Open Therzok opened 5 years ago
Have tried multiple ways to fix this, but I'm hitting some roadblocks.
There are scenarios where we want to either use the IDE type or a type defined in a test assembly. In those cases, we cannot solve both - we have 2 exports for one given type.
I'm trying to figure out if we can somehow integrate DelegatingExportProvider, where we use bait-and-switch depending on what the test fixture is annotated with, but not sure it's the right approach.
@alanmcgovern @redth @abock how do you imagine MEF 'just working' in unit tests? There's a plethora of cases to cover - mocked exports, real IDE exports, mixed ones. I'd like to understand the requests better before I try and overengineer a solution for this.
I.e. Roslyn has a few cached ExportProviders, but doesn't allow registering arbitrary assemblies: http://source.roslyn.io/#Roslyn.Services.Test.Utilities/TestExportProvider.cs,19
Ignore my previous comment.
Found an interesting bit here: http://source.roslyn.io/#Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests/EventHookup/EventHookupTestState.cs,39
Which then goes to ExportProviderCache.
But nothing is automated, in the terms of creating the composition itself: http://source.roslyn.io/#Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests/CodeModel/VisualStudioTestExportProvider.cs,16
So the whole idea is to have different export providers which just add your parts.
Currently, there is no way to define a class in unit tests that allows for MEF composition.
Introduce a special CompositionManager implementation which also adds the current test assembly and its dependencies into the MEF graph.
Need to design how to switch between the IDE and the Test catalogs.