How to configure editorconfig file to allow units of measurement after variable names?

64 views Asked by At

I am configuring naming conventions for a C# project using Visual Studio and Resharper. I want to export the conventions to an .editorconfig file so that other developers have the same convention even if they do not use Resharper or even Visual Studio. Resharper has built-in support to export to editorconfig.

Now my problem: Let "batteryVoltage" be a local variable to capture the voltage of a battery. I would like to specify the unit of measurement including the metric prefix, e.g. "batteryVoltage_V" (V for Volt), or "batteryVoltage_mV" (mV for milli-volt). Both options should be allowed by the naming convention.

In Resharper, I can configure multiple naming rules for local variables to set this up like this, which works perfectly.

enter image description here

However, If I export this exact configuration to editorconfig, Visual Studio shows a IDE1006 naming rule violation for the "batteryVoltage_mV" variable. I have pasted the content of the .editorconfig file below (I stripped away stuff of which I am sure its not relevant).

My question: How can I modify the editorconfig file to allow both styles like resharper does?

# Microsoft .NET properties

dotnet_naming_rule.locals_rule.import_to_resharper = as_predefined
dotnet_naming_rule.locals_rule.resharper_style = aaBb_aaBb, aaBb_AaBb
dotnet_naming_rule.locals_rule.severity = warning
dotnet_naming_rule.locals_rule.style = lower_camel_case_underscore_tolerant_style
dotnet_naming_rule.locals_rule.symbols = locals_symbols
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
dotnet_naming_style.lower_camel_case_underscore_tolerant_style.capitalization = camel_case
dotnet_naming_style.lower_camel_case_underscore_tolerant_style.word_separator = _
dotnet_naming_symbols.locals_symbols.applicable_accessibilities = *
dotnet_naming_symbols.locals_symbols.applicable_kinds = local
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

0

There are 0 answers