Working with legacy moderate size project. I have implemented one feature using Decorator pattern, and it works great except that it breaks crappy code that uses downcast from interface to implementation. The question is: is there any tool or compiler flag or something, that can help me find all cases of using downcast. It is ok for me to find all cases for all types.
I have some code to elaborate my problem:
there were
interface IComponent {}
class Concrete : IComponent {}
...
IComponent obj = new Concrete()
and now
interface IComponent {}
class Concrete : IComponent {}
class Decorator : IComponent
{
private IComponent _imp = new Concrete()
}
...
IComponent obj = new Decorator()
and bad code breaks on casting obj to Concrete, like (Concrete) obj.