Fix loading of extensions referencing Engine API v3.0.0 #813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #807. This is a pretty unsatisfying fix to the problem. It feels like we're going down a rabbit hole, but I'm struggling to come up with a cleaner solution.
I'd appreciate some feedback on the approach, or any ideas of other solutions.
Root cause
Since Engine version 3.0, the nunit.engine.api.dll assembly has not had the version number incremented. We've intended to only make what we thought were backwards-compatible changes to this assembly, however we've recently found that these changes have actually been causing a number of issues: ref: #6, #424, #800.
There seems to be two viable solutions to this problem: 1) Stop making any changes to nunit.engine.api.dll or 2) start versioning the assembly when changes are made. I personally consider option 1 to be too restrictive to future development.
For that reason, we started versioning nunit.engine.api.dll in v3.12-beta1.
Extension loading issue
Issue #807 highlighted that changing the version number of nunit.engine.api.dll had broken extension loading, for the NUnit-Org packaged extensions. The reason for this is that these extensions reference nunit.engine.api v3.0, but are not packaged with that assembly. Previously, this hadn't caused a problem as api v3.0 was always supplied with the engine, however with the above change this is no longer the case.
Workaround-fix
This PR works around the above problem by forcing nunit.engine.api.dll v3.0 to always resolve to the same version as the engine, which allows the existing extensions to still be loaded.
I think this is acceptable as it's restricted to only apply to nunit.engine.api v3.0, which will be the only version affected by this issue, once we start incrementing the assembly version. It should also only affect cases where the engine is loading the API assembly itself, which as far as I can think, would only be in an extension loading scenario.
Interim "proper" fix
Extensions should start packaging their referenced version of nunit.engine.api.dll alongside the extension assembly.
v4 fix
For v4, I think we should split the extension API off from the main API assembly used for controlling the engine. The former is stable and sees a very limited number of changes, whereas the latter we wish to change more regularly. This is touched on in #770. Extensions should also continue to package the appropriate API version.
Would appreciate all thoughts on this - I've not found it a nice problem to reason about...