Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change "Generate Method Stub" to throw NotImplementedException in VS?

How can I change default Generate Method Stub behavior in Visaul Studio to generate method with body

throw new NotImplementedException();

instead of

throw new Exception("The method or operation is not implemented.");
like image 444
Jakub Šturc Avatar asked Sep 05 '08 15:09

Jakub Šturc


1 Answers

Taken from: http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx

Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types that is not included is NotImplementedException.

You can change the generated code by editing the code snippet file: C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Refactoring\MethodStub.snippet and changing the Declarations section to the following:

        <Declarations>
            <Literal Editable="true">
                <ID>signature</ID>
                <Default>signature</Default>
            </Literal>
            <Literal>
                <ID>Exception</ID>
                <Function>SimpleTypeName(global::System.NotImplementedException)</Function>
            </Literal>
        </Declarations>
like image 76
Sam Wessel Avatar answered Sep 28 '22 11:09

Sam Wessel