Getting Started
This guide explains how to build, test, pack, and validate ComplexityAnalysis.Analyzers from the current repository layout.
Prerequisites
Section titled “Prerequisites”- .NET SDK
10.0.401, or a compatible SDK selected by the rootglobal.json. - Git.
- A shell capable of running
dotnetcommands.
The analyzer project targets netstandard2.0 because Roslyn analyzers are loaded by compiler and IDE hosts rather than by the runtime target of the application being analyzed. The repository tests and tooling use the SDK selected by global.json.
The repository build SDK is not the minimum consumer host version. Build and test tooling currently use SDK 10.0.401; package compatibility is validated separately by installing the generated .nupkg into consumer projects built by supported SDK hosts.
Clone and build
Section titled “Clone and build”From the repository root:
dotnet restore ComplexityAnalysis.Analyzers.slnxdotnet build ComplexityAnalysis.Analyzers.slnx --configuration Release --no-restoredotnet test ComplexityAnalysis.Analyzers.slnx --configuration Release --no-buildThe analyzer is the product represented by the repository root. Production code lives under src/, tests under tests/, performance validation under performance/, and documentation under docs/.
Run The Project-Level CLI
Section titled “Run The Project-Level CLI”The repository also builds ComplexityAnalysis.Tool, a separately versioned
.NET 10 tool for aggregate reports and CI-oriented gates. After 1.0.0 is
published, install the consumer package globally or in a local manifest:
dotnet tool install --global ComplexityAnalysis.Tool --version 1.0.0complexity-analysis analyze MySolution.slnx
dotnet new tool-manifestdotnet tool install ComplexityAnalysis.Tool --version 1.0.0dotnet tool restoredotnet tool run complexity-analysis analyze MyProject.csproj --format jsonFor source development, use dotnet run --project src/ComplexityAnalysis.Tool -- analyze <path>. A locally packed tool must be
installed with an explicit --add-source and local-only version; it is not a
published release.
The tool supports .csproj, .slnx, and .sln inputs. See
Project-Level Tooling for JSON, console output, quality
gates, exclusions, duplicate detection, exit codes, and normalization rules.
Create a local package
Section titled “Create a local package”Build first, then create a local NuGet package:
dotnet build ComplexityAnalysis.Analyzers.slnx --configuration Releasedotnet pack src/ComplexityAnalysis.Analyzers/ComplexityAnalysis.Analyzers.csproj \ --configuration Release \ --no-build \ -p:PackageVersion=0.0.0-local \ --output artifacts/local-packagesThe generated package is a Roslyn analyzer package. ComplexityAnalysis.Analyzers.dll is packed under:
analyzers/dotnet/cs/It is intentionally not packed as a normal runtime library under lib/. Roslyn authoring dependencies are private assets and are not intended to become transitive dependencies of consuming projects.
The project uses README.md as the package readme and declares the repository URL, repository type, and MIT package license metadata.
The package contract also expects no .deps.json, no duplicate analyzer DLL, no runtime lib/ asset for the analyzer assembly, and no transitive Roslyn dependency group in the generated .nuspec.
Consume the local package
Section titled “Consume the local package”The repository documents local package creation and consumption. Do not treat this guide as evidence that a version has been published to NuGet.org.
One PowerShell workflow is:
dotnet build ComplexityAnalysis.Analyzers.slnx --configuration Releasedotnet pack src/ComplexityAnalysis.Analyzers/ComplexityAnalysis.Analyzers.csproj ` --configuration Release ` --no-build ` -p:PackageVersion=0.0.0-local ` --output artifacts/local-packages
$packageSource = (Resolve-Path "artifacts/local-packages").Path$consumer = Join-Path ([System.IO.Path]::GetTempPath()) ("AnalyzerConsumer-" + [System.Guid]::NewGuid().ToString("N"))
dotnet new console -o $consumerSet-Location $consumerdotnet new nugetconfigdotnet nuget add source $packageSource --name complexity-analysis-local --configfile NuGet.configdotnet add package ComplexityAnalysis.Analyzers --version 0.0.0-local --source $packageSourceIf needed, point the local NuGet source directly at the directory containing the generated .nupkg.
PackageReference
Section titled “PackageReference”Analyzer packages are normally referenced with PrivateAssets="all" so they participate in compilation without becoming a transitive runtime dependency:
<PackageReference Include="ComplexityAnalysis.Analyzers" Version="<local-or-published-version>" PrivateAssets="all" />Consumer application code does not call analyzer types at runtime.
Verify the analyzer is running
Section titled “Verify the analyzer is running”BIG9000 is an opt-in infrastructure probe. Enable it temporarily when you need to prove that the package loaded and the analyzer executed:
[*.cs]
dotnet_diagnostic.BIG9000.severity = warningDisable it again after the smoke test:
[*.cs]
dotnet_diagnostic.BIG9000.severity = noneTry the diagnostics
Section titled “Try the diagnostics”BIG1001 through BIG1005 are enabled by default with Info severity. BIG1006 and BIG2001 through BIG2007 are also enabled as descriptors, but they only report after concrete thresholds are configured. Build visibility for informational diagnostics depends on the consuming project and SDK settings.
Promote an actionable diagnostic locally:
[*.cs]
dotnet_diagnostic.BIG1001.severity = warningPromote the source-call-in-loop diagnostic:
[*.cs]
dotnet_diagnostic.BIG1004.severity = warningPromote exponential recursion:
[*.cs]
dotnet_diagnostic.BIG1005.severity = warningConfigure a maximum-complexity threshold:
[*.cs]
complexity_analyzers.maximum_complexity = n_log_ndotnet_diagnostic.BIG1006.severity = warningPromote the Cyclomatic Complexity threshold diagnostic:
[*.cs]
complexity_analyzers.maximum_cyclomatic_complexity = 10complexity_analyzers.cyclomatic_complexity_mode = standarddotnet_diagnostic.BIG2001.severity = warningPromote the Maximum Control-Flow Nesting Depth threshold diagnostic:
[*.cs]
complexity_analyzers.maximum_nesting_depth = 3dotnet_diagnostic.BIG2002.severity = warningPromote method-size threshold diagnostics:
[*.cs]
complexity_analyzers.maximum_method_nloc = 40complexity_analyzers.maximum_statement_count = 25complexity_analyzers.maximum_token_count = 300complexity_analyzers.maximum_parameters = 5dotnet_diagnostic.BIG2003.severity = warningdotnet_diagnostic.BIG2004.severity = warningdotnet_diagnostic.BIG2005.severity = warningdotnet_diagnostic.BIG2006.severity = warningPromote the Cognitive Complexity threshold diagnostic:
[*.cs]
complexity_analyzers.maximum_cognitive_complexity = 15dotnet_diagnostic.BIG2007.severity = warningBIG0001 is disabled by default. Enable it when you want method-level complexity estimates:
[*.cs]
dotnet_diagnostic.BIG0001.severity = suggestionSee Configuration and the Analyzer Catalog for the complete behavior of each option and rule.
Compatibility matrix
Section titled “Compatibility matrix”CI validates local package consumption on the supported SDK hosts:
| SDK host | Consumer target framework |
|---|---|
| .NET 8 LTS | net8.0 |
| .NET 9 STS | net9.0 |
| .NET 10 LTS | net10.0 |
The analyzer assembly itself targets netstandard2.0. The compatibility matrix verifies that compiler hosts can load and execute the analyzer package, not merely that the consumer project can target a given framework.
The analyzer is compiled against Microsoft.CodeAnalysis.CSharp 4.8.0, which resolves Microsoft.CodeAnalysis.Common 4.8.0. This is a conservative Roslyn host baseline: dependency upgrades require package inspection and successful consumer execution across the supported host matrix before merge. Microsoft.CodeAnalysis.Workspaces is intentionally absent because the package does not provide code fixes or workspace-based IDE features.
Performance validation
Section titled “Performance validation”Run the structural performance harness from the repository root:
dotnet test ComplexityAnalysis.Analyzers.slnx \ --configuration Release \ --no-build \ --filter PerformanceSyntheticCorpusTestsAfter restore, request the compiler analyzer execution report:
dotnet build performance/ComplexityAnalysis.Analyzers.Performance/ComplexityAnalysis.Analyzers.Performance.csproj \ --configuration Release \ --no-restore \ -t:Rebuild \ -p:ReportAnalyzer=true \ -p:UseSharedCompilation=false \ -v:detailedTiming varies by hardware and CI runner. The repeatable validation is that the synthetic workload completes, structural invariants hold, and the compiler report contains ComplexityAnalysis.Analyzers.ComplexityAnalyzer.
Next steps
Section titled “Next steps”- Read the Analyzer Catalog to understand each diagnostic.
- Read Configuration to tune analysis budgets and severities.
- Read Architecture for the analyzer pipeline and design boundaries.