Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper quick-fix templates

Tags:

c#

resharper

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(); }
}
like image 852
Lorin Avatar asked Aug 20 '09 17:08

Lorin


1 Answers

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.

like image 112
James Kolpack Avatar answered Sep 19 '22 13:09

James Kolpack