如何改变“生成方法存根”在VS中抛出NotImplementedException? [英] How to change "Generate Method Stub" to throw NotImplementedException in VS?

查看:814
本文介绍了如何改变“生成方法存根”在VS中抛出NotImplementedException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Visaul中更改默认生成方法存根行为Studio使用正文生成方法

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

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支持定位1.0版本的紧凑框架。为了使紧凑框架的大小保持较小,它不包括桌面框架中存在的所有相同类型。未包括的类型之一是NotImplementedException。

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 并将声明部分更改为以下内容:

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>

这篇关于如何改变“生成方法存根”在VS中抛出NotImplementedException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆