Skip to content

Repository files navigation

NuGet ANcpLua.AnalyzersNuGet ANcpLua.NET.SdkNuGet ANcpLua.Roslyn.UtilitiesNuGet ANcpLua.Agents.NETLicense: MIT

ANcpLua.Analyzers

Roslyn diagnostic analyzers and code fixes for modern C# correctness, async and threading reliability, AOT and trim safety, ASP.NET Core / Aspire hosting, Roslyn-author hygiene, package/version management, agent-tool governance, and the ANcpLua Roslyn-utilities helper API — 90 rules across 9 domain bands.

Targets: netstandard2.0 (Roslyn host requirement)

Family

PackageContents
ANcpLua.AnalyzersRoslyn diagnostic analyzers + code fixes (this package)
ANcpLua.NET.SdkMSBuild SDK that auto-injects this analyzer package and shared .editorconfig defaults
ANcpLua.Roslyn.UtilitiesShared Roslyn helpers, extensions, and Guard.* API the AL12xx band promotes
ANcpLua.AgentsMicrosoft Agent Framework consumer toolkit; the AL18xx agent-governance band targets its [LoomTool] attributes

Domain bands

RangeDomainRules
AL1000..1099Correctness / language pitfalls13
AL1100..1199ASP.NET Core / Aspire / web hosting10
AL1200..1299Roslyn Utilities helper API surface21
AL1300..1399Async / threading / reliability15
AL1400..1499AOT / trim safety10
AL1500..1599Roslyn-author hygiene7
AL1600..1699Package / version management / doc alignment7
AL1700..1799Style4
AL1800..1899Agent / tool governance (Loom)3

AL0xxx is reserved for sibling packages in the ANcpLua family that ship their own AL-prefixed analyzers. AL1900..AL9999 is reserved for future bands.

Rules

Correctness / language pitfalls (AL1000..1012)

IDSeverityTitle
AL1000ErrorProhibit reassignment of primary constructor parameters
AL1001WarningDon't repeat negated patterns
AL1002ErrorDon't divide by constant zero
AL1003WarningUse pattern matching when comparing Span with constants
AL1004WarningUse SequenceEqual when comparing Span with non-constants
AL1005WarningField name conflicts with primary constructor parameter
AL1006ErrorGetSchema should be explicitly implemented
AL1007ErrorGetSchema must return null and not be abstract
AL1008ErrorDon't call IXmlSerializable.GetSchema
AL1009WarningAvoid lock keyword on non-Lock types
AL1010WarningPrefer pattern matching for null and zero comparisons
AL1011InfoNormalize null-guard style
AL1012InfoCombine declaration with subsequent null-check

ASP.NET Core / Aspire (AL1100..1109)

IDSeverityTitle
AL1100ErrorIFormCollection requires explicit attribute
AL1101ErrorMultiple structured form sources
AL1102ErrorMixed form collection and DTO
AL1103ErrorUnsupported form type
AL1104ErrorForm and body conflict
AL1105WarningMissing resilience configuration
AL1106WarningMissing health checks
AL1107InfoConsider using configuration for connection string
AL1108WarningMissing service discovery
AL1109WarningAvoid Task.Run in ASP.NET Core request handlers

Roslyn Utilities helper API (AL1200..1220)

IDSeverityTitle
AL1200InfoUse IsEqualTo extension
AL1201InfoUse HasAttribute extension
AL1202InfoUse type hierarchy extension
AL1203InfoUse operation extension
AL1204InfoUse OrEmpty extension
AL1205InfoUse ToImmutableArrayOrEmpty extension
AL1206InfoUse WhereNotNull extension
AL1207InfoUse symbol display string extension
AL1208WarningUse null-guard helper
AL1209WarningUse TryParse extension
AL1210WarningUse StringComparison extension
AL1211WarningUse attribute argument extraction extension
AL1212WarningUse null-or-empty guard helper
AL1213WarningUse null-or-whitespace guard helper
AL1214WarningUse zero-guard helper
AL1215WarningUse non-negative guard helper
AL1216WarningUse positive-guard helper
AL1217WarningUse empty-guid guard helper
AL1218WarningUse defined-enum guard helper
AL1219InfoUse Any string comparison extension
AL1220WarningUse Guard.* helpers instead of throw helpers

Async / threading / reliability (AL1300..1314)

IDSeverityTitle
AL1300WarningAvoid async void methods
AL1301WarningAvoid lock on 'this'
AL1302WarningAvoid lock on typeof(T)
AL1303WarningAvoid lock on string
AL1304WarningPrefer 'await using' for IAsyncDisposable
AL1305WarningAvoid blocking calls in async methods
AL1306WarningAvoid SQL string interpolation in CommandText
AL1307WarningAvoid fire-and-forget task discard
AL1308WarningPrefer TryParse over Parse
AL1309WarningEmpty catch block swallows exceptions
AL1310WarningException details leaked in HTTP response
AL1311WarningUnnecessary LINQ materialization
AL1312WarningRead-modify-write without transaction
AL1313InfoForward CancellationToken to invocations that support it
AL1314WarningUse Math.Round/MathF.Round overload with explicit MidpointRounding

AOT / trim safety (AL1400..1409)

IDSeverityTitle
AL1400ErrorMethod with [AotTest] or [TrimTest] must return int
AL1401Warning[AotTest]/[TrimTest] method should return 100 on success
AL1402Warning[TrimSafe] code must not call methods with [RequiresUnreferencedCode]
AL1403Warning[AotSafe] code must not call methods with [RequiresDynamicCode]
AL1404Error[AotSafe] code must not call [AotUnsafe] code
AL1405WarningUnnecessary [AotUnsafe] attribute
AL1406WarningAvoid 'dynamic' keyword in AOT-published code
AL1407WarningAvoid Expression.Compile() in AOT context
AL1408WarningActivator.CreateInstance is not AOT-safe
AL1409WarningType.GetType with dynamic name is not AOT-safe

Roslyn-author hygiene (AL1500..1506)

IDSeverityTitle
AL1500WarningClosed hierarchy match is not exhaustive
AL1501WarningAvoid storing ISymbol in source generator models
AL1502WarningUse IIncrementalGenerator instead of ISourceGenerator
AL1503WarningAvoid NormalizeWhitespace in source generators
AL1504Error[DuckDbTable] type must be partial
AL1505WarningConflicting [DuckDbColumn] ordinal values
AL1506WarningExcluded code hides untested branches

Package / version management (AL1600..1606)

IDSeverityTitle
AL1600WarningHardcoded package version detected
AL1601WarningVersion.props not imported
AL1602WarningUndefined version variable
AL1603WarningDiagnostic missing from documentation
AL1604WarningDiagnostic missing from release notes
AL1605WarningDiagnostic documentation mismatch
AL1606WarningOutdated MAF ecosystem package version

Style (AL1700..1703)

IDSeverityTitle
AL1700WarningAnonymous function can be made static
AL1701WarningAvoid DateTime/DateTimeOffset time accessors
AL1702WarningAvoid legacy JSON library
AL1703WarningUse implicit type when type is apparent

Agent / tool governance (AL1800..1802)

IDSeverityTitle
AL1800WarningDestructive Loom tool must require approval
AL1801InfoLoom tool should declare its side effect
AL1802InfoLoom tool should declare required capabilities

Usage

<PackageReferenceInclude="ANcpLua.Analyzers"Version="2.1.0"PrivateAssets="all"IncludeAssets="analyzers; buildtransitive" />

IncludeAssets="analyzers; buildtransitive" is what makes <AlAnalysisMode> and the bundled editorconfig profiles flow through. Consumers of ANcpLua.NET.Sdk get the analyzer auto-injected and don't need this <PackageReference>.

Consumer-side severity profile (<AlAnalysisMode>)

Switch the whole AL00xxAL18xx band in one csproj line instead of dropping editorconfig files:

<PropertyGroup>
<AlAnalysisMode>AllAsErrors</AlAnalysisMode>
</PropertyGroup>
ValueBehavior
DefaultEvery rule at its descriptor-declared default severity. Useful to override an ambient stricter config (incl. ANcpLua.NET.Sdk's bundled profile).
AllAsErrorsEvery AL rule promoted to error. Use for strict CI.
DisabledEvery AL rule silenced.
(unset)No editorconfig injection. Inside an ANcpLua.NET.Sdk consumer the SDK's bundled editorconfig still applies; outside it, descriptor severities apply.

The knob is exposed via buildTransitive/ANcpLua.Analyzers.props in the NuGet, which appends the matching profile from buildTransitive/editorconfig/ to $(EditorConfigFiles) on restore. The name is intentionally not bare <AnalysisMode> — that's owned by Microsoft.CodeAnalysis.NetAnalyzers.

Documentation

  • docs/ANcpLua.Analyzers.md — slim index with the full catalog, configuration knob, and cross-cutting policy.
  • docs/rules/ — one markdown file per rule (ALXXXX_<SymbolicName>.md) with severity, category, code-fix status, description, and source link. Every descriptor's HelpLinkUri resolves to a per-rule page, so IDE Quick-Fix "Show error help" lands on the focused rule, not on a multi-thousand-line aggregate.
  • docs/ANcpLua.Analyzers.sarif — SARIF v2.1.0 rule manifest for tool interop (Sonar bridges, GitHub Advanced Security uploads, IDE rule-catalog importers).
  • docs/editorconfig/ — three drop-in severity profiles: Default, AllRulesAsErrors, AllRulesDisabled. Same content ships inside the NuGet under buildTransitive/editorconfig/ so <AlAnalysisMode> can pick them up.

Siblings: ANcpLua.Roslyn.Utilities · ANcpLua.NET.Sdk · ANcpLua.Agents · Qyl.Opentelemetry.SemanticConventions

About

Roslyn analyzers enforcing code quality, AOT safety, and best practices for C#. Auto-injected via ANcpLua.NET.Sdk.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages