Is there any way to change the default override method autogenerated by visual studio? If I implement an abstract class by doing following:
Visual Studio generates the following code:
public override void OverrideMethod() => throw new NotImplementedException();
Can I edit this template, so Visual Studio generates an "normal" method body instead an expression body?
public override void OverrideMethod()
{
throw new NotImplementedException("not implemented");
}
In Visual Studio under
Tools > Options > Text Editor > C# > Code Style > General
You can change "Use expression body for methods" to never.
Note that this also changes all of the code generation that would have generated expression bodies such as automatically implementing an interface.
Also, if you have a method that you want to convert from an expression body to a block body, or visa versa, simply press Ctrl+.
on the method and you will get the quick action to automatically convert it.