C#


ROSLYN.USAGE.CA2211 : Non-constant fields should not be visible (C#)

See Roslyn-Detected C# Warning Classes for more information.

Summary

Static fields that are neither constants nor read-only are not thread-safe. Access to such a field must be carefully controlled and requires advanced programming techniques to synchronize access to the class object.

This check corresponds to Roslyn rule CA2211. For full rule details, see the Microsoft website: CA2211.

Properties

Class Name Non-constant fields should not be visible (C#)
Significance reliability
Mnemonic ROSLYN.USAGE.CA2211
Categories None
Availability Available for C# only.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Non-constant fields should not be visible (C#)"

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.