none
Visual Studio 2015 Implement Interface snippet not working RRS feed

  • Question


  • I am trying to get Visual Studio 2015 (14.0) to use auto properties when implementing an interface using refactoring for C#.

    In the past, this worked: http://codeimpossible.com/2010/11/29/Make-Implement-Interface-use-auto-properties/

    With Visual Studio 2015, this snippet is ignored and the throw new NotImplement

    By default:

    public object SomeProperty
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }



    What I want Implement Interface to script out:

    public object MyProperty { get; set; }




    Tuesday, September 15, 2015 12:19 PM

Answers

  • Hey John!

    The short answer to your question is: "no, it is not possible". Visual Studio 2015 uses Roslyn for it's refactoring, which means the snippets are no longer used when invoking the "Implement interface" refactoring command. Hence, you can change the snippets all you want, they aren't picked up by the current refactoring engine.


    Thanks!!
    Jan

    Tuesday, June 14, 2016 12:42 PM

All replies

  • Hi John,

    For this VS behavior, I think you could give a feedback to Microsoft Visual Studio Connect Site, and check whether they have good workaround for you, Microsoft engineers will evaluate this seriously.

    With regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 18, 2015 8:57 AM
    Moderator
  • Thanks Angie for the direction, but it really isn't an answer for us to run around from one Microsoft site to another with this stuff. 

    I'm pretty sure that this is on topic here.

    Marking this as answered will end up indexed on search engines for others looking for an answer, but it isn't answered.


    I did post to the recommend board referencing this.
    Friday, October 2, 2015 12:55 AM
  • Was there ever a solution to this? I was watching an MVVM tutorial on the web and the presenter implemented an interface using a snippet (typed almost too fast to follow him). Never having implemented an interface that way before, I simply copied his keystrokes over and over to no avail. Since I was new at this, I figured I was doing something wrong. Thanks.
    Thursday, March 17, 2016 3:28 AM
  • Bump...
    Monday, May 16, 2016 4:52 PM
  • Hey John!

    The short answer to your question is: "no, it is not possible". Visual Studio 2015 uses Roslyn for it's refactoring, which means the snippets are no longer used when invoking the "Implement interface" refactoring command. Hence, you can change the snippets all you want, they aren't picked up by the current refactoring engine.


    Thanks!!
    Jan

    Tuesday, June 14, 2016 12:42 PM
  • Unfortunate that this little gem is gone!
    Thursday, August 25, 2016 1:50 PM
  • Hello,

    I'm using a find and replace macro like this as a workaround:

    Find:
    (\r|\n| |\t)+\{(\r|\n| |\t)+get(\r|\n| |\t)+\{(\r|\n| |\t)+throw(\r|\n| |\t)+new(\r|\n| |\t)+NotImplementedException\(\);(\r|\n| |\t)+\}(\r|\n| |\t)+set(\r|\n| |\t)+\{(\r|\n| |\t)+throw(\r|\n| |\t)+new(\r|\n| |\t)+NotImplementedException\(\);(\r|\n| |\t)+\}(\r|\n| |\t)+\}
    
    replace:
     {get;set;}
    
    

    Friday, January 27, 2017 6:32 AM