AutoArchitecture 1.0.0
See the version list below for details.
dotnet add package AutoArchitecture --version 1.0.0
NuGet\Install-Package AutoArchitecture -Version 1.0.0
<PackageReference Include="AutoArchitecture" Version="1.0.0" />
<PackageVersion Include="AutoArchitecture" Version="1.0.0" />
<PackageReference Include="AutoArchitecture" />
paket add AutoArchitecture --version 1.0.0
#r "nuget: AutoArchitecture, 1.0.0"
#:package AutoArchitecture@1.0.0
#addin nuget:?package=AutoArchitecture&version=1.0.0
#tool nuget:?package=AutoArchitecture&version=1.0.0
AutoArchitecture
Free, MIT-licensed compile-time architecture rule enforcement for .NET. No commercial license, no separate desktop tool, no CI-only step — violations show up as build warnings/errors the moment they're introduced, right in your IDE.
Why AutoArchitecture?
Tools like NDepend are excellent for deep codebase analysis but require a paid commercial license. If all you need is "the UI layer must never reference the data-access layer directly," you shouldn't need a separate license and a separate analysis pass for that. AutoArchitecture is a Roslyn source generator: declare your rules once as assembly attributes, and every build enforces them for free.
[assembly: AutoArchitecture.ForbidDependency("MyApp.UI", "MyApp.DataAccess",
Because = "UI must go through the service layer, not the repositories directly")]
The moment any type in MyApp.UI (or a sub-namespace like MyApp.UI.Views) references a
type in MyApp.DataAccess (or a sub-namespace), you get:
warning AA001: 'OrderController' in namespace 'MyApp.UI' references 'OrderRepository' in
namespace 'MyApp.DataAccess', which is forbidden by
[assembly: ForbidDependency("MyApp.UI", "MyApp.DataAccess")]
(UI must go through the service layer, not the repositories directly)
Install
dotnet add package AutoArchitecture
Usage
Add one [assembly: ForbidDependency(from, to)] attribute per rule anywhere in your
project (e.g. in AssemblyInfo.cs or alongside your Program.cs):
[assembly: AutoArchitecture.ForbidDependency("MyApp.Presentation", "MyApp.Infrastructure")]
[assembly: AutoArchitecture.ForbidDependency("MyApp.Domain", "MyApp.Infrastructure")]
- Namespace matching includes sub-namespaces: a rule for
MyApp.DataAccessalso coversMyApp.DataAccess.Sql,MyApp.DataAccess.Migrations, etc. - Rules only match on exact/dot-boundary prefixes, so
MyApp.DataAccessdoes not accidentally match an unrelatedMyApp.DataAccessLegacynamespace. - The
Becausenamed argument is optional and is included verbatim in the diagnostic message — handy for explaining why the rule exists to whoever hits it next. - AA001 is a
Warningby default. Promote it to a build-breaking error per-project with a standard.editorconfigseverity override:dotnet_diagnostic.AA001.severity = error
Design goals
- MIT licensed, forever. No commercial tier, no per-seat fees, no desktop app to buy.
- Zero runtime cost — this is a source generator/analyzer; nothing ships in your compiled output.
- IDE-first feedback — violations appear as squiggles while you type, not just in a nightly CI report.
- Simple, declarative rules — no XML rule files or query languages to learn.
Roadmap
- Allow-list exceptions for specific types within an otherwise-forbidden namespace pair are planned for a future release, to support gradual migrations.
💼 Need .NET consulting?
I'm the author of AutoArchitecture and a suite of compile-time source generators (AutoWire, AutoMap.Generator) and 28+ Polly v8 resilience packages. I'm available for consulting on Polly v8 resilience, Azure cloud architecture, and clean .NET design.
→ solidqualitysolutions.com · LinkedIn
Also by the same author
🌐 Full suite overview: swevo.github.io
| Package | Description |
|---|---|
| AutoAssert | Free, MIT-licensed fluent assertions — alternative to FluentAssertions' commercial license. |
| EFCore.BulkOperations | Free, MIT-licensed bulk insert/update/delete for EF Core. |
| AutoWire | Compile-time DI auto-registration — [Scoped]/[Singleton]/[Transient] generates IServiceCollection registration code. |
| AutoMap.Generator | Compile-time object mapping — [Map(typeof(Dto))] generates ToDto() extension methods. |
| AutoDispatch.Generator | Compile-time CQRS dispatcher — free alternative to MediatR's commercial license. |
License
MIT © Justin Bannister
Learn more about Target Frameworks and .NET Standard.
-
.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.
1.0.0: Initial release. [assembly: ForbidDependency(from, to)] with AA001 diagnostic.