如何更改"生成方法存根"以在VS中抛出NotImplementedException?

Jak*_*urc 7 .net configuration visual-studio

如何在Visaul Studio中更改默认的Generate Method Stub行为以生成body的方法

throw new NotImplementedException();
Run Code Online (Sandbox Code Playgroud)

代替

throw new Exception("The method or operation is not implemented.");
Run Code Online (Sandbox Code Playgroud)

Sam*_*sel 8

取自:http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx

Visual Studio 2005支持定位1.0版本的紧凑框架.为了使紧凑框架的大小保持较小,它不包括桌面框架中存在的所有相同类型.其中一个未包含的类型是NotImplementedException.

您可以通过编辑代码段文件来更改生成的代码: C:\ Program Files\Microsoft Visual Studio 8\VC#\ Snippets\1033\Refactoring\MethodStub.snippet并将声明部分更改为以下内容:

        <Declarations>
            <Literal Editable="true">
                <ID>signature</ID>
                <Default>signature</Default>
            </Literal>
            <Literal>
                <ID>Exception</ID>
                <Function>SimpleTypeName(global::System.NotImplementedException)</Function>
            </Literal>
        </Declarations>
Run Code Online (Sandbox Code Playgroud)