single-namespace-per-file
What it does
Section titled “What it does”Reports a namespace that comes after the first one in a file; nested namespaces are reported too. No fix.
Why it matters
Section titled “Why it matters”A file with one namespace has one place where its names come from. Several namespaces in a file make the meaning of a name depend on where in the file it is read.
To fix, move the later namespaces into files of their own.
Example
Section titled “Example”...namespace N { class Other { void M() {...#endregion} } class B { } struct S { } namespace M { } }Configuration
Section titled “Configuration”csharp: lint: rules: single-namespace-per-file: warn # off (default), warn, errorEnabled by the presets: csharp/stylecop.
Suppress one line with sudsy-disable-next-line single-namespace-per-file in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| StyleCop | SA1403 |
full |