Skip to content

Gendarme.Rules.Maintainability.AvoidAlwaysNullFieldRule(2.10)

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

AvoidAlwaysNullFieldRule

Assembly: Gendarme.Rules.Maintainability
Version: 2.10

Description

A type has a private field whose value is always null.

Examples

Bad example:

internal sealed class Bad {
    private List<int> values;
    public List<int> Values {
        get {
            return values;
        }
    }
}

Good example:

internal sealed class Good {
    private List<int> values = new List<int>();
    public List<int> Values {
        get {
            return values;
        }
    }
}

Notes

  • This rule is available since Gendarme 2.4
Clone this wiki locally