Skip to main content

check_architecture

Check user-supplied layering rules against the solution's real semantic type graph (resolved symbols, not using directives — so a fully qualified reference with no using is still caught, and an unused using is not reported). Rule kinds: forbid (a dependency from from to to is a violation) and allowOnly (a dependency from from to anything outside to is a violation). TWO SEMANTICS YOU MUST KNOW TO READ AN EMPTY RESULT CORRECTLY. (1) allowOnly evaluates ONLY solution-internal, non-generated targets: references to framework and NuGet namespaces such as System.Collections.Generic are ignored (otherwise every file would violate every allowOnly rule), and so are types declared entirely in generated code, which the caller cannot remove. To restrict a framework or generated namespace, write an explicit forbid — that path DOES evaluate metadata and generated targets. (2) Self-references are always allowed: a scope depending on itself is never a violation, under either kind. Results are grouped per violated rule plus sourceScope plus targetScope edge, each with a full referenceCount and the first maxSitesPerViolation sites. Sorted by rule order, then by descending reference count. Generated code is never reported as the SOURCE of a violation under either kind. Envelope adds a byRule / totalReferences / rulesEvaluated summary.

Parameters

ParameterTypeRequiredDescription
rulesArchitectureRuleInput[]Layering rules to evaluate, in priority order. Each is kind (forbid or allowOnly), from, to (array of patterns), and an optional description.
scopestringScope compared by the rules: namespace (default) or project.
maxSitesPerViolationintMaximum example sites recorded per violated edge (default: 5). The full reference count is reported regardless.
limitint?Maximum number of items to return (default: 100). Items are sorted by rule order, then by descending reference count.