Skip to content

Conversation

Copy link

Copilot AI commented Jun 13, 2025

This PR updates both XAMLTest.Generator and XAMLTest.UnitTestGenerator from the legacy ISourceGenerator interface to the modern IIncrementalGenerator interface introduced in Roslyn 4.0.

Changes Made

ElementGenerator.cs

  • Interface Update: Changed from ISourceGenerator to IIncrementalGenerator
  • Initialization: Replaced Initialize(GeneratorInitializationContext) with Initialize(IncrementalGeneratorInitializationContext)
  • Execution Model: Replaced Execute(GeneratorExecutionContext) with RegisterSourceOutput using incremental value providers
  • Syntax Processing: Converted ISyntaxContextReceiver pattern to SyntaxProvider.CreateSyntaxProvider() with predicate and transform functions
  • Code Organization: Moved helper methods and constants from SyntaxReceiver class to static methods in ElementGenerator

UnitTestGenerator.cs

  • Applied the same incremental generator conversion pattern
  • Restructured static helper methods at class level
  • Maintained all existing business logic and output generation patterns

Benefits

The incremental source generator API provides several advantages:

  • Better Performance: Only regenerates code when relevant inputs change through intelligent caching
  • Improved IDE Experience: Better integration with IntelliSense and real-time diagnostics
  • Composable Pipeline: More modular and testable generator architecture
  • Future-Proof: Aligns with Microsoft's recommended approach for source generators

Verification

✅ Both generators build successfully with zero warnings
✅ Generated output remains identical to previous implementation
✅ Test compilation confirms generators produce expected files
✅ All existing functionality preserved

The migration maintains 100% backward compatibility while modernizing the codebase to use current best practices.

Fixes #280.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Update Source Generator to use new Incremental Source Generator Update Source Generators to use new Incremental Source Generator API Jun 13, 2025
Copilot AI requested a review from Keboo June 13, 2025 05:08
Copilot finished work on behalf of Keboo June 13, 2025 05:08
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.

Update Source Generator to use new Incremental Source Generator

2 participants