Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In ReSharper 9, how to generate autoproperties from missing members?

In ReSharper 8, when a class was missing interface members (properties), I would Alt+Enter and select "Implement Missing Members", which would generate autoproperties like this:

public class MyClass : IHasId {
    public int Id { get; set; }
}

However, in ReSharper 9, the following is generated:

public class MyClass : IHasId {
    public int Id {
        get { throw new System.NotImplementedException(); }
        set { throw new System.NotImplementedException(); }
    }
}

I have set R# to create automatic properties under "Member Generation", still no effect.

Is this a bug, or am I missing something?

like image 480
Geir Sagberg Avatar asked Jan 08 '15 10:01

Geir Sagberg


1 Answers

It seems there's some odd options at work here that impact each other.

Do this:

Navigate inside the class (ie. not on the squigglies on the class or interface), and hit Alt+Insert, for generate code, then select "Missing Members".

In the dialog that pops up, only change an option at the bottom, to generate automatic properties:

ReSharper 9: Implement missing members

Then OK out that dialog, note that I didn't pick any items to actually implement. Then try Alt+Enter on the class/interface again.

This seems odd to say the least, but now at least you can "fix" it.

like image 67
Lasse V. Karlsen Avatar answered Oct 25 '22 00:10

Lasse V. Karlsen