Partager via


ProvideLanguageServiceAttribute.EnableFormatSelection Property

Determines if the language service supports automatic formatting of the source code.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)

Syntax

'Déclaration
Public Property EnableFormatSelection As Boolean
    Get
    Set
'Utilisation
Dim instance As ProvideLanguageServiceAttribute
Dim value As Boolean

value = instance.EnableFormatSelection

instance.EnableFormatSelection = value
public bool EnableFormatSelection { get; set; }
public:
property bool EnableFormatSelection {
    bool get ();
    void set (bool value);
}
member EnableFormatSelection : bool with get, set
function get EnableFormatSelection () : boolean
function set EnableFormatSelection (value : boolean)

Property Value

Type: System.Boolean
Returns true if formatting is supported; otherwise, returns false.

Remarks

A language service can support formatting source code which enhances the readability of the code. Formatting typically involves inserting white space at the beginning of each line to move it to the proper level of indentation. This formatting can occur when the user selects a command (Edit -> Advanced -> Format Selection or Edit -> Advanced -> Format Document) or it can be triggered automatically within the language service when a particular character is typed (for example, in C#, typing a closing brace '}' causes all the source between it and the corresponding opening brace '{' to be properly indented). The EnableFormatSelection property applies to any formatting.

This property is specific to the managed package framework (MPF).

The default is false when the corresponding registry entry is accessed through the LanguagePreferences class.

The registry entry looks like this:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[X.Y]\Languages\Language Services\
  [Language Name]\
    EnableFormatSelection = reg_dword: 0x00000001

Examples

    [ProvideLanguageService(typeof(MyLanguageService),           // Required
                            MyConstants.languageName,            // Required
                            MyConstants.languageNameResourceID,  // Required
        // Optional language service properties
        EnableFormatSelection = true,  // formatting is supported
                           )]

.NET Framework Security

See Also

Reference

ProvideLanguageServiceAttribute Class

ProvideLanguageServiceAttribute Members

Microsoft.VisualStudio.Shell Namespace