We are using Visual Studio 2015 and Resharper Ultimate 2016.3.2.
Is there a way to get an error or warning if someone overrides a virtual method of a base class (C# in our case) but does not call the base class implementation? In most of the cases calling the base class is a must and for that few cases where I really don't want to call the base class I want to be able to disable the error or warning with a comment.
I want to make sure that no one forgets to call the base class and if it is really intended not to call the base class, that one has to write a comment stating why it is not intended here.
class A
{
public virtual void Something(){...}
}
class B : A
{
public override void Something()
{
base.Something();//everything fine. no error or warning.
someOtherCode...
}
}
class C : A
{
public override void Something()
{
<-- generate error or warning here
someOtherCode...
}
}
class D : A
{
public override void Something()
{
// ReSharper disable once ...: Reason why I don't want to call the base class
<-- No error or warning here because of the comment.
someOtherCode...
}
}