Beskar.CodeGeneration.Extensions 1.2.1

dotnet add package Beskar.CodeGeneration.Extensions --version 1.2.1
                    
NuGet\Install-Package Beskar.CodeGeneration.Extensions -Version 1.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Beskar.CodeGeneration.Extensions" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Beskar.CodeGeneration.Extensions" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Beskar.CodeGeneration.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Beskar.CodeGeneration.Extensions --version 1.2.1
                    
#r "nuget: Beskar.CodeGeneration.Extensions, 1.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Beskar.CodeGeneration.Extensions@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Beskar.CodeGeneration.Extensions&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Beskar.CodeGeneration.Extensions&version=1.2.1
                    
Install as a Cake Tool

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 IAttributeSpec objects during transformation.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 84 4/29/2026
1.2.0 95 4/26/2026
1.1.9 88 4/25/2026
1.1.8 90 4/8/2026
1.1.7 89 4/7/2026
1.1.6 106 4/5/2026
1.1.5 92 4/5/2026
1.1.4 96 4/4/2026
1.1.3 92 4/4/2026
1.1.2 95 4/2/2026
1.1.1 101 4/2/2026
1.0.2 117 4/1/2026
1.0.0 96 4/1/2026