Skip to main content
ANcpLua.Analyzers enforces code quality and prevents common bugs. Included automatically with ANcpLua.NET.Sdk.

Categories

CategoryRulesExamples
Design4Primary constructor patterns, type partialness
Usage17Span comparisons, IXmlSerializable, static lambdas, Roslyn utils
Style3Pattern matching, null-guard normalization
ASP.NET Core5Form binding, parameter validation
OpenTelemetry2Semantic conventions, schema URLs
Threading1Lock statement best practices
Reliability3Division by zero, trim/AOT safety
VersionManagement2Hardcoded version, Version.props import
AOT/Trim Safety4AotTest return codes, TrimSafe/AotSafe violations

Rules

IdCategoryDescriptionSeverityFix
AL0001DesignProhibit reassignment of primary constructor parametersError-
AL0002DesignDon’t repeat negated patternsWarningYes
AL0003ReliabilityDon’t divide by constant zeroError-
AL0004UsageUse pattern matching for Span constantsWarningYes
AL0005UsageUse SequenceEqual for Span non-constantsWarningYes
AL0006DesignField name conflicts with primary constructorWarning-
AL0007UsageGetSchema should be explicitly implementedError-
AL0008UsageGetSchema must return nullErrorYes
AL0009UsageDon’t call IXmlSerializable.GetSchemaError-
AL0010DesignType should be partialInfoYes
AL0011ThreadingAvoid lock on non-Lock typesWarningYes
AL0012OpenTelemetryDeprecated semantic conventionWarningYes
AL0013OpenTelemetryMissing telemetry schema URLInfo-
AL0014StylePrefer pattern matching for null/zeroWarningYes
AL0015StyleNormalize null-guard styleInfoYes
AL0016StyleCombine declaration with null-checkInfoYes
AL0017VersionManagementHardcoded package versionWarning-
AL0018VersionManagementVersion.props not importedWarning-
AL0020ASP.NET CoreIFormCollection requires explicit attributeError-
AL0021ASP.NET CoreMultiple structured form sourcesError-
AL0022ASP.NET CoreMixed form collection and DTOError-
AL0023ASP.NET CoreUnsupported form typeError-
AL0024ASP.NET CoreForm and body conflictError-
AL0025UsageAnonymous function can be staticWarningYes
AL0026UsageAvoid DateTime.Now/UtcNow, use TimeProviderWarning-
AL0027UsageAvoid Newtonsoft.Json, use System.Text.JsonWarning-
AL0028UsageUse IsEqualTo() for symbol comparisonInfo-
AL0029UsageUse HasAttribute() for attribute checksInfo-
AL0030UsageUse type hierarchy extensionsInfo-
AL0031UsageUse operation extensionsInfo-
AL0032UsageUse OrEmpty() extensionInfo-
AL0033UsageUse ToImmutableArrayOrEmpty() extensionInfo-
AL0034UsageUse WhereNotNull() extensionInfo-
AL0035UsageUse GetFullyQualifiedName/GetMetadataName()Info-
AL0036UsageUse Guard.NotNull() extensionWarning-
AL0037UsageUse TryParse extensionsWarning-
AL0038UsageUse GetOrNull/GetOrDefault extensionsWarning-
AL0039UsageUse StringComparison extensionsWarning-
AL0040UsageUse attribute argument extensionsWarning-
AL0041AOT/Trim[AotTest]/[TrimTest] must return intError-
AL0042AOT/Trim[AotTest]/[TrimTest] should return 100Warning-
AL0043Reliability[TrimSafe] violates trim safetyWarning-
AL0044Reliability[AotSafe] violates AOT safetyWarning-

Refactorings

IdDescription
AR0001Snake case to Pascal case
AR0002Make static lambda

Configuration

Configure via .editorconfig. See Configuration.
[*.cs]
dotnet_diagnostic.AL0014.severity = warning
dotnet_diagnostic.AL0010.severity = none