I'm trying to develop a language service within Visual Studio, and so far I've been able to implement a basic Tagger for highlights and spans:
However, I wanted to take it a step further and add my own section under 'Text Editor' so that I can maintain Tab settings, and the like for the language (shown below):
I'm finding it difficult to find resources for Visual Studio extensibility online, as there's a lot you can do but knowing where to start is often difficult. I'm also interested in custom project/item services, but have similar issues with finding a sample.
It's possible I'm close as it is (due to the custom taggers), I just don't know what to decorate the exported types with, or I've got a lot of underlying work to do. Direction appreciated.
I found this blog post it has a lot of Visual Studio Extension project samples. Among them there is one project called Options Page – VS 2013 I think this is what you are looking for:
For your specific case you should tweak the following attributes in the class (taken from the example) OptionsPagePackage.cs
. Specifically these attributes:
Have "category" as second passed parameter (which correspond to the main category in the Tools menu).
[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string[] { "Change sample general options (C#)" })]
[ProvideProfileAttribute(typeof(OptionsPageGeneral), "Text Editor", "General Options", 100, 101, true, DescriptionResourceID = 100)]
[ProvideOptionPageAttribute(typeof(OptionsPageCustom), "Text Editor", "Custom", 100, 102, true, new string[] { "Change sample custom options (C#)" })]
[InstalledProductRegistration("Text Editor", "My Options Page (C#) Sample", "1.0")]
[Guid(GuidStrings.GuidPackage)]
public class OptionsPagePackageCS : Package
{
.....
}
The DescriptionResourceID (100,101,102 etc) are defined in the xml file VsPackage.resx
and will be used by the vsix installer to insert the labels in the tools menu:
<data name="100" xml:space="preserve">
<value>My Managed Options (C#)</value>
<comment>Options category</comment>
</data>
<data name="101" xml:space="preserve">
<value>My Options</value>
<comment>General page</comment>
</data>
<data name="102" xml:space="preserve">
<value>Custom</value>
<comment>Custom page</comment>
</data>
This is my attempt:
Just be cautious as using an existing Category will overwrite the existing one. As you can see in the picture there are no options for all the other languages.
EDIT:
As pointed out by Alexander to avoid overwriting the existing configuration (if one wants to add his category to an existing one in the Tools menu) backslash must be added to the category parameter in the attributes mentioned above. For Example:
[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string[] { "Change sample general options (C#)" })]
Becomes:
[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor\\MyOptionPage","General", 100, 101, true, new string[] { "Change sample general options (C#)" })]
In that case MyOptionPage will be a child of Text Editor and it won't overwrite the existing configuration.
hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With