AL0006: Field name conflicts with primary constructor parameter
Field names should not conflict with primary constructor parameters to avoid shadowing and confusion.
When it triggers
public class Example(int value)
{
private int value; // AL0006: Field 'value' conflicts with primary constructor parameter
}
Why this matters
When a field has the same name as a primary constructor parameter, it shadows the parameter. This leads to confusion about which value is being referenced in different contexts and can cause subtle bugs.
How to fix
Rename the field to avoid conflict:
public class Example(int value)
{
private int _value = value; // Clear naming, no conflict
}
Configuration
[*.cs]
dotnet_diagnostic.AL0006.severity = warning