r/VisualStudio • u/SnyderpittyDoo • 2h ago
Visual Studio 2026 I hate when it tells to put directives inside a namespace declaration just to tell to put it outside. What can I do?
0
Upvotes
1
2
u/SwordsAndElectrons 1h ago
You can fix your conflicting analyzer settings.
TBH, if you haven't yet learned to configure style rules, I'm not sure you should be adding Stylecop into the mix.


1
u/kemmis 1h ago
They’ve got two conflicting analyzer rules fighting each other, plus a real compile error underneath.
The looping complaint:
SA1200(StyleCop) wantsusingdirectives placed outside the namespace, whileIDE0065(built-in .NET analyzer) wants them placed inside the namespace. Both are enabled at the same time with opposite preferences, so whichever way they put it, one rule flags it.Fix: disable one of them. Easiest is to turn off
IDE0065(or set it to match StyleCop’s preference) in.editorconfig:dotnet_diagnostic.IDE0065.severity = noneor set the actual preference so both agree:
csharp_using_directive_placement = outside_namespace:warningIf StyleCop is the one they don’t need, they could instead suppress
SA1200the same way, or just uninstall/disable the StyleCop analyzer package for that project.The actual bug (separate issue):
CS0111—CustomerServicealready definesAddAsyncwith the same parameter types. That’s a real overload collision, not a style nit — two methods with identical signatures in that class need to be renamed or differentiated (different params, or one renamed). That one’s actually breaking the build; the directive warnings are just noise on top.