有什么方法可以阻止Visual Studio在新函数上添加"throw new NotImplementedException"?导致名称空间与Unity冲突 [英] Any way to stop Visual Studio adding 'throw new NotImplementedException' on new functions? Causes namespace conflicts with Unity
问题描述
是的,我知道通常这是一种好习惯,但是Unity中的问题是它会导致添加系统名称空间,这会破坏多个Unity类(例如Random),除非我完全限定了它们的乏味:).有什么办法可以禁止它添加抛出?我尝试为其寻找代码段,但已绘制了一个空白.在键入"DoSomething();"后从Alt-Enter执行生成方法"时会发生这种情况
Yes, I know this is good practise normally but the problem in Unity is it causes the System namespace to be added which breaks several Unity classes such as Random unless I fully qualify them which is tedious :). Is there any way to disable it from adding the throw? I've tried searching for a snippet for it but have drawn a blank. This happens when doing 'Generate Method' from Alt-Enter after typing in 'DoSomething();'
推荐答案
是的,您可以通过更改创建默认代码的代码段来更改此默认行为.该代码段位于以下位置:(caveat ...这将在VS2017中对其进行全面更改)
Yes, you can change this default behavior by changing the snippet that creates it. That snippet is located at the following location: (caveat...this will change it across the board for VS2017)
C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC#\ Snippets \ 1033 \ Refactoring \ MethodStub.snippet
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC#\Snippets\1033\Refactoring\MethodStub.snippet
这篇关于有什么方法可以阻止Visual Studio在新函数上添加"throw new NotImplementedException"?导致名称空间与Unity冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!