Description
Primary constructor parameters should not be reassigned as this can lead to confusion and bugs.Bad Code
Good Code
Properties
- Category: Design
- Severity: Error
- Enabled by default: True
- Code fix available: False
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Primary constructor parameters should not be reassigned
public class Service(ILogger logger)
{
public void Reset() => logger = null;
}
public class Service(ILogger logger)
{
private readonly ILogger _logger = logger;
}
dotnet_diagnostic.AL0001.severity = warning
Was this page helpful?
