A Roslyn-based C# source generation framework that enables multi-pass generation and parallel execution of generators.
Uno.SourceGeneration is a Roslyn-based source generation framework for C# that allows developers to generate C# source code during compilation. It provides an API-compatible alternative to Roslyn's built-in source generators with additional features like multi-pass generation and parallel execution. The framework enables generators to analyze the full syntactic and semantic model of the project being built.
C# developers and library authors who need to implement complex code generation scenarios, particularly those requiring generators to depend on each other or share compilation contexts.
Developers choose Uno.SourceGeneration over Roslyn's built-in generators because it supports multi-pass generation (where generators can depend on each other), parallel execution for better performance, and provides better MSBuild integration and debugging capabilities.
A Roslyn based C# source generation framework
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows generators to depend on each other using GenerateAfter/GenerateBefore attributes, enabling complex scenarios like generating code based on other generators' output, which Roslyn's built-in generators don't support.
Runs multiple generators in parallel while sharing the same expensive Roslyn compilation context, improving build performance for projects with many generators, as stated in the README.
Supports updating generators on the fly without locking assemblies, making iterative development easier and reducing restart times during debugging.
Provides direct access to MSBuild properties and items via GetProjectInstance or GetMSBuildPropertyValue, allowing fine-grained generator configuration without extra setup in MSBuild files.
API-compatible with Roslyn 3.8 source generators, so existing generators can be adapted with minimal changes while gaining Uno's extended features.
Requires manual creation of .props files, specific csproj modifications, and handling of target framework issues, making initial integration more involved than standard Roslyn generators.
Has known issues with mixed target frameworks graphs, such as generating code in a net47 project referencing netstandard2.0, requiring workarounds like adding additional targets.
Upgrades can introduce breaking changes, such as the need to update UWP target frameworks when moving to version 1.29, adding maintenance overhead.
Debugging generators requires explicit calls to Debugger.Launch() to attach a debugger, which is less seamless than integrated development tools and can interrupt workflow.