AStarDev.SourceGenerators
0.1.0
See the version list below for details.
dotnet add package AStarDev.SourceGenerators --version 0.1.0
NuGet\Install-Package AStarDev.SourceGenerators -Version 0.1.0
<PackageReference Include="AStarDev.SourceGenerators" Version="0.1.0" />
<PackageVersion Include="AStarDev.SourceGenerators" Version="0.1.0" />
<PackageReference Include="AStarDev.SourceGenerators" />
paket add AStarDev.SourceGenerators --version 0.1.0
#r "nuget: AStarDev.SourceGenerators, 0.1.0"
#:package AStarDev.SourceGenerators@0.1.0
#addin nuget:?package=AStarDev.SourceGenerators&version=0.1.0
#tool nuget:?package=AStarDev.SourceGenerators&version=0.1.0
Roslyn Source Generators Sample
A set of three projects that illustrates Roslyn source generators. Enjoy this template to learn from and modify source generators for your own needs.
Content
AStarDev.SourceGenerators
A .NET Standard project with implementations of sample source generators. You must build this project to see the result (generated code) in the IDE.
- SampleSourceGenerator.cs: A source generator that creates C# classes based on a text file (in this case, Domain Driven Design ubiquitous language registry).
- SampleIncrementalSourceGenerator.cs: A source generator that creates a custom report based on class properties. The target class should be annotated with the
Generators.ReportAttributeattribute.
AStarDev.SourceGenerators.Sample
A project that references source generators. Note the parameters of ProjectReference in AStarDev.SourceGenerators.Sample.csproj, they make sure that the project is referenced as a set of source generators.
AStarDev.SourceGenerators.Tests
Unit tests for source generators. The easiest way to develop language-related features is to start with unit tests.
How To?
How to debug?
- Use the launchSettings.json profile.
- Debug tests.
How can I determine which syntax nodes I should expect?
Consider using the Roslyn Visualizer toolwindow, witch allow you to observe syntax tree.
How to learn more about wiring source generators?
Watch the walkthrough video: Let’s Build an Incremental Source Generator With Roslyn, by Stefan Pölz The complete set of information is available in Source Generators Cookbook.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v0.1.7 - Fix bug in AutoRegisterServiceAttribute detection/code generation.
v0.1.6 - Fix build and packaging issues.
v0.1.5 - Update dependencies to latest Roslyn versions.
v0.1.4 - Add missing namespace in generated ServiceRegistrations class.
- Rename ServiceAttribute to AutoRegisterServiceAttribute for clarity