Analyzer Rules
ANcpLua.Analyzers provides 17 diagnostic rules for C# code quality.
Rule Categories
| Rule | Severity | Description |
|---|---|---|
| AL0001 | Error | Prohibit reassignment of primary constructor params |
| AL0002 | Warning | Don't repeat negated patterns |
| AL0003 | Error | Don't divide by constant zero |
| AL0004 | Warning | Use pattern matching for Span constant comparison |
| AL0005 | Warning | Use SequenceEqual for Span non-constant comparison |
| AL0006 | Warning | Field name conflicts with primary constructor parameter |
| AL0007 | Warning | GetSchema should be explicitly implemented |
| AL0008 | Warning | GetSchema must return null and not be abstract |
| AL0009 | Warning | Don't call IXmlSerializable.GetSchema |
| AL0010 | Info | Type should be partial for source generator support |
| AL0011 | Warning | Avoid lock keyword on non-Lock types (.NET 9+) |
| AL0012 | Warning | Deprecated OTel semantic convention attribute |
| AL0013 | Info | Missing telemetry schema URL |
| AL0014 | Info | Prefer pattern matching for null/zero comparisons |
| AL0015 | Info | Normalize null-guard style |
| AL0016 | Info | Combine declaration with subsequent null-check |
| AL0017 | Warning | Hardcoded package version in Directory.Packages.props |
Configuration
All rules can be configured via .editorconfig:
[*.cs]
# Disable a rule
dotnet_diagnostic.AL0001.severity = none
# Change severity
dotnet_diagnostic.AL0014.severity = warning