How can I change default Generate Method Stub behavior in Visaul Studio to generate method with body
throw new NotImplementedException();
instead of
throw new Exception("The method or operation is not implemented.");
How can I change default Generate Method Stub behavior in Visaul Studio to generate method with body
throw new NotImplementedException();
instead of
throw new Exception("The method or operation is not implemented.");
There's another reason: FxCop catches instances of anybody throwing 'Exception' and flags it, but throwing instances of 'NotImplementedException' is acceptable.
I actually like the default behavior, because it does have this differentiation. NotImplementedException is not a temporary exception to be thrown while you're working your way through your code. It implies "I mean it, I'm really not going to implement this thing". If you leave the codegen the way it is, it's easy for you to differentiate in the code the "I will come back to this later" bits from "I've decided not to do this" bits.
Taken from: http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx
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: