3

I have and interface that I have made updates to. I would like to implement all my changes in my derived classes as auto properties, but they get implemented with the NotImplemented exception. Is there a way to set properties created by ReSharper 6 as autoproeprty?

DDiVita
  • 4,225
  • 5
  • 63
  • 117

2 Answers2

3

Currently there are two different ways to implement missing interface members.

The first is invoked by pressing Alt+Ins while in the body of the implementing class, and choosing Implement missing members. In the resulting dialog, you can choose that properties are implemented as autoproperties.

The second is invoked by pressing Alt+Enter while on the red squiggly of the definition statment of the implementing class, and choosing Implement members. The bodies of the generated members in this case are controlled by the setting in ReSharper | Options... | Languages | Common | Members Generation - where 'autoproperty' is not an option.

There is an open YouTrack issue to improve the UI in the second case to provide an autoproperty option - JetBrains have marked it as Critical, so it might make it into 6.1, else we'll have to wait for 7.

AakashM
  • 62,551
  • 17
  • 151
  • 186
  • Such a simple thing can be so complex and not fixed yet. Sad panda. – Syska Oct 20 '11 at 09:15
  • Upvote for Alt+Ins trick and issue link. Still, I find myself using R# templates more often to generate view model properties that raise property changed event etc. – angularsen Apr 19 '12 at 12:22
0

Here is a hacky workaround:

  1. Temporarily change the interface into a class.
  2. Make the desired property public and copy its definition to the clipboard
  3. Perform the Push Members Down refactoring which will copy the member into implementors.
  4. Revert the class back to being an interface and re-add (using paste) the property to the interface.

Having to do this sucks, but it works.

Mario
  • 2,229
  • 2
  • 21
  • 21