Delly.Modeling.Generator
2026.6.22
dotnet add package Delly.Modeling.Generator --version 2026.6.22
NuGet\Install-Package Delly.Modeling.Generator -Version 2026.6.22
<PackageReference Include="Delly.Modeling.Generator" Version="2026.6.22" />
<PackageVersion Include="Delly.Modeling.Generator" Version="2026.6.22" />
<PackageReference Include="Delly.Modeling.Generator" />
paket add Delly.Modeling.Generator --version 2026.6.22
#r "nuget: Delly.Modeling.Generator, 2026.6.22"
#:package Delly.Modeling.Generator@2026.6.22
#addin nuget:?package=Delly.Modeling.Generator&version=2026.6.22
#tool nuget:?package=Delly.Modeling.Generator&version=2026.6.22
Delly.Modeling.Generator
Roslyn Source Generator for Delly.Modeling - provides compile-time code generation for object modeling.
Overview
This source generator automatically generates code for classes marked with the [Modelable] attribute, enabling reflection-like property access with zero runtime overhead.
Framework
- Target Framework: .NET Standard 2.0
- Language Version: Latest C#
Dependencies
| Package | Version | Purpose |
|---|---|---|
| Microsoft.CodeAnalysis.CSharp | 4.12.0 | C# compilation and syntax analysis |
| Microsoft.CodeAnalysis.Analyzers | 3.3.4 | Roslyn analyzer support |
How It Works
The generator consists of two main components:
1. ModelableSyntaxReceiver
Collects class declarations that have the [Modelable] attribute during syntax tree traversal.
Location: ModelableSyntaxReceiver.cs
2. ModelableSourceGenerator
The main generator that:
- Scans for classes with
[Modelable]attribute - Analyzes properties and their types
- Generates extension methods for property access
- Outputs generated code to
obj/Generated
Location: ModelableSourceGenerator.cs
Generated Code Structure
For a class named User with properties, the generator creates:
1. GetModel() Extension Method
public partial class User
{
public static c__UserModel GetModel() => c__UserModel.Instance;
}
2. Property Model Classes
For each property, a class implementing IModelProperty:
public class p__UserModel_Age : IModelProperty
{
public string Name => nameof(User.Age);
public IModel PropertyModel => Int64Model.Instance;
public object? GetValue(object? obj) { ... }
public void SetValue(object? obj, object? value) { ... }
}
3. Main Model Class
public class c__UserModel : IModel
{
public static c__UserModel Instance => _instance;
public string Name => "UserModel";
public string Namespace => "...";
public IModelProperty[] GetProperties() { ... }
public IModelProperty? GetProperty(string name) { ... }
}
Type Support
The generator handles the following types with appropriate conversion:
| Type | Model Class | Conversion Expression |
|---|---|---|
string |
StringModel | value?.ToString() |
int / Int32 |
Int32Model | Convert.ToInt32(value) |
long / Int64 |
Int64Model | Convert.ToInt64(value) |
bool / Boolean |
BooleanModel | Convert.ToBoolean(value) |
double / Double |
DoubleModel | Convert.ToDouble(value) |
decimal / Decimal |
DecimalModel | Convert.ToDecimal(value) |
DateTime |
DateTimeModel | Convert.ToDateTime(value) |
Guid |
GuidModel | Guid.Parse(value?.ToString()) |
Special Handling
- Read-only properties:
SetValue()throwsNotSupportedException - Nullable reference types: Proper null checking with
NoNullAllowedExceptionfor non-nullable values - Nullable value types: Automatically unwrapped to their underlying types
Integration
The generator is packaged as a Roslyn analyzer and automatically integrates with projects that reference the Delly.Modeling.Generator NuGet package.
License
See LICENSE file in the root repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.6.22 | 86 | 6/3/2026 |
| 2026.6.21 | 90 | 6/3/2026 |
| 2026.5.20 | 93 | 5/29/2026 |
| 2026.5.19 | 99 | 5/28/2026 |
| 2026.5.18 | 93 | 5/27/2026 |
| 2026.5.16 | 87 | 5/25/2026 |
| 2026.5.12 | 85 | 5/25/2026 |
| 2026.5.9 | 87 | 5/24/2026 |
| 2026.5.8 | 85 | 5/24/2026 |
| 2026.5.7 | 81 | 5/24/2026 |
| 2026.5.6 | 86 | 5/24/2026 |
| 2026.5.5 | 82 | 5/24/2026 |
| 2026.5.4 | 87 | 5/23/2026 |
| 2026.5.3 | 91 | 5/20/2026 |
| 2026.5.2 | 91 | 5/20/2026 |
| 2026.5.1 | 86 | 5/20/2026 |