When an assembly exposes a superfluous (but missing) dependency, is there a clean way to squelch or ignore it?
Scenario:
Some app uses a FooUtil
class, in CoolAssembly.dll
. The only methods of concern are FooUtil.AwesomeMethod1
and FooUtil.AwesomeMethod2
, both of which only have primitive-typed parameters, and both of which return void.
FooUtil
implements IFooUtil
, which publicly exposes .ProblematicMethod
, a method that returns a CrazyNamespace.Bar
. CrazyNamespace
is defined in an assembly that's not available.
Now I could probably disassemble FooUtil
and rebuild it without the unneeded dependencies, but that's the nuclear option, and I'd like to avoid it. So...
- Is there any way to simply hide the leaked dependency from the consuming app, or ignore it within the app, provided the leaked type isn't referenced anywhere in any possible call stack?
- If not, is it possible to redirect the dependency to a fake for
CrazyNamespace
that only exposes dummy substitutes forFooUtil's
leaked type dependencies?
I assume that #2 could get hairy if the dependency chain gets deep or tangled, but that's out of my control. I can't know everything that CrazyNamespace.Bar
depends on, but logically I should only need to worry about the subset that's publicly exposed (and/or nonpublicly consumed) by FooUtil
. If #2 is possible in principle, then is the extent of FooUtil's
dependence discoverable? (I'm thinking of method signatures consumed from nonpublic call sites.)