ANcpLua.Analyzers
1.4.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ANcpLua.Analyzers --version 1.4.0
NuGet\Install-Package ANcpLua.Analyzers -Version 1.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ANcpLua.Analyzers" Version="1.4.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ANcpLua.Analyzers" Version="1.4.0" />
<PackageReference Include="ANcpLua.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ANcpLua.Analyzers --version 1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ANcpLua.Analyzers, 1.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ANcpLua.Analyzers@1.4.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ANcpLua.Analyzers&version=1.4.0
#tool nuget:?package=ANcpLua.Analyzers&version=1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ANcpLua.Analyzers
Roslyn analyzers for C# code quality, focusing on modern .NET patterns and best practices. Catches common mistakes at compile time with actionable diagnostics and automatic code fixes.
Installation
dotnet add package ANcpLua.Analyzers
Or add to your project file:
<PackageReference Include="ANcpLua.Analyzers" Version="1.4.0" PrivateAssets="all" />
Rules
| Rule | Category | Description | Severity | Enabled | Code Fix |
|---|---|---|---|---|---|
| AL0001 | Design | Prohibit reassignment of primary constructor parameters | ❌ | ✔️ | |
| AL0002 | Design | Don't repeat negated patterns | ⚠️ | ✔️ | |
| AL0003 | Reliability | Don't divide by constant zero | ❌ | ✔️ | |
| AL0004 | Usage | Use pattern matching for Span constant comparison | ⚠️ | ✔️ | ✔️ |
| AL0005 | Usage | Use SequenceEqual for Span non-constant comparison | ⚠️ | ✔️ | ✔️ |
| AL0006 | Design | Field name conflicts with primary constructor parameter | ⚠️ | ✔️ | |
| AL0007 | Usage | GetSchema should be explicitly implemented | ⚠️ | ✔️ | |
| AL0008 | Usage | GetSchema must return null and not be abstract | ⚠️ | ✔️ | |
| AL0009 | Usage | Don't call IXmlSerializable.GetSchema | ⚠️ | ✔️ | |
| AL0010 | Design | Type should be partial for source generator support | ℹ️ | ✔️ | |
| AL0011 | Threading | Avoid lock keyword on non-Lock types | ⚠️ | ✔️ | |
| AL0012 | OpenTelemetry | Deprecated semantic convention attribute | ⚠️ | ✔️ | |
| AL0013 | OpenTelemetry | Missing telemetry schema URL | ℹ️ | ✔️ | |
| AL0014 | Style | Prefer pattern matching for null and zero comparisons | ℹ️ | ✔️ | ✔️ |
| AL0015 | Style | Normalize null-guard style | ℹ️ | ✔️ | ✔️ |
| AL0016 | Style | Combine declaration with subsequent null-check | ℹ️ | ✔️ | ✔️ |
| AL0017 | VersionManagement | Hardcoded package version in Directory.Packages.props | ⚠️ | ✔️ |
Legend: ❌ Error · ⚠️ Warning · ℹ️ Info
Configuration
Configure rule severity in your .editorconfig:
[*.cs]
# AL0001: Prohibit reassignment of primary constructor parameters
dotnet_diagnostic.AL0001.severity = error
# AL0002: Don't repeat negated patterns
dotnet_diagnostic.AL0002.severity = warning
# AL0003: Don't divide by constant zero
dotnet_diagnostic.AL0003.severity = error
# AL0004: Use pattern matching for Span constant comparison
dotnet_diagnostic.AL0004.severity = warning
# AL0005: Use SequenceEqual for Span non-constant comparison
dotnet_diagnostic.AL0005.severity = warning
# AL0006: Field name conflicts with primary constructor parameter
dotnet_diagnostic.AL0006.severity = warning
# AL0007: GetSchema should be explicitly implemented
dotnet_diagnostic.AL0007.severity = warning
# AL0008: GetSchema must return null and not be abstract
dotnet_diagnostic.AL0008.severity = warning
# AL0009: Don't call IXmlSerializable.GetSchema
dotnet_diagnostic.AL0009.severity = warning
# AL0010: Type should be partial for source generator support
dotnet_diagnostic.AL0010.severity = none
# AL0011: Avoid lock keyword on non-Lock types
dotnet_diagnostic.AL0011.severity = warning
# AL0012: Deprecated semantic convention attribute
dotnet_diagnostic.AL0012.severity = warning
# AL0013: Missing telemetry schema URL
dotnet_diagnostic.AL0013.severity = suggestion
# AL0014: Prefer pattern matching for null and zero comparisons
dotnet_diagnostic.AL0014.severity = suggestion
# AL0015: Normalize null-guard style
dotnet_diagnostic.AL0015.severity = suggestion
# AL0016: Combine declaration with subsequent null-check
dotnet_diagnostic.AL0016.severity = suggestion
# AL0017: Hardcoded package version
dotnet_diagnostic.AL0017.severity = warning
Examples
AL0001: Primary Constructor Parameter Reassignment
// Error: Primary constructor parameter 'x' should not be reassigned
public class Example(int x)
{
public void SetX(int value) => x = value; // AL0001
}
// Fix: Use a separate field
public class Example(int x)
{
private int _x = x;
public void SetX(int value) => _x = value;
}
AL0014: Pattern Matching for Null Checks
// Before: AL0014 triggered
if (x == null) { }
if (x != null) { }
// After: Use pattern matching
if (x is null) { }
if (x is not null) { }
Documentation
See the docs folder for detailed documentation on each rule, including examples and fix guidance.
Related Projects
- ANcpLua.NET.Sdk - MSBuild SDK that includes this analyzer
- ANcpLua.Roslyn.Utilities - Roslyn utilities used by these analyzers
License
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.8.0 | 0 | 1/21/2026 |
| 1.7.0 | 0 | 1/21/2026 |
| 1.6.16 | 0 | 1/21/2026 |
| 1.6.15 | 28 | 1/20/2026 |
| 1.6.13 | 120 | 1/18/2026 |
| 1.6.12 | 51 | 1/18/2026 |
| 1.6.11 | 59 | 1/18/2026 |
| 1.6.10 | 54 | 1/17/2026 |
| 1.6.7 | 49 | 1/16/2026 |
| 1.6.6 | 122 | 1/14/2026 |
| 1.6.5 | 95 | 1/14/2026 |
| 1.6.4 | 85 | 1/14/2026 |
| 1.6.3 | 86 | 1/14/2026 |
| 1.6.2 | 87 | 1/14/2026 |
| 1.6.1 | 359 | 1/14/2026 |
| 1.6.0 | 102 | 1/13/2026 |
| 1.5.3 | 123 | 1/10/2026 |
| 1.5.2 | 82 | 1/10/2026 |
| 1.5.1 | 274 | 1/2/2026 |
| 1.5.0 | 85 | 1/2/2026 |
| 1.4.0 | 88 | 1/1/2026 |
| 1.3.6 | 87 | 1/2/2026 |
| 1.3.5 | 84 | 1/2/2026 |
| 1.3.3 | 92 | 12/31/2025 |
| 1.3.2 | 87 | 12/31/2025 |
| 1.3.1 | 89 | 12/30/2025 |
| 1.0.10 | 94 | 12/30/2025 |
| 1.0.9 | 93 | 12/29/2025 |
| 1.0.4 | 854 | 12/24/2025 |
| 1.0.3 | 162 | 12/24/2025 |
| 1.0.2 | 163 | 12/24/2025 |