συμβάν
17 Μαρ, 9 μ.μ. - 21 Μαρ, 10 π.μ.
Συμμετάσχετε στη σειρά meetup για να δημιουργήσετε κλιμακούμενες λύσεις AI που βασίζονται σε πραγματικές περιπτώσεις χρήσης με συναδέλφους προγραμματιστές και ειδικούς.
Εγγραφή τώραΑυτό το πρόγραμμα περιήγησης δεν υποστηρίζεται πλέον.
Κάντε αναβάθμιση σε Microsoft Edge για να επωφεληθείτε από τις τελευταίες δυνατότητες, τις ενημερώσεις ασφαλείας και την τεχνική υποστήριξη.
This article describes two related rules, IDE0003
and IDE0009
.
Property | Value |
---|---|
Rule ID | IDE0003 |
Title | Remove this or Me qualification |
Category | Style |
Subcategory | Language rules ('this.' and 'Me.' qualifiers) |
Applicable languages | C# and Visual Basic |
Options | dotnet_style_qualification_for_field |
dotnet_style_qualification_for_property |
|
dotnet_style_qualification_for_method |
|
dotnet_style_qualification_for_event |
Property | Value |
---|---|
Rule ID | IDE0009 |
Title | Add this or Me qualification |
Category | Style |
Subcategory | Language rules ('this.' and 'Me.' qualifiers) |
Applicable languages | C# and Visual Basic |
Options | dotnet_style_qualification_for_field |
dotnet_style_qualification_for_property |
|
dotnet_style_qualification_for_method |
|
dotnet_style_qualification_for_event |
These two rules define whether or not you prefer the use of this (C#) and Me.
(Visual Basic) qualifiers. To enforce that the qualifiers aren't present, set the severity of IDE0003
to warning or error. To enforce that the qualifiers are present, set the severity of IDE0009
to warning or error.
For example, if you prefer qualifiers for fields and properties but not for methods or events, then you can enable IDE0009
and set the options dotnet_style_qualification_for_field
and dotnet_style_qualification_for_property
to true
. However, this configuration would not flag methods and events that do have this
and Me
qualifiers. To also enforce that methods and events don't have qualifiers, enable IDE0003
.
Σημείωση
Even if you enable code style rules on build, this rule is not enabled. It only surfaces in the Visual Studio editor.
This rule's associated options define which of the following symbols this style preference should be applied to:
An option value of true
means prefer the code symbol to be prefaced with this.
in C# and Me.
in Visual Basic. An option value of false
means prefer the code element not to be prefaced with this.
or Me.
.
For more information about configuring options, see Option format.
Property | Value | Description |
---|---|---|
Option name | dotnet_style_qualification_for_field | |
Option values | true |
Prefer fields to be prefaced with this. in C# or Me. in Visual Basic |
false |
Prefer fields not to be prefaced with this. or Me. |
|
Default option value | false |
// dotnet_style_qualification_for_field = true
this.capacity = 0;
// dotnet_style_qualification_for_field = false
capacity = 0;
' dotnet_style_qualification_for_field = true
Me.capacity = 0
' dotnet_style_qualification_for_field = false
capacity = 0
Property | Value | Description |
---|---|---|
Option name | dotnet_style_qualification_for_property | |
Option values | true |
Prefer properties to be prefaced with this. in C# or Me. in Visual Basic. |
false |
Prefer properties not to be prefaced with this. or Me. . |
|
Default option value | false |
// dotnet_style_qualification_for_property = true
this.ID = 0;
// dotnet_style_qualification_for_property = false
ID = 0;
' dotnet_style_qualification_for_property = true
Me.ID = 0
' dotnet_style_qualification_for_property = false
ID = 0
Property | Value | Description |
---|---|---|
Option name | dotnet_style_qualification_for_method | |
Option values | true |
Prefer methods to be prefaced with this. in C# or Me. in Visual Basic. |
false |
Prefer methods not to be prefaced with this. or Me. . |
|
Default option value | false |
// dotnet_style_qualification_for_method = true
this.Display();
// dotnet_style_qualification_for_method = false
Display();
' dotnet_style_qualification_for_method = true
Me.Display()
' dotnet_style_qualification_for_method = false
Display()
Property | Value | Description |
---|---|---|
Option name | dotnet_style_qualification_for_event | |
Option values | true |
Prefer events to be prefaced with this. in C# or Me. in Visual Basic. |
false |
Prefer events not to be prefaced with this. or Me. . |
|
Default option value | false |
// dotnet_style_qualification_for_event = true
this.Elapsed += Handler;
// dotnet_style_qualification_for_event = false
Elapsed += Handler;
' dotnet_style_qualification_for_event = true
AddHandler Me.Elapsed, AddressOf Handler
' dotnet_style_qualification_for_event = false
AddHandler Elapsed, AddressOf Handler
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 IDE0003 // Or IDE0009
// The code that's violating the rule is on this line.
#pragma warning restore IDE0003 // Or IDE0009
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE0003.severity = none
dotnet_diagnostic.IDE0009.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 Μαρ, 9 μ.μ. - 21 Μαρ, 10 π.μ.
Συμμετάσχετε στη σειρά meetup για να δημιουργήσετε κλιμακούμενες λύσεις AI που βασίζονται σε πραγματικές περιπτώσεις χρήσης με συναδέλφους προγραμματιστές και ειδικούς.
Εγγραφή τώρα