Can't get IDE0130 to show up in VS2022 error list

65 Views Asked by At

I'm using Visual Studio 2022 Community, and C# projects. I like my namespaces to match my folder structures, so when I move a file from one folder to another within VS, I always accept the popup message offering to change the namespace too, or if I do the move outside of VS (e.g. in File Explorer), I go into the file within VS and open up the code fix stuff for the namespace. That always has an option to "Change namespace to match folder structure", which it says is associated with IDE0130.

That's all great, but I'd also like to get IDE0130 to automatically show up in the error list when I build the project, rather than needing to make sure I remember to use the code fix myself. Unfortunately, I have been unable to get it to show up there, ever.

I have added an .editorconfig file, and in it I enabled the rule as shown in the docs for IDE0130:

dotnet_style_namespace_match_folder = true

That's the default anyway, but I figured might as well. I also set its severity to "warning", thinking that would cause it to show up in the error list, based on the same documentation page's example of how to set its severity to "none":

dotnet_diagnostic.IDE0130.severity = warning

It just never shows up in the error list. I have tried many things and done several experiments to try to figure out what's wrong, including but probably not limited to:

  • Varying the location of .editorconfig (e.g. project level, solution level, ancestor of solution level).

  • Putting these lines inside of the [*.cs] section or the [*.{cs,vb}] section... I don't care about VB, but the latter is what's shown on that documentation page, so I figured why not try it.

  • Using the lines in combination or individually.

  • Using the apparently old format of dotnet_style_namespace_match_folder = true:warning

  • Using severity "error" rather than "warning"

  • Using or not using the project file CompilerVisibleProperty includes that are suggested on that page (this should not be necessary according to the page, as I'm compiling from within VS rather than from the command line, but hey)

  • Unloading/reloading projects, closing/reopening solutions, stopping/restarting VS, building, rebuilding, cleaning build, etc.

  • All of the above in various combinations and orders.

None of that helped.

I have verified that I can control another message in this way; for example IDE0290, "Use primary constructor":

dotnet_diagnostic.IDE0290.severity = error

When I add that line to the exact same .editorconfig file, instances of that diagnostic automatically change in the error list from their default "message" to "error".

I have also noticed that when I open up the code fix popup for an instance of IDE0130, I can select an option to set its severity there. Doing so automatically modifies (well, overwrites, actually ) the .editorconfig file seemingly with the exact same thing that I had/would put in there manually if I wanted the specified severity. And that still doesn't make IDE0130 show up.

Am I missing something here? Is there perhaps some other level of configuration that has to be set up in a certain way? Thanks for any help.

1

There are 1 best solutions below

0
Minxin Yu - MSFT On

The problem is open on GitHub: https://github.com/dotnet/sdk/issues/39742.

You can post comments and follow the progress of the issue.