Resharper Command Line Tools EditorConfig

Hello Team

Does .EditorConfig works with Resharper CLT? If it does, is there any example/documentation for the same?

I tried working with Resharper CLT (inspectCode.exe) and .EditorConfig but its not working as expected. I expected the rules in .EditorConfig to be used but doesn't look like. 

Thanks.

0
6 comments
Official comment

It should work for 2019.3 or newer versions. Could you please provide extracts from your editorconfig with rules that don't work?

Hi Dmitry

Do you mean **2019.3 or older** or **2019.3 or newer** version?  Following are the details:

CLT Details

  • CLT version: JetBrains.ReSharper.CommandLineTools.2020.1
  • Using inspectCode.exe
  • Tried editorconfig at both repository root level and solution root level.
  • Visual studio - with the same editor config shows the expected result (shows the interface name with an error).

Editor Config:

root = true

[*]
indent_style = space

[*.{cs,vb}]
# Style Definitions
dotnet_naming_rule.interface_rule.symbols = interface_symbols
dotnet_naming_symbols.interface_symbols.applicable_kinds = interface
dotnet_naming_symbols.interface_symbols.applicable_accessibilities = *
dotnet_naming_rule.interface_rule.severity = error
dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style

dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I
dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case

Test Code (added below code in one of the files):

public interface Test
{
    string Message { get; set; }
}

Actual Output in Xml file 

Received Warning

<IssueType Id="InconsistentNaming" Category="Constraints Violations" 
CategoryId="ConstraintViolation" Description="Inconsistent Naming" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=InconsistentNaming" />


<Issue TypeId="InconsistentNaming" File="EditorConfigNetFrameworkTest\Controllers\ManageController.cs" Offset="328-332" Line="13" Message="Name 'Test' does not match rule 'Interfaces'. Suggested name is 'ITest'." />

Was expecting following output:

Was expecting Error

<IssueType Id="InconsistentNaming" Category="Constraints Violations" 
CategoryId="ConstraintViolation" Description="Inconsistent Naming" Severity="ERROR" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=InconsistentNaming" />


<Issue TypeId="InconsistentNaming" File="EditorConfigNetFrameworkTest\Controllers\ManageController.cs" Offset="328-332" Line="13" Message="Name 'Test' does not match rule 'Interfaces'. Suggested name is 'ITest'." />

Visual Studio shows the interface name with an error (shown below). If I turn the error to warning in editorconfig - Visual studio shows interface name with warning. So its working as per my expectation.

 

Please let me know if you need any further details or if I have missed something

Also, is there an example anywhere about how to use EditorConfig with Resharper CLT?

Thanks

 

 

 

 

0

Hi Raghavrkapoor!

Of course I mean newer, sorry for confusion.
InspectCode outputs issue severities set on a solution level. To change severities on a solution level using .editorconfig:
1. Please use [*] instead of [*.{cs,vb}]
2. Place your .editorconfig file in the same folder as your .sln file or in any folder above it.

We would think about outputting severities also separately for each found issue.

0

Hi Dmitry

Thanks for the details. After making the changes you listed above its working as per expectations. I can see the changes made to editorconfig reflected in the output. 

Have one more question though -

I was only expecting the output to include details of the rules that are there in the editorconfig file. With editorconfig example that I included in previous comment I expected the output to only include failures for "dotnet_naming_rule.interface_rule". However I can see the details of other rules in the output as well (image below). I want the rules listed in editorconfig to be the only rules that should be run as part of inspection. How can I achieve this?

Raghav. 

-----------------------------------

 

0

Hi Raghav!
Regarding other rules. That's a problem. By default, ReSharper inspects all naming. We cannot just disable all naming rules when we find an .editorconfig, it would introduce incompatibility with previous versions. We're still researching possible ways to solve this problem. For now, you can add the following lines to your .editorconfig to disable all other naming rules:

# ReSharper properties
resharper_csharp_naming_rule.constants=AaBb:do_not_check
resharper_csharp_naming_rule.enum_member=AaBb:do_not_check
resharper_csharp_naming_rule.event=AaBb:do_not_check
resharper_csharp_naming_rule.locals=aaBb:do_not_check
resharper_csharp_naming_rule.local_constants=aaBb:do_not_check
resharper_csharp_naming_rule.local_functions=AaBb:do_not_check
resharper_csharp_naming_rule.method=AaBb:do_not_check
resharper_csharp_naming_rule.other=AaBb:do_not_check
resharper_csharp_naming_rule.parameters=aaBb:do_not_check
resharper_csharp_naming_rule.private_constants=AaBb:do_not_check
resharper_csharp_naming_rule.private_instance_fields=_ + aaBb:do_not_check
resharper_csharp_naming_rule.private_static_fields=_ + aaBb:do_not_check
resharper_csharp_naming_rule.private_static_readonly=AaBb:do_not_check
resharper_csharp_naming_rule.property=AaBb:do_not_check
resharper_csharp_naming_rule.public_fields=AaBb:do_not_check
resharper_csharp_naming_rule.static_readonly=AaBb:do_not_check
resharper_csharp_naming_rule.types_and_namespaces=AaBb:do_not_check
resharper_csharp_naming_rule.type_parameters=T + AaBb:do_not_check

0

Thanks Dmitry for the above information.

I am having enough information about editorconfig for now to further my work.

However, I am having another issue related to inconsistent execution times for running inspections which is not related to this query. Will ask a separate query. 

Raghav. 

0

Please sign in to leave a comment.