Namespace does not match folder structure (IDE0130)
Članak
Property
Value
Rule ID
IDE0130
Title
Namespace does not match folder structure
Category
Style
Subcategory
Language rules (expression-level preferences)
Applicable languages
C# and Visual Basic
Options
dotnet_style_namespace_match_folder
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
Napomena
The dotnet_style_namespace_match_folder option depends on knowing the current project and root namespace properties. This information is provided by Visual Studio but is not available for command-line builds, such as dotnet build. For command-line builds to work, you must add the following properties to your project file:
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 Sub M()
End Sub
End Class
End Namespace
' Fixed code
Namespace Root.Data
Class Example
Public Sub M()
End Sub
End Class
End Namespace
Suppress 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.
C#
#pragmawarning disable IDE0130// The code that's violating the rule is on this line.#pragmawarning restore IDE0130
To disable the rule for a file, folder, or project, set its severity to none in the configuration file.
Izvor za ovaj sadržaj možete pronaći na GitHubu, gdje možete stvarati i pregledavati probleme i zahtjeve za povlačenjem. Dodatne informacije potražite u našem vodiču za suradnike.
Povratne informacije o proizvodu .NET
.NET je projekt otvorenog koda. Odaberite vezu za slanje povratnih informacija:
Pridružite se seriji susreta kako biste s kolegama programerima i stručnjacima izgradili skalabilna rješenja umjetne inteligencije temeljena na stvarnim slučajevima upotrebe.