Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 1.27 KB

File metadata and controls

47 lines (34 loc) · 1.27 KB

SX1309S

TypeName SX1309SStaticFieldNamesMustBeginWithUnderscore
CheckId SX1309S
Category Naming Rules (Alternative)

Alternative rule

This rule is a non-standard extension to the default StyleCop behavior, and represents an alternative style which is adopted by some projects. Alternative rules are known to directly conflict with standard StyleCop rules.

Cause

A static field name does not begin with an underscore.

Rule description

A violation of this rule occurs when a static field name does not begin with an underscore.

Detailed Behavior

This rule only checks the name of private, static fields that are neither const nor readonly. Static readonly fields are treated like constants and are ignored. C# 8 readonly struct members (methods, properties, indexers) are not analyzed by this rule.

How to fix violations

The fix an instance of this violation, add an underscore (_) prefix to the name of the field.

How to suppress violations

#pragma warning disable SX1309S // Static field names should begin with underscore
static int bar;
#pragma warning restore SX1309S // Static field names should begin with underscore