Skip to content

Gendarme.Rules.Design.AvoidVisibleFieldsRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

AvoidVisibleFieldsRule

Assembly: Gendarme.Rules.Design
Version: git

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.

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally