Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Visual Studio services to be passed into constructor for instance methods #130

Open
jcansdale opened this issue Jul 10, 2018 · 0 comments

Comments

@jcansdale
Copy link
Owner

jcansdale commented Jul 10, 2018

MEF importing constructors are now supported, but a little ceremony is required to use with Visual Studio services.

For example, it's now possible to do the following:

[Export]
class DteTests
{
    DTE dte;

    [ImportingConstructor]
    Foo(SVsServiceProvider sp)
    {
        this.dte = (DTE)sp.GetServiceProvider(typeof(DTE));
    }

    void Test()
    {
        Console.WriteLine(dte.FileName);
    }
}

It would be more convenient if we could instead do this:

class DteTests
{
    DTE dte;

    Foo(DTE dte)
    {
        this.dte = dte;
    }

    void Test()
    {
        Console.WriteLine(dte.FileName);
    }
}

There are other ways, but this could be a handy shortcut if a little setup is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant