Enable a VSIX extension in a certain language?

414 views Asked by At

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.

1

There are 1 answers

2
Sergey Vlasov On BEST ANSWER

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.