如何更改默認Generate Method Stub行爲VISAUL工作室與機體產生方法如何更改「生成方法存根」在VS中拋出NotImplementedException?
throw new NotImplementedException();
,而不是
throw new Exception("The method or operation is not implemented.");
如何更改默認Generate Method Stub行爲VISAUL工作室與機體產生方法如何更改「生成方法存根」在VS中拋出NotImplementedException?
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。
您可以通過編輯代碼段文件更改生成代碼: C:\ Program Files文件\微軟的Visual Studio 8個\ VC#\片段\ 1033 \重構\ 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>
還有另外一個原因:FxCop的捕捉拋出「異常」的「NotImplementedException」扔情況下任何人的情況和標誌,但是是可以接受的。
我其實很喜歡默認行爲,因爲它確實有這種區別。 NotImplementedException不是在您通過代碼工作時引發的臨時異常。它意味着「我的意思是,我真的不會執行這件事情」。如果按照原來的方式離開Codegen,那麼很容易區分代碼中的「我將會回來」這一部分,這些部分來自「我決定不做這個」位。
那麼你可以創建自己的NotYetImplementedException或WillNeverImplementThisMethodException或MissingCodeHereException或WillFixInNextVersionException :) – 2009-03-09 22:57:50