-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.BadPractice.AvoidVisibleConstantFieldRule(2.10)
Assembly: Gendarme.Rules.BadPractice
Version: 2.10
This rule looks for constant fields which are visible outside the current assembly. Such fields, if used outside the assemblies, will have their value (not the field reference) copied into the other assembly. Changing the field's value requires that all assemblies which use the field to be recompiled. Declaring the field as static readonly, on the other hand, allows the value to be changed without requiring that client assemblies be recompiled.
Bad example:
// if this fields is used inside another assembly then
// the integer 42, not the field, will be baked into it
public const int MagicNumber = 42;
Good example:
// if this field is used inside another assembly then
// that assembly will reference the field instead of
// embedding the value
static public readonly int MagicNumber = 42;
- This rule is available since Gendarme 2.0
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!