ArchUnit.NET

Architecture testing for .NET. Analyze C# projects and express boundaries as fluent, testable rules. The alpha includes cycles, dependency policies, naming, presets, baselines, and SARIF or HTML reporting for xUnit, NUnit, MSTest, and framework-neutral use.

C# & .NETApache-2.0

NuGet

dotnet add package ArchUnit --version 2.4.0-alpha.2
ArchitectureTests.cs
using ArchUnitNet;
using ArchUnitNet.Testing.XUnit;

[Fact]
public async Task DomainStaysIndependent()
{
    var rule = ArchUnit.ProjectFiles("./App.csproj")
        .InPath("src/Domain/**")
        .ShouldNot()
        .DependOnFiles()
        .InPath("src/Infrastructure/**");

    await rule.PassesAsync();
}

The ecosystem

.NET, in context.

.NET is Microsoft's cross-platform application runtime and developer platform. C# is its most widely used language, although .NET also supports F# and Visual Basic. Teams use C# and .NET for ASP.NET web APIs, cloud services, desktop applications, games, and large enterprise systems.

01

C# is the primary language; .NET is the runtime and platform

02

ASP.NET, cloud services, desktop software, and games

03

xUnit, NUnit, and MSTest integration paths

Adoption snapshot

Public adoption, in context.

NuGet reports 82 downloads for the current ArchUnit alpha package. NuGet does not expose a directly comparable rolling 30-day total.

Package status
Published on NuGet
Public download totals
Reported history
82
All versions through Oct 4, 2026
Latest 30 days
Unavailable
No comparable 30-day figure
GitHub stars
2
Snapshot of October 4, 2026

Capabilities

What ArchUnit.NET brings to the test suite.

The family shares a recognizable architecture vocabulary while each implementation stays honest about its language, toolchain, and maturity.

01

Cycles, boundaries, naming, and placement rules

02

xUnit, NUnit, and MSTest adapters

03

Architecture presets and gradual-adoption baselines

04

SARIF, JSON, text, and HTML reports

05

Structured violations for custom assertions

06

Async and framework-neutral execution

Go deeper

Adopt boundaries without stopping delivery.

Baselines let an established solution record existing violations and fail only when new ones appear. Teams can then remove old debt deliberately while protecting every improvement.

CycleRules.cs
var rule = ArchUnit.ProjectFiles("./Commerce.sln")
    .InPath("src/**")
    .Should()
    .HaveNoCycles();

var result = await rule.CheckAsync();

Assert.True(result.Passed, result.Format());

Documentation highlights

Work with ArchUnit.NET beyond the quickstart.

ArchUnit.NET uses Roslyn to read C# projects and keeps extraction, projection, assertion, and reporting separate. The current alpha is designed for realistic adoption through familiar .NET test runners and structured output.

01

Read the solution through Roslyn

C# syntax trees and project information become normalized dependency edges before any rule is evaluated.

  • Project and solution entry points support file, naming, cycle, and dependency-direction checks.
  • The same extracted graph is projected into files, layers, slices, and metrics rather than reparsed for every rule family.
  • Package installation uses ArchUnit, while the C# namespaces remain under ArchUnitNet.
02

Adopt rules without hiding legacy debt

Violation baselines allow an established solution to record existing findings while failing on newly introduced architectural drift.

  • Architecture presets provide a faster starting point for recurring solution shapes.
  • xUnit, NUnit, and MSTest adapters sit above the same generic CheckAsync result.
  • Structured violations make it possible to write organization-specific assertions without parsing console text.
03

Bring findings into delivery

Text and HTML reports serve people, JSON serves automation, and SARIF can place architecture findings beside other code-scanning results.

  • dotnet test remains the ordinary execution path in local development and CI.
  • Performance profiling helps teams understand extraction cost on larger solutions.
  • The alpha status is explicit: APIs may change while extraction and the full test matrix are hardened.
Read the complete documentation ↗

Release and compatibility

2.4.0-alpha.2

An evaluation-only alpha under active development. APIs and behavior can still change before a stable release.

Language.NET
Release2.4.0-alpha.2
RuntimeC# & .NET
LicenseApache-2.0

Where it fits

Put boundaries next to the code they protect.

Common starting points for ArchUnit.NET include the following project shapes.

ASP.NET servicesModular monolithsClean architectureLegacy modernization

Make the first boundary executable.

Add one meaningful rule, run it with the existing tests, and grow the architecture suite as the system reveals where it needs protection.

Start with ArchUnit.NET ↗