DefaultPropertyValue Mutator

Mutator that takes initializes a property to the value specified in the DefaultValueAttribute attribute.
  • Defined in: CciSharp.DefaultPropertyValue.dll

Example

  • original code
using System.ComponentModel;

class Foo {
    [DefaultValue(10)]
    public int Value {get; private set;}
    public Foo() { }
}
  • rewritten code
class Foo {
    [DefaultValue(10)]
    public int Value {get; private set;}
    public Foo() {
        this.Value = 10;
    }
}

Requirements:

  • an non-virtual instance auto-property with a setter
  • marked with a System.ComponentModel.DefaultValueAttribute.
  • the attribute argument must match the property type

Last edited Dec 30, 2009 at 8:42 AM by pelikhan, version 2

Comments

No comments yet.