แก้ไข

แชร์ผ่าน


CA1509: Invalid entry in code metrics configuration file

Property Value
Rule ID CA1509
Title Invalid entry in code metrics configuration file
Category Maintainability
Fix is breaking or non-breaking Non-Breaking
Enabled by default in .NET 9 No

Cause

A configuration file named CodeMetricsConfig.txt has an invalid entry.

Rule description

The analysis rules for code metrics allow you to supply an additional file in your project named CodeMetricsConfig.txt. This file contains entries to configure code-metric thresholds for analysis. The following rules are configurable in this file:

This configuration file expects each entry to be in following format:

'RuleId'(Optional 'SymbolKind'): 'Threshold'
  • Valid values for RuleId are CA1501, CA1502, CA1505, and CA1506.
  • Valid values for the optional SymbolKind are Assembly, Namespace, Type, Method, Field, Event, and Property.
  • Valid values for Threshold are non-negative integers.
  • Lines starting with '#' are treated as comment lines.

For example, the following is a valid configuration file:

# Comment text

CA1501: 1

CA1502(Type): 4
CA1502(Method): 2

An invalid entry in this configuration file is flagged with the CA1509 diagnostic.

How to fix violations

To fix a violation of this rule, make sure the invalid entry in CodeMetricsConfig.txt gets the required format.

When to suppress warnings

Do not suppress violations of this rule.

See also