Overview
This style rule uses the folder structure of the project to enforce namespace naming requirements.
Options
Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.
dotnet_style_namespace_match_folder
| Property | Value | Description |
|---|---|---|
| Option name | dotnet_style_namespace_match_folder | |
| Option values | true |
Prefer namespace naming to match folder structure. |
false |
Disables the rule. | |
| Default option value | true |
Example
Assume that the following code snippets are from a file named Data/Example.cs or Data/Example.vb, where Data represents the folder structure from the project file. The folder structure naming is added to the root namespace, which in this example is Root.
// Code with violations
namespace Root.BadExample
{
class Example
{
public void M()
{
}
}
}
// Fixed code
namespace Root.Data
{
class Example
{
public void M()
{
}
}
}' Code with violations
Namespace Root.BadExample
Class Example
Public Sub M()
End Sub
End Class
End Namespace
' Fixed code
Namespace Root.Data
Class Example
Public Sub M()
End Sub
End Class
End NamespaceSuppress a warning
If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable IDE0130
// The code that's violating the rule is on this line.
#pragma warning restore IDE0130To disable the rule for a file, folder, or project, set its severity to none in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE0130.severity = noneTo disable all of the code-style rules, set the severity for the category Style to none in the configuration file.
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-Style.severity = noneFor more information, see How to suppress code analysis warnings.