qualify-namespace-usings
What it does
Section titled “What it does”Reports a using directive inside a namespace whose name is not written fully qualified, so that it resolves relative to the enclosing namespace. The fix writes the full name, unless it has type arguments.
Why it matters
Section titled “Why it matters”A relative name resolves to different things when a namespace with that name is added anywhere in the enclosing namespaces, so a new file can change what a using means without touching it.
To fix, write the full name.
Example
Section titled “Example”using System;using System.Diagnostics;namespace A.B { using C.D; struct S { }... class P { public virtual void Run() { } }...using System;using System.Diagnostics;namespace A.B { using A.C.D; struct S { }... class P { public virtual void Run() { } }...Configuration
Section titled “Configuration”csharp: lint: rules: qualify-namespace-usings: warn # off (default), warn, errorEnabled by the presets: csharp/stylecop.
Suppress one line with sudsy-disable-next-line qualify-namespace-usings 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 | SA1135 |
full |