Architecture as executable policy

ArchitectureAnalyzer

A project-agnostic Roslyn analyzer for C# that reads a JSON Architecture Contract from your repository and turns architecture rules into compiler diagnostics.

Declare layers, forbidden dependency directions, forbidden APIs, optional layer attributes, and interop boundaries. Normal IDE analysis, dotnet build, and CI then check the code against that contract.

Get it on NuGet View on GitHub

What it enforces

Layer dependencies

Prevent inner layers from depending on forbidden outer layers or other disallowed architecture edges.

Forbidden APIs

Keep I/O, framework calls, or other APIs out of layers where your architecture contract forbids them.

Layer declarations

Optionally require configured architecture attributes and detect missing, conflicting, or namespace-mismatched declarations.

Interop boundaries

Restrict configured interop declarations to the layers where native or external boundaries are intended to live.

Why ArchitectureAnalyzer?

Architecture documents and ADRs record intent, but they do not enforce it. ArchitectureAnalyzer makes selected structural rules executable so architecture drift can surface during development instead of depending entirely on manual review.

Project-agnostic by design

The analyzer contains no application-specific layer names, namespace roots, dependency graph, or API policy. Those rules live in the consuming repository's architecture.contract.json.