Skip to content

Gendarme.Rules.Design.AvoidVisibleFieldsRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

AvoidVisibleFieldsRule

Assembly: Gendarme.Rules.Design
Version: 2.10

Description

This rule fires if a type contains externally visible fields. Instead use a property which allows you to change the implementation without breaking binary compatibility with other assemblies.

Examples

Bad example:

public class Foo {
    public int Value;
}

Good example:

public class Foo {
    private int v;
    public int Value {
        get {
            return v;
        }
        set {
            v = value;
        }
    }
    

Notes

  • Prior to Gendarme 2.2 this rule was named AvoidPublicInstanceFieldsRule.
Clone this wiki locally