The many properties of ProvideLanguageServiceAttribute
The ProvideLanguageServiceAttribute
class has been with us for many years now. At least since it shipped as source code in the Visual Studio 2005 SDK. With more than two dozen properties, it’s easy to get lost trying to figure out which ones are meaningful and/or useful, and which ones are safe to ignore.
Like the other registration attributes, for Visual Studio 2010+ extension developers this class aids in the creation of a .pkgdef file for a VSPackage extension. Each property is associated with one or more entries in the file, and eventually corresponds to registry keys which can be queried by either Visual Studio itself or an extension. In the case of ProvideLanguageServiceAttribute
, the supported entries fall into the following categories.
- Some properties instruct Visual Studio to either enable or disable one or more standard options in the Tools → Options… → Text Editor → {language name} pages for the language being registered (aka the language options pages).
- Some properties set the default values for one or more standard options in the language options pages.
- Some properties control other special behavior of the Visual Studio editor.
- Some properties do not have any impact on Visual Studio itself, but do create registry entries that can be queried by an extension (more on these later).
- Some properties I am still unclear on, either because I have never used them or because they appear to have changed behavior or become obsolete for Visual Studio 2010+ extensions. (Hopefully I can eventually move items from this category to other categories.)
Enabling/disabling standard options
The following properties determine whether certain standard UI elements in the language options pages are visible and/or enabled.
EnableAdvancedMembersOption
. When set tofalse
, the Hide advanced members check box on the General language options page is disabled. The default value isfalse
. This option is closely related to both theShowCompletion
andHideAdvancedMembersByDefault
options described below.EnableLineNumbers
. When set tofalse
, the Line numbers check box on the General language options page is disabled. The default value istrue
.ShowCompletion
. When set tofalse
, all of the check boxes under Statement completion on the General language options page are disabled. The default value isfalse
.ShowDropDownOptions
. When set tofalse
, the Navigation bar check box on the General language options page is disabled. The default value isfalse
. Note: This behavior was observed in Visual Studio 2013, and differs substantially from the behavior described on MSDN. Users implementing this feature should set the property totrue
, and other users should leave the property unset for consistent behavior that matches MSDN.ShowSmartIndent
. When set tofalse
, the Smart radio box on the Tabs language options page is disabled. The default value isfalse
.
Specifying default options
The following properties determine the default values of language options.
DefaultToInsertSpaces
. When set totrue
, the Insert spaces option on the Tabs language options page is selected by default. When set tofalse
, the Keep tabs option is selected by default. The default value isfalse
.DefaultToNonHotURLs
.HideAdvancedMembersByDefault
. When set totrue
, the Hide advanced members box is checked by default on the General language options page. The default value isfalse
.
Controlling special behavior
The following properties control standard editor behavior which is not exposed through the standard language options pages.
RequestStockColors
. For MPF language services targeting versions of Visual Studio prior to 2010, this was a very important property for users implementing custom syntax highlighting items. When set tofalse
, Visual Studio will try to cast your implementation ofIVsLanguageInfo
to an instance ofIVsProvideColorableItems
to get information about the additional syntax highlighting colors. For Visual Studio 2010+ extensions, a much cleaner API is available by simply setting the property totrue
and exporting instances ofClassificationTypeDefinition
andEditorFormatDefinition
to support additional syntax highlighting colors. The default value isfalse
.SingleCodeWindowOnly
. When set totrue
, the Window → New Window command is disabled for editor windows created for this language. Note that this does not affect the behavior of the Window → Split command. The default value isfalse
(and should not be changed unless absolutely necessary).
Properties that do not impact Visual Studio
Many of the available properties set registry keys that do not directly impact Visual Studio at all. For users basing their language service implementations on the managed package framework (MPF), these properties control behavior provided by that framework. Since I no longer use this framework for language service implementations, I’ll omit the detailed descriptions of these properties.
AutoOutlining
CodeSense
CodeSenseDelay
EnableAsyncCompletion
EnableCommenting
EnableFormatSelection
MatchBraces
MatchBracesAtCaret
MaxErrorMessages
QuickInfo
ShowMatchingBrace