ZenithArch.Generator
1.0.0
dotnet add package ZenithArch.Generator --version 1.0.0
NuGet\Install-Package ZenithArch.Generator -Version 1.0.0
<PackageReference Include="ZenithArch.Generator" Version="1.0.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="ZenithArch.Generator" Version="1.0.0" />
<PackageReference Include="ZenithArch.Generator"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add ZenithArch.Generator --version 1.0.0
#r "nuget: ZenithArch.Generator, 1.0.0"
#:package ZenithArch.Generator@1.0.0
#addin nuget:?package=ZenithArch.Generator&version=1.0.0
#tool nuget:?package=ZenithArch.Generator&version=1.0.0
Zenith Arch
Compile-time architecture automation for .NET with Roslyn incremental source generation.
Installation
dotnet add package ZenithArch.Abstractions
dotnet add package ZenithArch.Generator
For source generator usage, configure analyzer-style reference:
<ItemGroup>
<PackageReference Include="ZenithArch.Abstractions" Version="1.0.8" />
<PackageReference Include="ZenithArch.Generator" Version="1.0.8" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
Optional CLI installation:
dotnet tool install --global ZenithArch.Cli --version 1.0.8
Quickstart
using ZenithArch.Abstractions.Attributes;
using ZenithArch.Abstractions.Enums;
[assembly: Architecture(
Profile = ArchitectureProfile.CqrsQuickStart,
Pattern = ArchitecturePattern.Cqrs,
GenerateDependencyInjection = true,
DbContextType = typeof(AppDbContext)
)]
namespace Demo.Domain;
[Entity]
public partial class Trip
{
public Guid Id { get; set; }
[Required]
[MinLength(3)]
[MaxLength(120)]
public string Name { get; set; } = string.Empty;
}
Build once:
dotnet build
Then register generated DI extensions:
builder.Services.AddZenithArchDependencies();
Full API Reference
ZenithArch.Abstractions.Attributes
ArchitectureAttribute: Assembly-level generation contract (pattern, profile, feature flags).- Example:
[assembly: Architecture(Pattern = ArchitecturePattern.Cqrs, GenerateDependencyInjection = true)]
- Example:
EntityAttribute: Marks a class as a generation candidate entity.- Example:
[Entity] public partial class Trip { }
- Example:
AggregateRootAttribute: Marks an entity as an aggregate root for domain-event-enabled generation.- Example:
[Entity, AggregateRoot] public partial class Order : EntityBase { }
- Example:
MapToAttribute: Declares DTO/view model mapping targets.- Example:
[MapTo(typeof(TripDto))] public partial class Trip : EntityBase { }
- Example:
QueryFilterAttribute: Marks properties as generated filter criteria.- Example:
[QueryFilter] public string? Name { get; set; }
- Example:
RequiredAttribute: Marks a property as required for generated validators.- Example:
[Required] public string Name { get; set; } = string.Empty;
- Example:
MinLengthAttribute: Declares minimum length validation.- Example:
[MinLength(3)] public string Name { get; set; } = string.Empty;
- Example:
MaxLengthAttribute: Declares maximum length validation.- Example:
[MaxLength(120)] public string Name { get; set; } = string.Empty;
- Example:
EmailAttribute: Marks a property for email-format validation.- Example:
[Email] public string ContactEmail { get; set; } = string.Empty;
- Example:
ZenithArch.Abstractions.Enums
ArchitecturePattern: Selects CQRS, Repository, or FullStack generation topology.- Example:
Pattern = ArchitecturePattern.FullStack
- Example:
ArchitectureProfile: Applies starter flag presets.- Example:
Profile = ArchitectureProfile.RepositoryQuickStart
- Example:
CqrsSaveMode: Controls write persistence timing.- Example:
CqrsSaveMode = CqrsSaveMode.PerRequestTransaction
- Example:
ZenithArch.Abstractions.Interfaces
IAggregateRoot: Aggregate marker with domain-event buffer contract.- Example:
public partial class Order : EntityBase, IAggregateRoot { }
- Example:
IDomainEvent: Domain event contract with occurrence timestamp.- Example:
public sealed record TripCreated(Guid TripId) : DomainEvent;
- Example:
IAuditable: Audit metadata contract.- Example:
public DateTime CreatedAt { get; set; }
- Example:
ISoftDelete: Soft-delete contract.- Example:
public bool IsDeleted { get; set; }
- Example:
ISpecification<T>: Query specification contract.- Example:
public Expression<Func<Trip, bool>>? Criteria { get; }
- Example:
ISecurityContext: User/tenant context abstraction.- Example:
public string? UserId => _http.User.Identity?.Name;
- Example:
IZenithArchExecutionObserver: Runtime observer hooks for telemetry.- Example:
public void OnValidationFailed(string requestName, int failureCount) { ... }
- Example:
ZenithArch.Abstractions.Base
EntityBase: Aggregate base type withId, domain event buffering, and clear operations.- Example:
public partial class Trip : EntityBase { }
- Example:
DomainEvent: Base immutable domain event record.- Example:
public sealed record TripUpdated(Guid TripId) : DomainEvent;
- Example:
Configuration
ArchitectureAttribute options
| Option | Type | Default | Valid values |
|---|---|---|---|
Profile |
ArchitectureProfile |
Custom |
Custom, CqrsQuickStart, RepositoryQuickStart, FullStackQuickStart |
Pattern |
ArchitecturePattern |
Cqrs |
Cqrs, Repository, FullStack |
UseSpecification |
bool |
false |
true / false |
UseUnitOfWork |
bool |
false |
true / false |
EnableValidation |
bool |
false |
true / false |
GenerateDependencyInjection |
bool |
false |
true / false |
GenerateEndpoints |
bool |
false |
true / false |
EnableExperimentalEndpoints |
bool |
false |
true / false |
GenerateDtos |
bool |
false |
true / false |
GenerateEfConfigurations |
bool |
false |
true / false |
GenerateCachingDecorators |
bool |
false |
true / false |
GeneratePagination |
bool |
false |
true / false |
DbContextType |
Type? |
null |
Any DbContext type |
CqrsSaveMode |
CqrsSaveMode |
PerHandler |
PerHandler, PerRequestTransaction |
Feature dependency expectations
- CQRS or FullStack generation:
MediatR - Validation generation:
FluentValidation - Persistence generation:
Microsoft.EntityFrameworkCore - Endpoint generation:
Microsoft.AspNetCore.App - Caching decorators:
Microsoft.Extensions.Caching.*
Versioning Policy
Zenith Arch follows SemVer (MAJOR.MINOR.PATCH).
- Breaking public API changes require a major version bump.
- New backward-compatible capabilities use a minor version bump.
- Backward-compatible fixes and process improvements use a patch bump.
Full change history: CHANGELOG.md
Contributing
Issues and pull requests are welcome.
- Open an issue with repro steps and expected behavior.
- Fork and create a feature branch.
- Add tests for behavior changes.
- Submit a pull request with changelog updates.
Contribution guidelines: CONTRIBUTING.md
License
MIT. See LICENSE.
Learn more about Target Frameworks and .NET Standard.
This package has 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 |
|---|---|---|
| 1.0.0 | 99 | 4/26/2026 |
ZenithArch 1.0.0: migration baseline for standardized NuGet process, SemVer governance, XML API docs, characterization tests, and CI tag-based publishing. Full changelog: https://github.com/tuanngp/ZenithArch/blob/main/CHANGELOG.md