Some background...
i have a .net assembly (.net framework 4.6, fwiw) that runs as a plugin within a host application. The host application provides an API that the plugin uses to do its business, and it also provides an SDK containing reference assemblies which the plugin project uses at build time to compile the plugin.
At runtime, the host application is expected to be may be many versions ahead of when the plugin was built, and that is all fine, so long as the API it exposes through its SDK has not changed. (breaking changes will generate a new version of the SDK/API, and the host only supports plugins running at the current API version)
Now, I want to create a test that can verify that a current build of the host application has not changed the API, and fail accordingly if a breaking change is detected (in which case we would decide whether to rev the API version, or revert that particular change, etc…)
The problem I have is that while some API changes may be detected at load time (which is great, my test fails to load the plugin, and I'm done), many are not. Specifically, references to the host API from within various class methods in the plugin assembly are not resolved until the plugin method is actually executed.
For example, say my plugin has a method PluginMethod that calls some host method HostMethodA provided by HostClass in the host application, and in the current build of the host application, the name of the method HostMethodA is changed to HostMethodB.
In such a case, I am able to successfully load the plugin assembly, but am not able to detect that the reference to HostMethodA will fail at runtime unless I create an instance of the containing plugin class and actually execute PluginMethod.
I've tried about everything i can think of to get the references in the loaded plugin assembly to fully resolve, but short of actually executing the method, nothing quite gets me there.
It seems like there should be some method on an Assembly (or Type or MethodInfo) that would force the runtime to try and resolve all of the references within all of the methods in the assembly (or Type or Method) without having to execute every code path in the assembly. But I can find no such mechanism.
Alternatively, it would be sufficient if I could get a list of MemberInfo type items that represent the external references of the methods in the plugin assembly (assembly name, class::method, number and types of parameters would do) I could verify those against my current version of the host app. Can't really find a good way to do that either.
Thanks for reading this far, I greatly appreciate any suggestions.
Roger
Aucun commentaire:
Enregistrer un commentaire