Featured post
visual studio 2010 - Tool for examining potential casting problems in C# -
i have following situation on hands. in project work on have abstract class a has 2 descendants, a_concrete1 , a_concrete2. these 2 around time now.
the time has come add third descendant, a_concrete3. problem is, lot of time in existing codebase you'll find that:
a instance; // ... // assignment of instance // ... if (!(a a_concrete1)) a_concrete2 = (a_concrete2)a;
so now, when a has more 2 descendants, code broken , fail @ runtime.
my question is: how locate these situations automatically fix them? best way/tool it? tried use resharper, doesn't provide casting analysis. i'd glad hear suggestions , pointers on one.
thanks in advance
the best way have methods in (that might overridden in subclasses) , code given use call methods of a, , never cast either subclass. way won't have again.
probably find in files (the toolbar button features binoculars on file folder) best way find (a_concrete2)
, is a_concrete1
. don't in there , replace if bunch of ifs - change it's more appropriate base class.
- Get link
- X
- Other Apps
Comments
Post a Comment