A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-quality-rule-options below:

Code quality rule configuration options - .NET

The code quality rules have additional configuration options, besides just configuring their severity. For example, each code quality analyzer can be configured to only apply to specific parts of your codebase. You specify these options by adding key-value pairs to the same EditorConfig file where you specify rule severities and general editor preferences.

Note

This article does not detail how to configure a rule's severity. The .editorconfig option to set a rule's severity has a different prefix (dotnet_diagnostic) to the options described here (dotnet_code_quality). In addition, the options described here pertain to code quality rules only, whereas the severity option applies to code style rules as well. As a quick reference, you can configure a rule's severity using the following option syntax:

dotnet_diagnostic.<rule ID>.severity = <severity value>

However, for detailed information about configuring rule severity, see Severity level.

Option scopes

Each refining option can be configured for all rules, for a category of rules (for example, Security or Design), or for a specific rule.

All rules

The syntax for configuring an option for all rules is as follows:

Syntax Example dotnet_code_quality.<OptionName> = <OptionValue> dotnet_code_quality.api_surface = public

The values for <OptionName> are listed under Options.

Category of rules

The syntax for configuring an option for a category of rules is as follows:

Syntax Example dotnet_code_quality.<RuleCategory>.<OptionName> = OptionValue dotnet_code_quality.Naming.api_surface = public

The following table lists the available values for <RuleCategory>.

Design
Documentation
Globalization
Interoperability

Maintainability
Naming
Performance
SingleFile

Reliability
Security
Usage

Specific rule

The syntax for configuring an option for a specific rule is as follows:

Syntax Example dotnet_code_quality.<RuleId>.<OptionName> = <OptionValue> dotnet_code_quality.CA1040.api_surface = public Options

This section lists the available configuration options for code analyzers. For more information, see Analyzer configuration.

api_surface exclude_async_void_methods Description Allowable values Default value Configurable rules Whether to ignore asynchronous methods that don't return a value true
false false CA2007

Note

This option was named skip_async_void_methods in an earlier version.

exclude_single_letter_type_parameters Description Allowable values Default value Configurable rules Whether to exclude single-character type parameters from the rule, for example, S in Collection<S> true
false false CA1715

Note

This option was named allow_single_letter_type_parameters in an earlier version.

output_kind Description Allowable values Default value Configurable rules Specifies that code in a project that generates this type of assembly should be analyzed One or more fields of the OutputKind enumeration

Separate multiple values with a comma (,)

All output kinds CA1515, CA1516, CA2007 required_modifiers Description Allowable values Default value Configurable rules Specifies the required modifiers for APIs that should be analyzed One or more values from the below allowed modifiers table

Separate multiple values with a comma (,)

Depends on each rule CA1802 Allowed Modifier Summary none No modifier requirement static or Shared Must be declared as static (Shared in Visual Basic) const Must be declared as const readonly Must be declared as readonly abstract Must be declared as abstract virtual Must be declared as virtual override Must be declared as override sealed Must be declared as sealed extern Must be declared as extern async Must be declared as async exclude_extension_method_this_parameter Description Allowable values Default value Configurable rules Whether to skip analysis for the this parameter of extension methods true
false false CA1062 null_check_validation_methods Description Allowable values Default value Configurable rules Names of null-check validation methods that validate that arguments passed to the method are non-null Allowed method name formats (separated by |):
- Method name only (includes all methods with the name, regardless of the containing type or namespace)
- Fully qualified names in the symbol's documentation ID format, with an optional M: prefix None CA1062 additional_string_formatting_methods Description Allowable values Default value Configurable rules Names of additional string formatting methods Allowed method name formats (separated by |):
- Method name only (includes all methods with the name, regardless of the containing type or namespace)
- Fully qualified names in the symbol's documentation ID format, with an optional M: prefix None CA2241 excluded_type_names_with_derived_types excluded_symbol_names disallowed_symbol_names Description Allowable values Default value Configurable rules Names of symbols that are disallowed in the context of the analysis Allowed symbol name formats (separated by |):
- Symbol name only (includes all symbols with the name, regardless of the containing type or namespace)
- Fully qualified names in the symbol's documentation ID format. Each symbol name requires a symbol kind prefix, such as M: prefix for methods, T: prefix for types, and N: prefix for namespaces.
- .ctor for constructors and .cctor for static constructors None CA1031 exclude_ordefault_methods Description Allowable values Default value Configurable rules Excludes FirstOrDefault and LastOrDefault methods from analysis. true or false false CA1826 ignore_internalsvisibleto try_determine_additional_string_formatting_methods_automatically Description Allowable values Default value Configurable rules Boolean option to enable heuristic detection of additional string formatting methods.
A method is considered a string formatting method if it has a string format parameter followed by a params object[] parameter. true or false false CA2241 unsafe_DllImportSearchPath_bits Description Allowable values Default value Configurable rules Configure which value of DllImportSearchPath is unsafe for the analysis Integer values of System.Runtime.InteropServices.DllImportSearchPath 770 (that is, AssemblyDirectory | UseDllDirectoryForDependencies | ApplicationDirectory) CA5393 exclude_aspnet_core_mvc_controllerbase Description Allowable values Default value Configurable rules Exclude ASP.NET Core MVC ControllerBase when considering CSRF true or false true CA5391 enum_values_prefix_trigger Description Allowable values Default value Configurable rules Specifies the threshold to trigger the enum values naming rule - AnyEnumValue - The rule is triggered if any of the enum values starts with the enum type name.
- AllEnumValues - The rule is triggered if all of the enum values start with the enum type name.
- Heuristic - The rule is triggered using the default FxCop heuristic (that is, when at least 75% of the enum values start with the enum type name).
Heuristic CA1712 exclude_indirect_base_types Description Allowable values Default value Configurable rules Exclude indirect base types true or false true CA1710 additional_required_suffixes Description Allowable values Default value Configurable rules Specifies additional required suffixes List of type names (separated by |) with their required suffix (separated by ->). Allowed type name formats:
- Type name only (includes all types with the name, regardless of the containing type or namespace).
- Fully qualified names in the symbol's documentation ID format with an optional T: prefix. None CA1710 additional_required_generic_interfaces Description Allowable values Default value Configurable rules Specifies additional required generic interfaces List of interface names (separated by |) with their required generic fully qualified interface (separated by ->). Allowed interface formats:
- Interface name only (includes all interfaces with the name, regardless of the containing type or namespace).
- Fully qualified names in the symbol's documentation ID format with an optional T: prefix. None CA1010

Examples:

Option Value Summary dotnet_code_quality.CA1010.additional_required_generic_interfaces = ISomething->System.Collections.Generic.IEnumerable`1 All types implementing ISomething regardless of its namespace are expected to also implement System.Collections.Generic.IEnumerable\`1. dotnet_code_quality.CA1010.additional_required_generic_interfaces = T:System.Collections.IDictionary->T:System.Collections.Generic.IDictionary`2 All types implementing System.Collections.IDictionary are expected to also implement System.Collections.Generic.IDictionary`2. additional_inheritance_excluded_symbol_names Description Allowable values Default value Configurable rules Specifies types or namespaces to exclude from the inheritance hierarchy tree Allowed type name formats:
- Type or namespace name (includes all types with the name, regardless of the containing type or namespace, and all types whose namespace contains the name).
- Type or namespace name ending with a wildcard symbol (includes all types whose name starts with the given name, regardless of the containing type or namespace, and all types whose namespace contains the name).
- Fully qualified names in the symbol's documentation ID format with an optional T: prefix for types or N: prefix for namespaces.
- Fully qualified type or namespace name with an optional T: prefix for type or N: prefix for namespace and ending with the wildcard symbol (includes all types whose fully qualified name starts with the given type name, or all types whose fully qualified name starts with the given namespace name). N:System.* (This value is always automatically added to the value provided) CA1501 analyzed_symbol_kinds Description Allowable values Default value Configurable rules Specifies the symbol kinds to analyze One or more fields of SymbolKind as a comma-separated list. Namespace, NamedType, Method, Property, Event, Parameter CA1716 use_naming_heuristic Description Allowable values Default value Configurable rules Configures whether parameters or property names containing Text, Message, or Caption trigger this rule true or false false CA1303 additional_use_results_methods Description Allowable values Default value Configurable rules Specifies additional custom APIs whose results must be used Names of additional methods (separated by |). Allowed method name formats:
- Method name only (includes all methods with the name, regardless of the containing type or namespace).
- Fully qualified names in the symbol's documentation ID format with an optional M: prefix. None CA1806 allowed_suffixes Description Allowable values Default value Configurable rules Specifies allowable suffixes List (separated by |) of allowed suffixes. None CA1711 enable_platform_analyzer_on_pre_net5_target Description Allowable values Default value Configurable rules Specifies whether to enable analysis for TFMs prior to .NET 5 true or false false CA1416 exclude_structs Description Allowable values Default value Configurable rules Specifies whether to exclude structs from analysis true or false false CA1051 additional_enum_none_names Description Allowable values Default value Configurable rules Specifies additional allowable names for a zero-value enumeration field List of additional names (separated by |). None CA1008 enumeration_methods Description Allowable values Default value Configurable rules Specifies additional custom methods that enumerate an IEnumerable Fully qualified names of additional methods (separated by |). None CA1851 linq_chain_methods Description Allowable values Default value Configurable rules Specifies additional customized LINQ chain methods (that is, methods take an IEnumerable argument and return a new IEnumerable instance) Fully qualified names of additional methods (separated by |). None CA1851 assume_method_enumerates_parameters Description Allowable values Default value Configurable rules Specifies whether to assume that customized methods enumerate their IEnumerable parameters true or false false CA1851 Dataflow analysis options

The options in this section configure dataflow analysis rules. The options are:

For more information about dataflow analysis, see Writing dataflow analysis based analyzers.

dispose_analysis_kind Description Allowable values Default value Configurable rules Specifies which paths to analyze for dispose violations - AllPaths - Track and report missing dispose violations on all paths (non-exception and exception paths). Additionally, also flag use of non-recommended dispose patterns that might cause potential dispose leaks.
- AllPathsOnlyNotDisposed - Track and report missing dispose violations on all paths (non-exception and exception paths). Do not flag use of non-recommended dispose patterns that might cause potential dispose leaks.
- NonExceptionPaths - Track and report missing dispose violations only on non-exception program paths. Additionally, also flag use of non-recommended dispose patterns that might cause potential dispose leaks.
- NonExceptionPathsOnlyNotDisposed - Track and report missing dispose violations only on non-exception program paths. Do not flag use of non-recommended dispose patterns that might cause potential dispose leaks. NonExceptionPaths CA2000 dispose_ownership_transfer_at_constructor Description Allowable values Default value Configurable rules Configure dispose ownership transfer for arguments passed to constructor invocation true or false false CA2000 dispose_ownership_transfer_at_method_call Description Allowable values Default value Configurable rules Configure dispose ownership transfer for disposable objects passed as arguments to method calls true or false false CA2000 interprocedural_analysis_kind Description Allowable values Default value Configurable rules Specifies whether to perform interprocedural analysis for source method invocations None, NonContextSensitive, ContextSensitive Specific to each configurable rule CA1062, CA1303, CA1508, CA2000, CA2100, CA2213 max_interprocedural_method_call_chain Description Allowable values Default value Configurable rules Specifies the maximum method call chain length to analyze for interprocedural dataflow analysis Unsigned integer 3 CA1062, CA1303, CA1508, CA2000, CA2100, CA2213 max_interprocedural_lambda_or_local_function_call_chain Description Allowable values Default value Configurable rules Specifies the maximum lambda or local function call chain length to analyze for interprocedural dataflow analysis Unsigned integer 3 CA1062, CA1303, CA1508, CA2000, CA2100, CA2213 points_to_analysis_kind copy_analysis sufficient_IterationCount_for_weak_KDF_algorithm Description Allowable values Default value Configurable rules Configures a sufficient iteration count when using a weak key derivation function (KDF) algorithm Integer 100000 for most rules CA1062, CA1303, CA1508, CA2000, CA2100, CA2213

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4