Both ReSharper VisualStudio plugin and inspectcode CLI tool won't respect defined naming styles

Hi,

 

I just installed the ReSharper VS plugin as well as the JetBrains CLI tools. I'm trying to tweak the naming style options (in VS: Extensions > ReSharper > Options... > Code Editing > C# > Naming Style), but ReSharper just doesn't care.

 

For example, in my project, public fields are currently UpperCamelCase. For some reason, even if I set "Fields (not private)" to "UpperCamelCase" in ReSharper settings, I keep getting the following suggestion in VS: IDE1006: Naming rule violation: Missing prefix: '_'

 

The same happens with the inspectcode CLI tool: I export my ReSharper config to an .editorconfig file (in VS: Extensions > ReSharper > Tools > Export Settings to .editorconfig), pass that file to inspectcode with the --profile parameter, but I get the following issue: Name 'XxxYyy' does not match rule 'Fields (not private)'. Suggested name is '_xxxYyy'.

 

I reset the ReSharper settings to factory default several times (Extensions > ReSharper > Manage Options... > Reset All Settings), changing only what I needed, it still doesn't work. It's like my settings are just ignored plain and simple.

 

What am I missing?

5 comments
Comment actions Permalink

Hello,

 

Could you please try disabling the following option - ReSharper | Options | Code Editing | C# | Naming Style | Use auto-detect rules and check if it helps?

If that doesn't help please provide all dotSettings files via ReSharper | Manage Options | right-click on each layer | Export to file. You can upload them using our https://uploads.jetbrains.com/ service.

Also please let me know .editorconfig or Settings.Stylecop file in your solution?

Thank you.

0
Comment actions Permalink

Hi,

 

Disabling the "Use auto-detect rules" didn't help.

Here is the upload ID with the three files: Upload id: 2020_09_21_MyNa2K4AWZwTsQWS (files: computer.DotSettings and 2 more)

 

I tried to use these three files (one by one) with the JetBrains inspectcode CLI tool (--profile parameter) but the contents are not taken into account (my rules are not respected), despite the tool printing: Custom settings layer is mounted. Used file C:\Users\USERNAME\\Projects\MYPROJECT\personal.DotSettings

There is no .editorconfig/Settings.Stylecop in my solution. 

 

Thanks!

0
Comment actions Permalink

Hello,

 

thank you for the provided info.

I wasn't attentive to the details you've provided in your first post, so here are some comments:

  • IDE1006 isn't ReSharper warning, it's VS that provides that warning. (VS Tools | Options | Text Editor | C#  | Code Style | Naming).
  • --profile parameter is used for dotSettings files not for .editorconfig. You don't need to export ReSharper settings to .editorconfig, just specify corresponding dotSettings file. You can read more about ReSharper settings control in command line tools here - https://www.jetbrains.com/help/resharper/InspectCode.html#parameters-for-resharper-settings.

Please let me know if you have any more questions.

Thank you.

0
Comment actions Permalink

Hi,

 

Ok, this explains the problem for the editor then.

 

About the inspectcode CLI tool, I:

1. Set every C# Code Style naming setting to ALL_UPPER. I also unchecked the "Use auto-detected rules" checkbox.

2. Exported the file to Heda.DotSettings

3. Passed the file to inspectcode: inspectcode --profile C:\PATH\TO\Heda.DotSettings

4. It seems it's taking PART of my settings into account because it suggests me to rename some stuff to ALL_UPPER (it didn't before). However, I still get messages like this, when I clearly set everything to ALL_UPPER in the settings, including the "Fields (not private)" category: "Name 'Username' does not match rule 'Fields (not private)'. Suggested name is '_username'.". It should suggest me "USERNAME", not "_username".

 

Here is my Heda.DotSettings: Upload id: 2020_09_22_6KQnAcNuFkdeR3DB (file: Heda.DotSettings)

 

Do you know why it's ignoring this specific setting?

 

Thank you!

0
Comment actions Permalink

Hello Guillaume,

 

thank you for the reply.

Indeed, there seems to be some inconsistency in naming inspection results between ReSharper and CLT. Though in my case rule for "Fields (not private)" works correctly. Could you please also provide some sample solution for which the problem is reproduced and result file of inspectcode.

Thank you.

0

Please sign in to leave a comment.