אירוע
17 במרץ, 21 - 21 במרץ, 10
הצטרף לסידרה של פגישות כדי לבנות פתרונות מדרגיים של בינה מלאכותית בהתבסס על מקרי שימוש מהעולם האמיתי עם מפתחים ומומחים אחרים.
הירשם עכשיוהדפדפן הזה אינו נתמך עוד.
שדרג ל- Microsoft Edge כדי לנצל את התכונות, עדכוני האבטחה והתמיכה הטכנית העדכניים ביותר.
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 |
This style rule uses the folder structure of the project to enforce namespace naming requirements.
Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.
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 |
הערה
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:
<ItemGroup>
<CompilerVisibleProperty Include="RootNamespace" />
<CompilerVisibleProperty Include="ProjectDir" />
</ItemGroup>
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 Namespace
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 IDE0130
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE0130.severity = none
To 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 = none
For more information, see How to suppress code analysis warnings.
משוב של .NET
.NET הוא פרויקט קוד פתוח. בחר קישור כדי לספק משוב:
אירוע
17 במרץ, 21 - 21 במרץ, 10
הצטרף לסידרה של פגישות כדי לבנות פתרונות מדרגיים של בינה מלאכותית בהתבסס על מקרי שימוש מהעולם האמיתי עם מפתחים ומומחים אחרים.
הירשם עכשיו