dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.04k stars 4.03k forks source link

Naming Style: Underscore does not trigger violation in camel_case and pascal_case style #22745

Open nphmuller opened 7 years ago

nphmuller commented 7 years ago

Version Used: The version in VS15.4.0

Steps to Reproduce:

Git clone the following repo: https://github.com/nphmuller/RoslynNameStyleUnderscore.git

OR

  1. Create the following .editorconfig rule:
    
    dotnet_naming_rule.private_fields_are_camel_case.symbols = private_field
    dotnet_naming_rule.private_fields_are_camel_case.style = camel_case
    dotnet_naming_rule.private_fields_are_camel_case.severity = warning

dotnet_naming_symbols.private_field.applicable_accessibilities = private dotnet_naming_symbols.private_field.applicable_kinds = field

dotnet_naming_style.camel_case.capitalization = camel_case dotnet_naming_style.pascal_case.capitalization = pascal_case

2. Insert the following code snippet:
``` c#
    public class Class1
    {
        private string camelCase; // (1)
        private string PascalCase;  // (2)

        private string _camelCase;  // (3)
        private string _PascalCase;  // (4)

        private string snake_case;  // (5)
        private string Snake_Case;  // (6)
    }

Expected Behavior: Field 2, 3, 4, 5 and 6 should throw a warning.

Actual Behavior: Field 2 and 6 throw a warning.

Additionally

Change the value on line 2 from the editorconfig file from camel_case to pascal_case.

Expected Behavior: Field 1, 3, 4, 5 and 6 should throw a warning.

Actual Behavior: Field 1 and 5 throw a warning.

sharwell commented 6 years ago

Case 4 is a duplicate of #18354.

💭 Cases 3 and 6 seem to be a failure of the IDE to know what PascalCase is.

jinujoseph commented 5 years ago

Reported at DC

WPJorge commented 1 year ago

@akhera99 is there any update on this topic?