-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Concurrency.NonConstantStaticFieldsShouldNotBeVisibleRule(2.10)
Sebastien Pouliot edited this page Jan 22, 2011
·
2 revisions
Assembly: Gendarme.Rules.Concurrency
Version: 2.10
This rule warns if a non-constant public static field is found. In a multi-threaded environment access to those fields must be synchronized.
Bad example:
class HasPublicStaticField {
public static ComplexObject Field;
}
Good example:
class FieldIsReadonly {
public readonly static ComplexObject Field = new ComplexObject();
}
class UseThreadStatic {
[ThreadStatic]
public static ComplexObject Field;
public static InitializeThread ()
{
if (Field == null)
Field = new ComplexObject ();
}
}
Note that this page was autogenerated (3/17/2011 9:31:58 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!