Search code examples
c#.netvisual-studioeditorconfig

How to set m_ prefix for private fields via .editorconfig for .NET


I want to configure .editorconfig so it uses "m_" prefix for all private fields in C#/.NET. Can't find a setting that works.

The rule should be supported in the current Visual Studio 2017. Preferably by ReSharper as well.


Solution

  • try this

    dotnet_naming_rule.private_fields_should_have_prefix.severity = warning
    dotnet_naming_rule.private_fields_should_have_prefix.symbols  = private_fields
    dotnet_naming_rule.private_fields_should_have_prefix.style    = private_prefix_style
    
    dotnet_naming_symbols.private_fields.applicable_kinds   = field
    dotnet_naming_symbols.private_fields.required_modifiers = private
    
    dotnet_naming_style.private_prefix_style.required_prefix = m_
    dotnet_naming_style.private_prefix_style.capitalization = camel_case