The System.Windows.Input.ICommand interface has been Type Forwarded as of .NET 4.5 from being in PresentationCore.dll to System.dll. I have 2 issues:
How can I import this interface so I can use it as a return type of a property I am injecting into a class (don't need help with property injection, just type resolution/importing)?
How can I be sure that my resulting assembly will work on .NET 4 clients who don't have .NET 4.5 installed and as such do not have ICommand type forwarded to System.dll?
The code is intended to be used in a custom Fody weaver.
You have to handle it explicitly.
For example finding Action
which can exist in diff assemblies.
var msCoreLibDefinition = assemblyResolver.Resolve("mscorlib");
var msCoreTypes = msCoreLibDefinition.MainModule.Types;
var systemDefinition = assemblyResolver.Resolve("System");
var systemTypes = systemDefinition.MainModule.Types;
var actionDefinition = msCoreTypes.FirstOrDefault(x => x.Name == "Action");
if (actionDefinition == null)
{
actionDefinition = systemTypes.First(x => x.Name == "Action");
}