Atom uses Roslyn source generators and analysers to reduce boilerplate. This page explains what they do and how they affect your build definition.
| Package | Role |
|---|---|
Invex.Atom.Build.SourceGenerators |
Generates code for [BuildDefinition], [GenerateEntryPoint], [ConfigureHostBuilder], [GenerateSolutionModel], and [GenerateInterfaceMembers]. |
Invex.Atom.Build.Analyzers |
Reports diagnostics for common mistakes (e.g. forgetting partial, missing attributes). |
Both are automatically referenced when you add Invex.Atom.Build.
For a class decorated with [BuildDefinition], the generator emits:
TargetDefinitions— a dictionary mapping target names toTargetdelegates, collected from the class and all implemented interfaces.ParamDefinitions— a dictionary mapping parameter names toParamDefinitionrecords, collected from[ParamDefinition]/[SecretDefinition]attributes.AccessParam— a method that can read any declared parameter by name.
Emits a Program class with:
AtomHost.Run<Build>(args);For interfaces marked with [ConfigureHostBuilder], the generator declares a ConfigureBuilderFrom{InterfaceName}
partial method and ensures that when a [BuildDefinition] class implements the interface, that method is called during
host setup.
Scans the solution file and emits a typed model with project paths.
Generates boilerplate interface members (e.g. forwarding properties) so module authors don't have to write them manually.
The analyser package reports warnings and errors such as:
- Build definition class is not
partial [BuildDefinition]is missing on a class that inheritsBuildDefinition- Target properties that don't follow the expected pattern
To inspect the generated code:
-
In your
.csproj, add:<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
-
Build the project. Generated files appear under
obj/Debug/net*/generated/.
→ Testing