Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting naming styles with R# #617

Open
Hosch250 opened this issue Dec 30, 2016 · 5 comments
Open

Conflicting naming styles with R# #617

Hosch250 opened this issue Dec 30, 2016 · 5 comments

Comments

@Hosch250
Copy link
Contributor

R# says to use _camelCase naming for private static fields. VSD says to use PascalCase names for them. I usually use R#'s suggestions, but who is right here?

@Vannevelj
Copy link
Owner

Did VSD explicitly account for this in the code? Regardless: I think _camelCase is probably best.

@JohanLarsson
Copy link

R# is configurable.

@Hosch250
Copy link
Contributor Author

I'm using the default R# configuration.

@Hosch250
Copy link
Contributor Author

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);
    }
}

@JohanLarsson
Copy link

StyleCop does not agree with underscore prefixes. An alternative can be to try to detect the convention used in the document/project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants