| TypeName | SA1307AccessibleFieldsMustBeginWithUpperCaseLetter |
| CheckId | SA1307 |
| Category | Naming Rules |
The name of a public or internal field in C# does not begin with an upper-case letter.
A violation of this rule occurs when the name of a public or internal field begins with a lower-case letter. Public or internal fields should begin with an upper-case letter.
If the field or variable name is intended to match the name of an item associated with Win32 or COM, and thus needs to start with a lower-case letter, place the field or variable within a special NativeMethods class. A NativeMethods class is any class which contains a name ending in NativeMethods, and is intended as a placeholder for Win32 or COM wrappers. StyleCop will ignore this violation if the item is placed within a NativeMethods class.
C# 8 readonly members do not change the scope of this rule. It still applies only to field declarations (including readonly fields in structs) and ignores readonly methods, properties, indexers, or events. Public and internal readonly fields continue to be analyzed here, while static readonly fields can also trigger SA1311. SA1304 suppresses itself for public and protected readonly fields so only one naming diagnostic is produced.
To fix a violation of this rule, change the name of the field so that it begins with an upper-case letter, or place the item within a NativeMethods class if appropriate.
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Reviewed.")]#pragma warning disable SA1307 // AccessibleFieldsMustBeginWithUpperCaseLetter
#pragma warning restore SA1307 // AccessibleFieldsMustBeginWithUpperCaseLetter