Friday, May 30, 2014

CA2214 : Do not call overridable methods in constructors Workaround

When you seriously take .net code analysis you may either try to suppress them or try to fix it. There is one such code analysis review if have override or virtual method call in constructor.

When an object written in C# is constructed, what happens is that the initializers run in order from the most derived class to the base class, and then constructors run in order from the base class to the most derived class
Problem - Constructor has call to override method.

 Workaround :- Add Sealed


Post a Comment