I want to standardize the C# coding style for my team's .NET projects. Building on the default Visual Studio and CoreFX .editorconfig files, I am trying to build our custom one per our needs.
What I am missing is how do I raise a Suggestion for:
Local variables not properly named (camelCase). For example, below I need a Suggestion if myData is named MyData:
var myData = GetFileData()
Parameter names not properly named (camelCase). Similarly, I need a suggestion below if the nextJobExecutionId parameter is given as NextJobExecutionId
public void ParseFiles(long nextJobExecutionId)
CoreFX .editorconfig has helped me name many other cases (i.e statics, private class fields, etc.) but not this. Any idea?
CodePudding user response:
You will need the local
and parameter
types as scope to define the rules here.
[*.{cs,vb,cshtml,vbhtml}]
# For variables
dotnet_naming_symbols.local_symbol.applicable_kinds = local
dotnet_naming_style.local_style.capitalization = camel_case
dotnet_naming_rule.variables_are_camel_case.severity = suggestion
dotnet_naming_rule.variables_are_camel_case.symbols = local_symbol
dotnet_naming_rule.variables_are_camel_case.style = local_style
# for parameters
dotnet_naming_symbols.parameter_symbol.applicable_kinds = parameter
dotnet_naming_style.parameter_style.capitalization = camel_case
dotnet_naming_rule.parameters_are_camel_case.severity = suggestion
dotnet_naming_rule.parameters_are_camel_case.symbols = parameter_symbol
dotnet_naming_rule.parameters_are_camel_case.style = parameter_style
the outcome looks like:
of course you can merge the two under a same scope:
dotnet_naming_symbols.local_parameter_symbol.applicable_kinds = local,parameter
hope it helps