Skip to content
Discussion options

You must be logged in to vote

Yes. If you mean “the namespace should be the project's RootNamespace plus the file's folder path,” the built-in .NET rule IDE0130 checks that (it's not a Roslynator-specific rule). For example, with root namespace Root, a file under Data/Example.cs should use Root.Data.

Add this to .editorconfig to report mismatches as warnings:

[*.cs]
dotnet_style_namespace_match_folder = true
dotnet_diagnostic.IDE0130.severity = warning

For command-line build enforcement, also set <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>. The rule needs RootNamespace and ProjectDir as compiler-visible properties outside Visual Studio:

<ItemGroup>
  <CompilerVisibleProperty Include="RootNamespace" />
  <C…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by schmitch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants