Closed jcansdale closed 6 years ago
When executing ad-hoc methods using Test With > In-Proc (VS SDK), methods with MEF and VS service parameters are supported.
Test With > In-Proc (VS SDK)
For example you could write the following method that takes a MEF parameter:
void Go([Import(typeof(SVsServiceProvider))] IServiceProvider sp) { var dte = (DTE)sp.GetService(typeof(DTE)); Console.WriteLine(dte.FileName); }
You could also do the same by accepting a VS service interface directly:
void Go(DTE dte) { Console.WriteLine(dte.FileName); }
I'd like to add support for MEF components that use importing constructors.
For example, I'd like to be able to target the Go method here:
Go
[Export] class MyComponent { IServiceProvider sp; [ImportingConstructor] MyComponent([Import(typeof(SVsServiceProvider))] IServiceProvider sp) { this.sp = sp; } void Go() { Console.WriteLine(dte.FileName); } }
That way I could try things on my MEF components with very few changes. 😄
NOTE, my use of [Import(typeof(SVsServiceProvider))] IServiceProvider sp is simply an example MEF parameter and not at all recommended!
[Import(typeof(SVsServiceProvider))] IServiceProvider sp
When executing ad-hoc methods using
Test With > In-Proc (VS SDK)
, methods with MEF and VS service parameters are supported.For example you could write the following method that takes a MEF parameter:
You could also do the same by accepting a VS service interface directly:
I'd like to add support for MEF components that use importing constructors.
For example, I'd like to be able to target the
Go
method here:That way I could try things on my MEF components with very few changes. 😄
NOTE, my use of
[Import(typeof(SVsServiceProvider))] IServiceProvider sp
is simply an example MEF parameter and not at all recommended!