admin管理员组

文章数量:1122832

As a standardized convention, I have set up my system to suggest that most private items, including methods, start with an underscore.

The current revision of Visual Studio 2022 seems to have broken my convention. Has anyone else seen this and how do I fix it?

Details: The "Tools:Options" dialog, in the "Text Editor - C# - Code Style - Naming" section

I have a specification called "Should be Private" that has most of the "Symbol Kinds" checked (including Methods). In the "Accessibilities" section: private, internal, protected private, and protected internal are checked. Nothing is checked in the "Modifiers" section.

I have a Naming style called "Underscore and Pascal", which has (as you would expect) a prefix of "_" and a capitalization of "Pascal Case Name"

In my projects, I now (suddenly after upgrading to 17.12.1) have a lot of (Suggestion method) errors of type IDE1006 (Prefix '_' is not expected) for all of the private methods in my code.

Note: the same thing happens in VB as well

I've tried rebuilding the specifications and styles to see if something else is going on, but to no avail...

As a standardized convention, I have set up my system to suggest that most private items, including methods, start with an underscore.

The current revision of Visual Studio 2022 seems to have broken my convention. Has anyone else seen this and how do I fix it?

Details: The "Tools:Options" dialog, in the "Text Editor - C# - Code Style - Naming" section

I have a specification called "Should be Private" that has most of the "Symbol Kinds" checked (including Methods). In the "Accessibilities" section: private, internal, protected private, and protected internal are checked. Nothing is checked in the "Modifiers" section.

I have a Naming style called "Underscore and Pascal", which has (as you would expect) a prefix of "_" and a capitalization of "Pascal Case Name"

In my projects, I now (suddenly after upgrading to 17.12.1) have a lot of (Suggestion method) errors of type IDE1006 (Prefix '_' is not expected) for all of the private methods in my code.

Note: the same thing happens in VB as well

I've tried rebuilding the specifications and styles to see if something else is going on, but to no avail...

Share Improve this question edited Nov 23, 2024 at 5:58 Filburt 18.1k12 gold badges80 silver badges136 bronze badges asked Nov 23, 2024 at 5:09 AlanAlan 211 silver badge1 bronze badge 1
  • Visual Studio 17.12.1 also appears to be ignoring this setting when doing Ctrl+. to create and assign fields from class constructors. Something is definitely broken. – Jerrill Commented Nov 27, 2024 at 21:22
Add a comment  | 

1 Answer 1

Reset to default 3

With new .net release I updated my VS to version 17.12.2. I found out today that I have exactly the same problem.

Solution: Unpleasant fix for me was to generate .editorconfig for each project I use. First I checked my settings if they were not rewritten:

Then I clicked on the Code Style tab and from there I generated .editorconfig file into my project folder for each project I have:

Check: Add and remove EditorConfig files

In Options > Text Editor > General, there is checkbox called "Follow project coding conventions". It looks like it is not working properly as described here:

"When selected, any project specific code style settings will override any local code style settings specified in the Options dialog box by selecting Text Editor"

This is ugly solution and I never had to put it inside project. It was my local setting, I don't understand why this file should travel with the project. (for git adding it to .gitignore can be solution).

本文标签: visual studio 2022Did the configuration of naming options get changed in newest revisionStack Overflow