Omar Martinez
Omar Martinez

Reputation: 708

Enable a VSIX extension in a certain language?

Is there a method to detecting the current programming language and disabling an extension based on that language?

I'm creating a VSIX package that is only compatible in a C++ build. I can programmatically detect the current programming language and respond to unsupported languages and not open my dialog box, but i feel like there should be a property or something that would enable/disable an extension in a certain language.

Upvotes: 3

Views: 440

Answers (1)

Sergey Vlasov
Sergey Vlasov

Reputation: 27930

You can create a custom UI context rule for C++ and use it to load your package. It looks like this for C# and VB:

[ProvideAutoLoad(UIContexts.LoadContext)]
[ProvideUIContextRule(UIContexts.LoadContext,
    "RightFileTypeOpen",
    "(CSharpFileOpen | VBFileOpen)",
    new[] { "CSharpFileOpen", "VBFileOpen" },
    new[] { "ActiveEditorContentType:CSharp", "ActiveEditorContentType:Basic" })]

See How to: Use Rule-based UI Context for Visual Studio Extensions on MSDN and Mads Kristensen's sample for more details.

Upvotes: 4

Related Questions