Skip to content

Add Roslyn incremental source generator samples#7091

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/add-roslyn-source-generator-samples
Draft

Add Roslyn incremental source generator samples#7091
Copilot wants to merge 6 commits intomainfrom
copilot/add-roslyn-source-generator-samples

Conversation

Copy link

Copilot AI commented Feb 6, 2026

  • Create csharp/roslyn-sdk/SourceGenerators/ folder structure
  • Sample 1: Attribute-based member generator (GenerateMembersAttribute)
  • Sample 2: Non-C# file to C# generator (CSV to strongly-typed class)
  • Build and verify both samples
  • Add unit tests for GenerateMembers source generator
    • Create GenerateMembers.Test project with xUnit + Roslyn testing infrastructure
    • Test: class with properties generates Describe() and PropertyNames
    • Test: struct with attribute generates correctly
    • Test: class without attribute produces no generated output
    • Test: class in global namespace generates without namespace block
  • Add unit tests for CsvGenerator source generator
    • Create CsvGenerator.Test project with xUnit + Roslyn testing infrastructure
    • Test: CSV with headers and rows generates strongly-typed class
    • Test: CSV with only header (no data rows) produces no output
    • Test: non-CSV additional file is ignored
    • Test: CSV with three columns generates all properties
  • Update solution file to include test projects
  • Build and run all tests (8/8 passing)

💡 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 3 commits February 6, 2026 18:48
…ation and CSV-to-C# generation

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Roslyn source generator samples Add Roslyn incremental source generator samples Feb 6, 2026
Copilot AI requested a review from agocke February 6, 2026 18:55
Copilot AI added a commit to dotnet/docs that referenced this pull request Feb 6, 2026
…sample

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
@agocke
Copy link
Member

agocke commented Feb 6, 2026

@copilot Please add unit tests

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 6, 2026

@copilot Please add unit tests

Added unit tests in commit 622124b. Created two test projects:

  • GenerateMembers.Test (4 tests): class with properties, struct with attribute, class without attribute (no output), and class in global namespace
  • CsvGenerator.Test (4 tests): CSV with headers/rows, header-only CSV (no output), non-CSV file ignored, and CSV with three columns

All 8 tests pass using MSTest with Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.MSTest.

@agocke
Copy link
Member

agocke commented Feb 6, 2026

@copilot please use xunit

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 6, 2026

@copilot please use xunit

Switched both test projects to xUnit in commit 5082e7f. Replaced MSTest with xunit 2.9.3 and Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit 1.1.2. All 8 tests pass.

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