Constructor argument name differs from property or field being assigned to
RH1004 Warning
Cause
Constructor argument name differs from the name of the field or property the argument is being assigned to. The name comparison is case insensitive.
Reason for rule
Having the argument name differ from the assignment target can yield to problems with (de)serialization, requiring supplemental metadata (e.g. JsonPropertyAttribute in Json.NET) or otherwise customized deserialization schemes.
How to fix violations
Name the arguments the same as their assignment target.
Examples
Violates
class MyClass
{
public string StringProp { get; }
public MyClass(string stringArg)
{
StringProp = stringArg;
}
}
Does not violate
class MyClass
{
public string StringProp { get; }
public MyClass(string stringProp)
{
StringProp = stringProp;
}
}