Skip to content

Commit e4858fc

Browse files
authored
Merge pull request #5 from randlee/develop
fix: Match standard unified diff format for line-mode output
2 parents c4c0409 + 73db3f4 commit e4858fc

File tree

59 files changed

+1670
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1670
-107
lines changed

.serena/memories/code_style.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Code Style and Conventions
2+
3+
## Namespace Style
4+
- File-scoped namespaces (no braces): `namespace RoslynDiff.Output;`
5+
6+
## Documentation
7+
- XML documentation comments for public APIs
8+
- Use `/// <inheritdoc/>` for interface implementations
9+
- Summary sections for classes and methods
10+
11+
## Code Patterns
12+
- Records for immutable data models
13+
- Collection expressions `[]` for initializing collections
14+
- Pattern matching with `is` and `switch` expressions
15+
- Async/await with Task-based async pattern
16+
17+
## Testing Style
18+
- xUnit with `[Fact]` attributes
19+
- FluentAssertions for assertions
20+
- Arrange/Act/Assert pattern in comments
21+
- Test class naming: `{ClassName}Tests`
22+
- Test method naming: `{MethodName}_{Condition}_{ExpectedResult}`
23+
24+
## Null Handling
25+
- Nullable reference types enabled
26+
- Use `??=` for null-coalescing assignment
27+
- Use `?.` for null-conditional access
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# roslyn-diff Project Overview
2+
3+
## Purpose
4+
roslyn-diff is a semantic diff tool for .NET using Roslyn. It provides semantic-aware diffing capabilities for C# code, understanding code structure rather than just line-by-line text comparison.
5+
6+
## Tech Stack
7+
- .NET 10.0
8+
- C#
9+
- Roslyn (Microsoft.CodeAnalysis) for semantic code analysis
10+
- Spectre.Console for rich terminal output
11+
- xUnit for testing with FluentAssertions and NSubstitute
12+
13+
## Project Structure
14+
- `src/RoslynDiff.Core/` - Core diff engine and models
15+
- `src/RoslynDiff.Output/` - Output formatters (JSON, HTML, Plain Text, Terminal/Spectre)
16+
- `src/RoslynDiff.Cli/` - Command-line interface
17+
- `tests/` - Unit tests for each project
18+
19+
## Key Models (in RoslynDiff.Core.Models)
20+
- `DiffResult` - Main result containing file changes and stats
21+
- `Change` - Individual change with type, kind, location, content
22+
- `ChangeType` - Added, Removed, Modified, Moved, Renamed, Unchanged
23+
- `ChangeKind` - File, Namespace, Class, Method, Property, Field, Statement, Line
24+
- `DiffStats` - Statistics about changes
25+
26+
## Output Formatters
27+
Implement `IOutputFormatter` interface with:
28+
- `Format` property (format identifier like "json", "text", "terminal")
29+
- `ContentType` property (MIME type)
30+
- `FormatResult()` method
31+
- `FormatResultAsync()` method
32+
33+
Available formatters:
34+
- JsonOutputFormatter - JSON output
35+
- PlainTextFormatter - Simple text (no ANSI codes, good for pipes)
36+
- SpectreConsoleFormatter - Rich terminal output with colors
37+
- HtmlFormatter - HTML output
38+
- UnifiedFormatter - Unified diff format
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Suggested Commands for roslyn-diff
2+
3+
## Building
4+
```bash
5+
dotnet build # Build the entire solution
6+
dotnet build src/RoslynDiff.Output/RoslynDiff.Output.csproj # Build specific project
7+
```
8+
9+
## Testing
10+
```bash
11+
dotnet test # Run all tests
12+
dotnet test --no-build # Run tests without rebuilding
13+
dotnet test --filter "FullyQualifiedName~PlainTextFormatterTests" # Run specific tests
14+
```
15+
16+
## Cleaning
17+
```bash
18+
dotnet clean # Clean build artifacts
19+
```
20+
21+
## Running the CLI
22+
```bash
23+
dotnet run --project src/RoslynDiff.Cli -- <args>
24+
```
25+
26+
## Git
27+
```bash
28+
git status # Check modified files
29+
git diff # See changes
30+
```

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Git integration (compare commits, branches)
1414
- F# support via FSharp.Compiler.Service
1515

16-
## [1.0.0] - 2025-XX-XX
16+
## [0.5.0] - 2026-01-15
1717

1818
### Added
1919

@@ -93,7 +93,7 @@ This project follows [Semantic Versioning](https://semver.org/):
9393

9494
| Phase | Version | Features |
9595
|-------|---------|----------|
96-
| Phase 1 | v1.0.0 | Core CLI (current) |
96+
| Phase 1 | v0.5.0 | Core CLI (current) |
9797
| Phase 2 | v1.x | MCP Server integration |
9898
| Phase 3 | v2.0 | Folder/project/git support |
9999
| Phase 4 | v3.0 | Solution-level comparison |

Directory.Build.props

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@
1313
<NoWarn>$(NoWarn);1591</NoWarn>
1414
</PropertyGroup>
1515

16+
<!-- Version: Single source of truth for all assemblies and NuGet packages -->
17+
<PropertyGroup>
18+
<Version>0.5.0</Version>
19+
<AssemblyVersion>0.5.0.0</AssemblyVersion>
20+
<FileVersion>0.5.0.0</FileVersion>
21+
</PropertyGroup>
22+
1623
<PropertyGroup>
1724
<Authors>RoslynDiff Contributors</Authors>
1825
<Company>RoslynDiff</Company>
19-
<Copyright>Copyright (c) 2025 RoslynDiff Contributors</Copyright>
26+
<Copyright>Copyright (c) 2025-2026 RoslynDiff Contributors</Copyright>
2027
<RepositoryUrl>https://github.com/randlee/roslyn-diff</RepositoryUrl>
2128
<RepositoryType>git</RepositoryType>
2229
</PropertyGroup>

RELEASE_NOTES.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# roslyn-diff v0.5.0 Release Notes
2+
3+
**Release Date:** January 15, 2026
4+
5+
## Release Highlights
6+
7+
This is the first stable release of roslyn-diff, a semantic diff tool for .NET source code using the Roslyn compiler platform. Unlike traditional line-by-line diff tools, roslyn-diff understands code structure, enabling it to detect and report changes at the semantic level.
8+
9+
### Key Capabilities
10+
11+
- **Semantic Code Understanding** - Uses Roslyn to parse and analyze code structure
12+
- **Multi-Language Support** - Full semantic diff for C# and VB.NET; line-based diff for other files
13+
- **Intelligent Change Detection** - Detects additions, deletions, modifications, renames, and moves
14+
- **Flexible Output** - JSON for AI/tooling, HTML reports, and terminal output
15+
- **Class Comparison** - Compare specific classes with multiple matching strategies
16+
17+
## Features
18+
19+
### Semantic Diff Engine
20+
21+
- **C# Support** - Full semantic analysis of C# source files (.cs)
22+
- **VB.NET Support** - Full semantic analysis of Visual Basic source files (.vb)
23+
- **Line-by-Line Fallback** - Traditional diff for non-.NET files using DiffPlex
24+
- **Rename Detection** - Identifies when symbols are renamed rather than added/removed
25+
- **Move Detection** - Detects code that has been relocated within a file
26+
27+
### Change Detection
28+
29+
Detects changes to:
30+
- Classes, structs, records, and interfaces
31+
- Methods and functions
32+
- Properties and fields
33+
- Namespaces
34+
- Statement-level changes (in Roslyn mode)
35+
36+
### CLI Commands
37+
38+
#### `diff` Command
39+
Compare two files with semantic understanding:
40+
```bash
41+
roslyn-diff diff old.cs new.cs
42+
roslyn-diff diff old.cs new.cs --output json
43+
roslyn-diff diff old.cs new.cs --output html --out-file report.html
44+
```
45+
46+
**Options:**
47+
- `--mode <auto|roslyn|line>` - Select diff algorithm
48+
- `--ignore-whitespace` / `-w` - Ignore whitespace differences
49+
- `--ignore-comments` / `-c` - Ignore comment differences
50+
- `--context` / `-C` - Control context lines
51+
- `--output` / `-o` - Select output format (json, html, text, plain, terminal)
52+
- `--rich` / `-r` - Rich terminal output with colors
53+
54+
#### `class` Command
55+
Compare specific classes between files:
56+
```bash
57+
roslyn-diff class old.cs:Calculator new.cs:Calculator
58+
roslyn-diff class old.cs new.cs --match-by interface --interface IRepository
59+
```
60+
61+
**Options:**
62+
- `--match-by <exact|interface|similarity|auto>` - Matching strategy
63+
- `--interface` / `-i` - Interface name for interface matching
64+
- `--similarity` / `-s` - Similarity threshold (0.0-1.0)
65+
66+
### Output Formats
67+
68+
| Format | Description | Best For |
69+
|--------|-------------|----------|
70+
| `json` | Machine-readable structured output | AI tools, CI/CD, automation |
71+
| `html` | Interactive report with syntax highlighting | Code reviews, documentation |
72+
| `text` | Unified diff format (like git diff) | Quick review, command line |
73+
| `plain` | Simple text without ANSI codes | Piping, scripting |
74+
| `terminal` | Rich console output with colors | Interactive terminal use |
75+
76+
### Programmatic API
77+
78+
Use roslyn-diff as a library in your .NET applications:
79+
80+
```csharp
81+
using RoslynDiff.Core.Differ;
82+
using RoslynDiff.Core.Models;
83+
84+
var factory = new DifferFactory();
85+
var differ = factory.GetDiffer("file.cs", new DiffOptions());
86+
var result = differ.Compare(oldContent, newContent, options);
87+
```
88+
89+
## Installation
90+
91+
### As a .NET Tool (Recommended)
92+
93+
```bash
94+
dotnet tool install -g roslyn-diff
95+
```
96+
97+
### From Source
98+
99+
```bash
100+
git clone https://github.com/randlee/roslyn-diff.git
101+
cd roslyn-diff
102+
dotnet build
103+
```
104+
105+
### Run Without Installing
106+
107+
```bash
108+
cd src/RoslynDiff.Cli
109+
dotnet run -- diff old.cs new.cs
110+
```
111+
112+
## Requirements
113+
114+
- .NET 10.0 or later
115+
116+
## Dependencies
117+
118+
- Microsoft.CodeAnalysis.CSharp 4.12.0
119+
- Microsoft.CodeAnalysis.VisualBasic 4.12.0
120+
- DiffPlex 1.7.2
121+
- Spectre.Console 0.49.x
122+
- System.CommandLine 2.0.0-beta4
123+
124+
## Breaking Changes
125+
126+
None - this is the initial stable release.
127+
128+
## Known Issues
129+
130+
- Large files (1000+ methods) may experience longer processing times (3-10 seconds)
131+
- Roslyn mode requires .cs or .vb files; other extensions fall back to line diff
132+
- System.CommandLine is in beta; some edge cases in argument parsing may exist
133+
134+
## Migration from Pre-release Versions
135+
136+
If upgrading from 0.x pre-release versions:
137+
138+
1. **CLI Changes**
139+
- `--format` has been renamed to `--output` / `-o`
140+
- Default output format is now `text` (was `terminal`)
141+
- Use `--rich` / `-r` for colored terminal output
142+
143+
2. **API Changes**
144+
- `DiffResult` is now a record type (immutable)
145+
- `Change.Location` split into `OldLocation` and `NewLocation`
146+
- `OutputFormatter` interface renamed to `IOutputFormatter`
147+
148+
3. **JSON Output Schema**
149+
- Schema version updated to `roslyn-diff-output-v1`
150+
- `summary` object structure changed
151+
- Location objects now include `startColumn` and `endColumn`
152+
153+
## Documentation
154+
155+
- [README](./README.md) - Getting started guide
156+
- [Usage Guide](./docs/usage.md) - Detailed CLI usage
157+
- [Output Formats](./docs/output-formats.md) - Format specifications
158+
- [API Reference](./docs/api.md) - Programmatic API documentation
159+
- [Architecture](./docs/architecture.md) - Project design
160+
- [Performance Guide](./docs/performance.md) - Benchmarks and optimization
161+
162+
## Future Roadmap
163+
164+
Planned for future releases:
165+
- MCP Server integration for AI tooling (v1.x)
166+
- Folder/project comparison (v2.0)
167+
- Git integration (compare commits, branches) (v2.0)
168+
- F# support via FSharp.Compiler.Service (v2.0)
169+
- Solution-level comparison (v3.0)
170+
171+
## Acknowledgments
172+
173+
- [Roslyn](https://github.com/dotnet/roslyn) - The .NET Compiler Platform
174+
- [DiffPlex](https://github.com/mmanela/diffplex) - .NET Diff library
175+
- [Spectre.Console](https://github.com/spectreconsole/spectre.console) - Beautiful console applications
176+
177+
## License
178+
179+
MIT License - see [LICENSE](./LICENSE) for details.
180+
181+
---
182+
183+
Full changelog available at [CHANGELOG.md](./CHANGELOG.md)

docs/output-formats.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ roslyn-diff diff old.cs new.cs -o json --out-file diff.json
4242
"$schema": "roslyn-diff-output-v1",
4343
"metadata": {
4444
"tool": "roslyn-diff",
45-
"version": "1.0.0",
45+
"version": "0.5.0",
4646
"timestamp": "2025-01-14T20:00:00Z",
4747
"mode": "roslyn",
4848
"oldPath": "old/Service.cs",

icon.png

4.06 KB
Loading

icon.svg

Lines changed: 30 additions & 0 deletions
Loading

plan/sprint-plan.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# roslyn-diff - Sprint Plan
22

3+
## Progress Summary (Updated: 2026-01-15)
4+
5+
| Sprint | Status | Tests | Key Deliverables |
6+
|--------|--------|-------|------------------|
7+
| Sprint 1 | ✅ Complete | 52 | LineDiffer, DifferFactory, Basic CLI |
8+
| Sprint 2 | ✅ Complete | 65 | CSharpDiffer, SyntaxComparer, NodeMatcher |
9+
| Sprint 3 | ✅ Complete | 242 | VisualBasicDiffer, SemanticComparer, SymbolMatcher |
10+
| Sprint 4 | ✅ Complete | 242 | JsonFormatter, HtmlFormatter, PlainText, SpectreConsole |
11+
| Sprint 5 | ✅ Complete | 361 | ClassMatcher, `class` command, CLI options |
12+
| Sprint 6 | ✅ Complete | 650 | Edge case tests, Integration tests, Documentation, Benchmarks |
13+
| Sprint 7 | ✅ Complete | 650 | NuGet package config, Release artifacts, Final testing |
14+
15+
### Current State
16+
- **Branch**: release/v0.5.0
17+
- **Open PR**: #4 (release/v0.5.0 → main) - Contains Sprint 7
18+
- **Total Tests**: 650 passing (321 Core + 130 Output + 84 CLI + 115 Integration)
19+
- **Documentation**: Complete (README, docs/, samples/, CHANGELOG, RELEASE_NOTES)
20+
- **Package**: Configured and tested (ready for NuGet publish)
21+
22+
---
23+
324
## Sprint Overview
425

526
| Sprint | Focus | Duration | Dependencies |

0 commit comments

Comments
 (0)