Open Hosch250 opened 7 years ago
Did VSD explicitly account for this in the code? Regardless: I think _camelCase
is probably best.
R# is configurable.
I'm using the default R# configuration.
Here is VSD's code:
if (modifiers.Any(SyntaxKind.InternalKeyword) ||
modifiers.Any(SyntaxKind.ProtectedKeyword) ||
modifiers.Any(SyntaxKind.PublicKeyword))
{
CheckNaming(variable.Identifier, "field", NamingConvention.UpperCamelCase, context);
}
else if (modifiers.Any(SyntaxKind.PrivateKeyword) ||
nodeAsField.Modifiers.Count == 0 /* no access modifier defaults to private */)
{
if (modifiers.Any(SyntaxKind.StaticKeyword) || modifiers.Any(SyntaxKind.ConstKeyword))
{
CheckNaming(variable.Identifier, "field", NamingConvention.UpperCamelCase, context);
}
else
{
CheckNaming(variable.Identifier, "field", NamingConvention.UnderscoreLowerCamelCase, context);
}
}
StyleCop does not agree with underscore prefixes. An alternative can be to try to detect the convention used in the document/project.
R# says to use
_camelCase
naming for private static fields. VSD says to usePascalCase
names for them. I usually use R#'s suggestions, but who is right here?