“Virtual method call from constructor” What Could Go Wrong?

If you’ve used any sort of static analysis on source code you may have seen a message like “Virtual method call from constructor”.  In FxCop/Visual-Studio-Code-Analysis it’s CA2214 “Do not call overridable methods in constructors”.  It’s “syntactically correct”; some devs have said “what could go wrong with that”.  I’ve seen this problem in so many places, I’m compelled to write this post. I won’t get into one of my many pet peeves about ignoring messages like that and not educating yourself about ticking time bombs and continuing in ignorant bliss; but, I will try to make it more clear and hopefully … Continue reading “Virtual method call from constructor” What Could Go Wrong?

Code Analysis: How to Correctly Resolve CA1300 – "Specify MessageBox Options"

This is the first installment of what I hope to be many short bits of guidance about correctly resolving some of the more complex warnings coming out of FxCop and Code Analysis. The CA1300 warning is specifically about the right-to-left or left-to-right reading order of a message box.  The documentation for the warning alludes that a message box doesn't automatically inherit the containing form's reading order or the reading order from the user's current culture.  Although, I can't find any documentation that confirms either. In any case, this is a rather complex warning to resolve, you possibly have to traverse the form's … Continue reading Code Analysis: How to Correctly Resolve CA1300 – "Specify MessageBox Options"