.net - 如何更改 "Generate Method Stub"以在 VS 中抛出 NotImplementedException?

标签 .net visual-studio configuration

如何更改默认设置 Generate Method Stub Visaul Studio 中的行为以生成带有主体的方法

throw new NotImplementedException();

代替
throw new Exception("The method or operation is not implemented.");

最佳答案

取自: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.



您可以通过编辑代码片段文件来更改生成的代码:
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>

关于.net - 如何更改 "Generate Method Stub"以在 VS 中抛出 NotImplementedException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46003/

相关文章:

ios - 处理构建短语中的不同配置后找不到有效的 GoogleService-Info.plist

c# - WPF - 组样式 : Can we only bind to the "Name" property?

c# - 在空 IEnumerable<int> 上为 FirstOrDefault() 返回 null?

C#密码生成器,生成多个密码

.net - 如何自动化 Outlook?

perl - 在 Perl 脚本中分离配置数据和脚本逻辑

intellij-idea - 如何配置 IntelliJ IDEA 从属性文件加载许可证服务器地址?

macos - Visual Studio 2015 Mac 代理未连接到 Macbook

c# - 尝试创建HttpWebRequest时,System.dll中发生了 'System.UriFormatException'类型的未处理异常

visual-studio - 链接来自另一个项目的所有 .obj 文件