Hi Paulo,
I completely agree with the article you sent. But as far as I can say, Eric Lippert did not recommend to always override all virtual methods. Instead I think he suggests:
- if you are a library developer, you should be extra careful when you are adding new overrides, because they could be breaking changes and you should update the version of your library accordingly, so that your consumers know they need to recompile and retest.
- If you are an application developer, you should
- test your application thoroughly and see if it breaks when the dependencies are changed, or
- simplify your dependency chain, or use different way to reuse and organize code, not inheritance
I think this scenario is an excellent candidate for a binary analysis rule on compiled assemblies (which we cannot do yet, unfortunately) – to check if the code in an assembly is skipping virtual methods in the hierarchy chain. This way you will be absolutely certain that something is not right and you need to take the needed measures (e.g. recompile and upgrade dependencies).
Lately we are trying to reduce the noise from our rules to the maximum, so that our customers will see only actual problems, not potential caveats. Forcing to override every possible virtual method will generate a lot of noise, because in the majority of the cases the developers don’t have to care about their dependencies in the middle adding overrides.
All the best,
Valeri