Implement Members for a single missing property.

I have a class that implments an interface:

public interface IFoo{
     string Description{get;set;}
     int FooId{get;set;}
}

public class Foo : IFoo{
}

If I use Alt+Enter to implement the members from IFoo the Generate dialog box is displayed for Implement Members (allowing me the option to "Implement As", "Properties As", etc.) This is expected behavior.

However, let's say I already had FooId implemented and added Description at a later time:

public interface IFoo{
     string Description{get;set;}
     int FooId{get;set;}
}

public class Foo : IFoo{
     private int _fooId;

     public int FooId{
          get{return _fooId;}
          set{_fooId = value;}
}

When I use Alt+Enter, no dialog box is displayed and the Description property is implemented as:

public interface IFoo{
     string Description{get;set;}
     int FooId{get;set;}
}

public class Foo : IFoo{
     private int _fooId;

     public string Description{
          get{throw new NotImplementedException();}
          set{throw new NotImplementedException();}
     }

     public int FooId{
          get{return _fooId;}
          set{_fooId = value;}
}

IMHO, this is unexpected behavior. Shouldn't the Generate dialog box be displayed so I can have the option to determine the action?

1 comment

Hello William,

Yes, when there's only one member to implement the 'Implement members' quick
fix uses the default implementation and doesn't show a dialog. As a workaround,
you can invoke ReSharper | Edit | Generate -> Missing members inside the
'Foo' class and choose desired implementation. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I have a class that implments an interface:

public interface IFoo{
string Description{get;set;}
int FooId{get;set;}
}
public class Foo : IFoo{
}
If I use Alt+Enter to implement the members from IFoo the Generate
dialog box is displayed for Implement Members (allowing me the option
to "Implement As", "Properties As", etc.) This is expected behavior.

However, let's say I already had FooId implemented and added
Description at a later time:

public interface IFoo{
string Description{get;set;}
int FooId{get;set;}
}
public class Foo : IFoo{
private int _fooId;
public int FooId{
get{return _fooId;}
set{_fooId = value;}
}
When I use Alt+Enter, no dialog box is displayed and the Description
property is implemented as:

public interface IFoo{
string Description{get;set;}
int FooId{get;set;}
}
public class Foo : IFoo{
private int _fooId;
public string Description{
get{throw new NotImplementedException();}
set{throw new NotImplementedException();}
}
public int FooId{
get{return _fooId;}
set{_fooId = value;}
}
IMHO, this is unexpected behavior. Shouldn't the Generate dialog box
be displayed so I can have the option to determine the action?

---
Original message URL:
http://devnet.jetbrains.net/message/5318592#5318592



0

Please sign in to leave a comment.