Skip to main content

Incursa.Generators by Incursa

NuGet / site data​

Nuget GitHub last commit GitHub Repo stars

Details​

Info​

info

Name: Incursa.Generators

Roslyn source generators for strongly typed identifiers, enums, DTOs, and value objects from JSON or XML definitions.

Author: Incursa

NuGet: https://www.nuget.org/packages/Incursa.Generators/

You can find more details at https://github.com/incursa/generators

Source: https://github.com/incursa/generators

Author​

note

Incursa Alt text

Original Readme​

note

Incursa.Generators​

Incursa.Generators generates strongly typed domain models from JSON and XML definition files. This example defines a Person DTO in Person.dto.json with required FirstName and LastName properties.

The generated Person.Create factory validates the new record before returning it. The demo creates a person and prints the full name. DTO/entity definitions use FluentValidation, so the project references that package directly.

See the Incursa.Generators repository for the full documentation and supported definition formats.

About​

note

Generating strongly typed DTO and entity models from JSON or XML definitions

How to use​

Example (source csproj, source files)​

This is the CSharp Project that references Incursa.Generators

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Incursa.Generators" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>analyzers;build;buildTransitive;contentFiles</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentValidation" Version="12.2.0" />
</ItemGroup>
</Project>

Generated Files​

Those are taken from $(BaseIntermediateOutputPath)\GX

// <auto-generated/>


#nullable enable

namespace Incursa.Generators.Demo;

using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using FluentValidation;

public partial record Person
{

/// <summary>
/// Gets the FirstName property.
/// </summary>
[Required]
public required string FirstName \{ get; init; }

/// <summary>
/// Gets the LastName property.
/// </summary>
[Required]
public required string LastName \{ get; init; }


// Private constructor to enforce strict DTO pattern
private Person() \{ }

/// <summary>
/// Factory method to create a validated instance of Person.
/// </summary>
public static Person Create(
string firstName,
string lastName)
{
var instance = new Person
{
FirstName = firstName,
LastName = lastName
};

instance.Validate();
return instance;
}
// Static validator instance
public static readonly PersonValidator Validator = new PersonValidator();

// Instance method for validation
public void Validate()
{
var validationResult = Validator.Validate(this);
if (!validationResult.IsValid)
{
throw new FluentValidation.ValidationException(validationResult.ToString());
}
}

// Method to check validation without throwing exceptions
public FluentValidation.Results.ValidationResult GetValidationResult()
{
return Validator.Validate(this);
}

/// <summary>
/// Internal FluentValidator class for validation rules.
/// </summary>
public partial class PersonValidator : AbstractValidator<Person>
{
public PersonValidator() : base()
{
RuleFor(x => x.FirstName).NotNull().WithMessage("'{FirstName}' is required.");
RuleFor(x => x.LastName).NotNull().WithMessage("'{LastName}' is required.");

// Hooks for additional validation
AddCustomValidation();
}

// Partial method for additional validation hooks
partial void AddCustomValidation();
}



}

Useful​

Download Example (.NET C#)​

Share Incursa.Generators​

https://ignatandrei.github.io/RSCG_Examples/v2/docs/Incursa.Generators

Category "EnhancementClass" has the following generators:​

1 AOP.Logging.SourceGenerator Nuget GitHub Repo stars 2026-08-30

2 ApparatusAOT Nuget GitHub Repo stars 2023-04-16

3 AspectGenerator Nuget GitHub Repo stars 2024-01-07

4 CommonCodeGenerator Nuget GitHub Repo stars 2024-04-03

5 Comparison Nuget GitHub Repo stars 2025-05-25

6 DudNet Nuget GitHub Repo stars 2023-10-27

7 Enhanced.GetTypes Nuget GitHub Repo stars 2024-09-17

8 FastGenericNew Nuget GitHub Repo stars 2023-08-10

9 Immutype Nuget GitHub Repo stars 2023-08-12

10 Incursa.Generators Nuget GitHub Repo stars 2026-11-22

11 Ling.Audit Nuget GitHub Repo stars 2023-12-12

12 Lombok.NET Nuget GitHub Repo stars 2023-04-16

13 M31.FluentAPI Nuget GitHub Repo stars 2023-08-25

14 MemberAccessor Nuget GitHub Repo stars 2025-03-24

15 MemoryPack Nuget GitHub Repo stars 2023-08-04

16 Meziantou.Polyfill Nuget GitHub Repo stars 2023-10-10

17 Microsoft.Extensions.Logging Nuget GitHub Repo stars 2023-04-16

18 Microsoft.Extensions.Options.Generators.OptionsValidatorGenerator Nuget GitHub Repo stars 2023-11-17

19 Microsoft.Interop.JavaScript.JSImportGenerator 2023-04-16

20 NLog.Extensions.ThisClass Nuget GitHub Repo stars 2026-04-03

21 OptionToStringGenerator Nuget GitHub Repo stars 2024-02-15

22 Pekspro.DataAnnotationValuesExtractor Nuget GitHub Repo stars 2026-02-15

23 Program Nuget GitHub Repo stars 2025-11-06

24 QueryStringGenerator Nuget GitHub Repo stars 2024-11-07

25 RSCG_Decorator Nuget GitHub Repo stars 2023-09-30

26 RSCG_UtilityTypes NugetNuget GitHub Repo stars 2023-12-22

27 StaticReflection NugetNuget GitHub Repo stars 2023-10-13

28 SyncMethodGenerator Nuget GitHub Repo stars 2023-08-14

29 System.Runtime.InteropServices Nuget GitHub Repo stars 2023-04-16

30 System.Text.RegularExpressions Nuget GitHub Repo stars 2023-04-16

31 TelemetryLogging Nuget GitHub Repo stars 2023-11-30

32 Tenekon.MethodOverloads.SourceGenerator Nuget GitHub Repo stars 2026-09-05

33 ThisClass Nuget GitHub Repo stars 2024-04-19

34 TrimItEasy Nuget GitHub Repo stars 2026-08-28

35 VoloGen NugetNuget GitHub Repo stars 2026-11-19

See category​

EnhancementClass