Beskar.CodeGeneration.Extensions
1.1.6
See the version list below for details.
dotnet add package Beskar.CodeGeneration.Extensions --version 1.1.6
NuGet\Install-Package Beskar.CodeGeneration.Extensions -Version 1.1.6
<PackageReference Include="Beskar.CodeGeneration.Extensions" Version="1.1.6" />
<PackageVersion Include="Beskar.CodeGeneration.Extensions" Version="1.1.6" />
<PackageReference Include="Beskar.CodeGeneration.Extensions" />
paket add Beskar.CodeGeneration.Extensions --version 1.1.6
#r "nuget: Beskar.CodeGeneration.Extensions, 1.1.6"
#:package Beskar.CodeGeneration.Extensions@1.1.6
#addin nuget:?package=Beskar.CodeGeneration.Extensions&version=1.1.6
#tool nuget:?package=Beskar.CodeGeneration.Extensions&version=1.1.6
Beskar.CodeGeneration.Extensions
A comprehensive suite of utilities and models designed to simplify the development of C# Source Generators. This package provides high-level abstractions ("Archetypes") and fluent extension methods to handle Roslyn symbols and attribute data efficiently.
Core Features
🏛️ Symbol Archetypes
Roslyn's ISymbol objects are not suitable for rendering storage or caching in incremental
generators because they hold references to the entire compilation. These extensions provide
"Archetypes" (like NamedTypeSymbolArchetype or MethodSymbolArchetype) which are lightweight,
serializable records containing only the metadata needed for code generation.
- Field Archetypes: Capture
RefKind,IsReadOnly,IsVolatile, and constant values. - Method Archetypes: Track return types, parameters, async/iterator status, and accessibility.
- Type Archetypes: Handle inheritance, interface implementations, and generic constraints.
- Parameter Archetypes: Stores ordinal position, scope, and optionality.
- Property Archetypes: Includes metadata for getters, setters, and indexer status.
And more...
🛠️ Extension Methods
Attribute Data Handling
The package provides powerful "Fallback" extensions to resolve attribute values. These methods automatically check for named arguments first and fall back to positional constructor arguments if the named one is missing.
// Example: Determine a value regardless of how the user provided it
string? value = attribute.DetermineStringValue(name: "ParameterName", index: 0, defaultValue: "Default");
bool isEnabled = attribute.DetermineBoolValue("Enabled", 1, true);
Supported types for determination include:
- Primitives:
bool,int,long,float,double,decimal,byte,short,char,uint,ulong. - Complex:
ITypeSymbol,IFieldSymbol(Enums). - Arrays: Specialized support for arrays of all the above types.
⚙️ Configurable Transformation
Use ArchetypeTransformOptions to control the depth and detail of the symbol transformation to optimize performance and memory usage.
- Depth Control: Limit how deep the transformer navigates the type tree (e.g., stopping at the first level of base types).
- Load Flags: Fine-grained control over whether to load attributes, interfaces, or specific member types.
- Filtering: Provide custom predicates (e.g.,
MethodFilter) to only include relevant members in the generated Archetype. - Attribute Registration: Register specific attributes that should be parsed into
IAttributeSpecobjects during transformation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Me.Memory (>= 1.3.7)
- Microsoft.CodeAnalysis.Common (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.