Delly.Modeling
2026.6.22
dotnet add package Delly.Modeling --version 2026.6.22
NuGet\Install-Package Delly.Modeling -Version 2026.6.22
<PackageReference Include="Delly.Modeling" Version="2026.6.22" />
<PackageVersion Include="Delly.Modeling" Version="2026.6.22" />
<PackageReference Include="Delly.Modeling" />
paket add Delly.Modeling --version 2026.6.22
#r "nuget: Delly.Modeling, 2026.6.22"
#:package Delly.Modeling@2026.6.22
#addin nuget:?package=Delly.Modeling&version=2026.6.22
#tool nuget:?package=Delly.Modeling&version=2026.6.22
Delly.Modeling
A .NET modeling library that provides source code generation capabilities for object modeling, enabling reflection-like property access and manipulation at compile time through Roslyn Source Generators.
Features
- Compile-time generation: Property access code is generated at compile time, eliminating runtime reflection overhead
- AOT-compatible: Works with Ahead-of-Time compilation (e.g., Native AOT)
- High performance: Up to 10x faster than traditional reflection-based property access
- Type safety: Compile-time type checking while maintaining dictionary-like property access
- Zero runtime allocation: Uses static singleton instances for models
- Framework support: .NET Standard 2.0 and .NET 6.0+
Installation
NuGet Packages
dotnet add package Delly.Modeling
dotnet add package Delly.Modeling.Generator
Quick Start
Mark your class with the [Modelable] attribute and declare it as partial:
using Delly.Modeling;
[Modelable]
public partial class User(string id)
{
public string Id { get; } = id;
public string Name { get; set; } = string.Empty;
public string? Password { get; set; }
public long Age { get; set; }
}
The source generator will automatically generate code that enables property access:
// Get the model for the User class
var model = User.GetModel();
// Get all property names
var properties = model.GetProperties();
// Returns array of property model objects
// Get a specific property
var ageProperty = model.GetProperty(nameof(User.Age));
// Get property value
var age = ageProperty?.GetValue(user);
// Set property value
ageProperty?.SetValue(user, 25L);
Supported Types
The library includes built-in models for common types:
string→StringModelint/Int32→Int32Modellong/Int64→Int64Modelbool/Boolean→BooleanModeldouble/Double→DoubleModeldecimal/Decimal→DecimalModelDateTime→DateTimeModelGuid→GuidModel
Performance
The source generator approach provides significant performance benefits over reflection:
| Method | 10M Operations | Overhead |
|---|---|---|
| Reflection | ~600ms | High |
| Source Generator | ~60ms | Minimal |
Benchmark results may vary depending on hardware and runtime
Project Structure
Delly.Modeling - Core modeling library (.NET Standard 2.0, .NET 6.0)
ModelableAttribute- Attribute to mark classes for source generationIModel- Interface for model objectsIModelProperty- Interface for model properties- Built-in type models in the
Modelsnamespace
Delly.Modeling.Generator - Roslyn Source Generator (.NET Standard 2.0)
ModelableSourceGenerator.cs- Main source generator implementationModelableSyntaxReceiver.cs- Syntax receiver for collecting [Modelable] classes
Deme - Performance benchmark demonstration application (.NET 10.0 with AOT)
NugetDemo - NuGet package usage demonstration
Building and Running
# Build the solution
dotnet build
# Run the demo application (with benchmark)
cd Deme
dotnet run
How It Works
- Mark a class with
[Modelable]and declare it aspartial - The source generator scans for classes with this attribute at compile time
- Generated code includes:
- A static
GetModel()method that returns the model singleton - Property model classes implementing
IModelPropertyfor each property - A main model class implementing
IModelwith property access methods
- A static
- All generated code is emitted to
obj/Generatedand compiled with your project
License
See LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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
- System.ComponentModel.Annotations (>= 5.0.0)
-
net6.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 | 39 | 6/3/2026 |
| 2026.6.21 | 43 | 6/3/2026 |
| 2026.5.20 | 90 | 5/29/2026 |
| 2026.5.19 | 101 | 5/28/2026 |
| 2026.5.18 | 101 | 5/27/2026 |
| 2026.5.16 | 80 | 5/25/2026 |
| 2026.5.12 | 90 | 5/25/2026 |
| 2026.5.9 | 93 | 5/24/2026 |
| 2026.5.8 | 96 | 5/24/2026 |
| 2026.5.7 | 104 | 5/24/2026 |
| 2026.5.6 | 89 | 5/24/2026 |
| 2026.5.5 | 88 | 5/24/2026 |
| 2026.5.4 | 94 | 5/23/2026 |
| 2026.5.3 | 94 | 5/20/2026 |
| 2026.5.2 | 89 | 5/20/2026 |
| 2026.5.1 | 99 | 5/20/2026 |