tags:

views:

119

answers:

1

Is there a way to change the code generated by a quick-fix in Resharper? It doesn't seem to be in the live templates.

I'd like the 'Create Property' quickfix for an unrecognized symbol to generate

public int MyProperty { get; set; }

Instead of:

protected int MyProperty
{
    get { throw new NotImplementedException(); }
    set { throw new NotImplementedException(); }
}
+1  A: 

Unfortunately you cannot define quick-fix behavior in Resharper. However, there are several options for what gets put inside the property body. Go to Resharper->Options->Languages->Common->Generated members - there are 3 options,

1) throw new NotImplemenatedException() [your example]

2) Return default value

protected int MyProperty
{
    get { return 0; }
    set { }
}

3) Not Compiled code

protected int MyProperty
{
    get
    {
    ???
    }
    set
    {
    ???
    }
}

2 is close to what you're looking for, but still not exactly.

I'd suggest instead using the "prop" Live Template - it will generate exactly what you're looking for, except that it won't do it automagically on an unrecognized symbol.

James Kolpack
Thanks! I was afraid that was the answer. VS 2008 will actually do exactly what I want with it's own quick fix-like menu, but I don't know what the keyboard shortcut is to trigger the menu, and I'm so used to doing everything with resharper. Oh well.
Lorin