benjamin-bader / stiletto

Fast Dependency Injection for .Net, Mono, and MonoTouch
http://stiletto.bendb.com
Apache License 2.0
43 stars 14 forks source link

Fody weaver should detect weaver/library version mismatches #27

Open benjamin-bader opened 11 years ago

benjamin-bader commented 11 years ago

Currently, it fails with an unhelpful key-not-found stacktrace from StilettoReferences.cs. Nicht sehr gut.

benjamin-bader commented 11 years ago

More details on the nature of this problem:

StilettoReferences assumes that certain classes and methods are present in Stiletto.dll, and obtains references to them by name-matching, with strings. This is necessary to allow the same weaver to work on multiple platforms; otherwise, references to the .NET 4.0 version would be embedded in, say, a Windows Phone build where that library obviously would be neither available nor functional.

This issue happens when Stiletto is refactored, such as the rename from IPlugin to ILoader, without updating StilettoReferences; in this situation, obviously the missing types are not found. The problem is that the weaver does not gracefully handle itself, and the error presented offers no indication.

The solution has multiple components. For one, we need to start embedding version numbers in the Stiletto assemblies themselves; this ought to happen automatically. For another, the weaver needs to know the latest version it can handle, and needs to use that information to craft a useful error message.