Skip to content

Conversation

Copy link

Copilot AI commented Dec 16, 2025

Upgrades the repository to use modern C# language features while maintaining backward compatibility.

Changes

Framework & Language

  • Upgraded .NET 6.0 → .NET 9.0 (eliminates EOL warnings)
  • Set LangVersion to C# 13

File-scoped Namespaces (C# 10)

// Before
namespace DiffPlex.Model
{
    public class DiffResult { ... }
}

// After
namespace DiffPlex.Model;

public class DiffResult { ... }

Primary Constructors (C# 12)

// Before
public class DiffBlock
{
    public int DeleteStartA { get; }
    public int DeleteCountA { get; }
    
    public DiffBlock(int deleteStartA, int deleteCountA)
    {
        DeleteStartA = deleteStartA;
        DeleteCountA = deleteCountA;
    }
}

// After
public class DiffBlock(int deleteStartA, int deleteCountA)
{
    public int DeleteStartA { get; } = deleteStartA;
    public int DeleteCountA { get; } = deleteCountA;
}

Collection Expressions (C# 12)

// Before
public List<DiffPiece> Lines { get; } = new List<DiffPiece>();
private readonly string[] lineSeparators = new[] {"\r\n", "\r", "\n"};

// After
public List<DiffPiece> Lines { get; } = [];
private readonly string[] lineSeparators = ["\r\n", "\r", "\n"];

Target-typed New (C# 9)

// Before
public static Differ Instance { get; } = new Differ();

// After
public static Differ Instance { get; } = new();

Impact

  • 27 source files modernized
  • Zero breaking changes (multi-targeting preserved: net45, netstandard2.0, net9.0)
  • All 248 tests passing
Original prompt

Upgrade this repo to use the most recent C# features


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits December 16, 2025 20:44
- Update target frameworks from net6.0 to net9.0
- Set LangVersion to C# 13
- Convert to file-scoped namespaces
- Apply primary constructors where applicable
- Use collection expressions consistently
- Use target-typed new expressions

Co-authored-by: mmanela <[email protected]>
- Convert all Model classes to file-scoped namespaces and primary constructors
- Convert all interface files to file-scoped namespaces
- Use collection expressions and target-typed new consistently
- Modernize property syntax with expression-bodied members

Co-authored-by: mmanela <[email protected]>
- Convert all remaining implementation files to file-scoped namespaces
- Apply modernizations to ThreeWayDiffer, SideBySideDiffBuilder, and UnidiffRenderer
- Use collection expressions and target-typed new consistently
- Apply primary constructor to PieceComparer nested class

Co-authored-by: mmanela <[email protected]>
- Apply target-typed new to EditLengthResult object initializers
- Maintain consistency with modernization approach throughout codebase

Co-authored-by: mmanela <[email protected]>
Copilot AI changed the title [WIP] Update repository to utilize recent C# features Modernize codebase to C# 13 Dec 16, 2025
Copilot AI requested a review from mmanela December 16, 2025 21:01
@mmanela mmanela closed this Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants