I was involved in a short side discussion about “should” fields be set to null in the Dispose method(s). I’m not sure what the impetus of the question was; but, if you read through the dispose pattern MSDN documentation (in most versions I believe) there’s a comment // Set large fields to null. in the implementation of the virtual Dispose method within the if(!disposed) block and after the if(disposing) block. But, that’s the only reference to setting fields to null during dispose. There’s nothing else that I’ve been able to find in MSDN with regard to setting fields to null. … Continue reading Dispose Pattern and “Set large fields to null”
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?