Evenimente
17 mar., 21 - 21 mar., 10
Alăturați-vă seriei de întâlniri pentru a construi soluții AI scalabile bazate pe cazuri de utilizare din lumea reală cu colegi dezvoltatori și experți.
Înregistrați-vă acumAcest browser nu mai este acceptat.
Faceți upgrade la Microsoft Edge pentru a profita de cele mai noi funcții, actualizări de securitate și asistență tehnică.
Property | Value |
---|---|
Rule ID | IDE0049 |
Title | Use language keywords instead of framework type names for type references |
Category | Style |
Subcategory | Language rules (language keywords instead of framework type names) |
Applicable languages | C# and Visual Basic |
Options | dotnet_style_predefined_type_for_locals_parameters_members |
dotnet_style_predefined_type_for_member_access |
This rule concerns the use of language keywords, where they exist, instead of framework type names.
Notă
Even if you enable code style rules on build, this rule is not enabled. It only surfaces in the Visual Studio editor.
Use the associated options for this rule to apply it to:
An option value of true
means prefer the language keyword (for example, int
or Integer
) instead of the type name (for example, Int32
) for types that have a keyword to represent them. A value of false
means prefer the type name instead of the language keyword.
For information about configuring options, see Option format.
Property | Value | Description |
---|---|---|
Option name | dotnet_style_predefined_type_for_locals_parameters_members | |
Option values | true |
Prefer the language keyword for local variables, method parameters, and class members |
false |
Prefer the type name for local variables, method parameters, and class members | |
Default option value | true |
// dotnet_style_predefined_type_for_locals_parameters_members = true
private int _member;
// dotnet_style_predefined_type_for_locals_parameters_members = false
private Int32 _member;
' dotnet_style_predefined_type_for_locals_parameters_members = true
Private _member As Integer
' dotnet_style_predefined_type_for_locals_parameters_members = false
Private _member As Int32
Property | Value | Description |
---|---|---|
Option name | dotnet_style_predefined_type_for_member_access | |
Option values | true |
Prefer the language keyword for member access expressions |
false |
Prefer the type name for member access expressions | |
Default option value | true |
// dotnet_style_predefined_type_for_member_access = true
var local = int.MaxValue;
// dotnet_style_predefined_type_for_member_access = false
var local = Int32.MaxValue;
' dotnet_style_predefined_type_for_member_access = true
Dim local = Integer.MaxValue
' dotnet_style_predefined_type_for_member_access = false
Dim local = Int32.MaxValue
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 IDE0049
// The code that's violating the rule is on this line.
#pragma warning restore IDE0049
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE0049.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.
Feedback pentru .NET
.NET este un proiect open source. Selectați un link pentru a oferi feedback:
Evenimente
17 mar., 21 - 21 mar., 10
Alăturați-vă seriei de întâlniri pentru a construi soluții AI scalabile bazate pe cazuri de utilizare din lumea reală cu colegi dezvoltatori și experți.
Înregistrați-vă acum