Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top