Partager via


ProvideLanguageEditorOptionPageAttribute Class

Informs Visual Studio about a language service property page.

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

Syntax

'Déclaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideLanguageEditorOptionPageAttribute _
    Inherits ProvideOptionDialogPageAttribute
'Utilisation
Dim instance As ProvideLanguageEditorOptionPageAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideLanguageEditorOptionPageAttribute : ProvideOptionDialogPageAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = true)]
public ref class ProvideLanguageEditorOptionPageAttribute sealed : public ProvideOptionDialogPageAttribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type ProvideLanguageEditorOptionPageAttribute =  
    class
        inherit ProvideOptionDialogPageAttribute
    end
public final class ProvideLanguageEditorOptionPageAttribute extends ProvideOptionDialogPageAttribute

Remarks

This user-defined attribute (which is specific to C#) is used to provide information necessary to register a language service's option pages with Visual Studio. The values specified by this attribute are stored as metadata in the assembly. This metadata is later used by a program such as Regpkg.exe (part of the VSIP SDK) to create the corresponding registry keys and entries that tell Visual Studio about the language service's option pages.

There can be multiple instances of this attribute and each instance specifies a node or a property page. The attributes can appear in any order. If the property page GUID is specified then a property page is registered, otherwise it is a node that is registered.

The registry entries affected by the ProvideLanguageEditorOptionPageAttribute are found under the EditorToolsOptions registry key which in turn is located under the language service's registry key. The layout of the nodes and pages are directly reflected in the category tree as displayed in the Options dialog box. The following example of the registry entries shows one node that contains a property page and a property page at the same level as the node.

HKEY_LOCAL_MACHINE\
  SOFTWARE\
    Microsoft\
      VisualStudio\
        [X.Y]\
          Languages\
            Language Services\
              [language name]\
                EditorToolsOptions\
                  [OptionPage1]\
                    (Default) = reg_sz: [localized name resource ID]
                    Package   = reg_sz: [package GUID]
                    Page      = reg_sz: [page GUID]
                  [Node]\
                    (Default) = reg_sz: [localized name resource ID]
                    Package   = reg_sz: [package GUID]
                    [OptionPage2]\
                      (Default) = reg_sz: [localized name resource ID]
                      Package   = reg_sz: [package GUID]
                      Page      = reg_sz: [page GUID]

The category tree in the Options dialog box for the above example would look something like this:

[+] Text Editor
  [+] [language name (localized)]
      [ ] [OptionPage1 (localized name)]
      [+] [Node (localized name)]
          [ ] [OptionPage2 (localized name)]

The following user-defined attributes are used for language services:

Attribute

Description

ProvideLanguageServiceAttribute

Registers the language service with Visual Studio and specifies what features are supported.

ProvideLanguageExtensionAttribute

Associates a file extension with the language service.

ProvideLanguageEditorOptionPageAttribute

Specifies a property node or page for the Options dialog box specific to the language service.

ProvideLanguageCodeExpansionAttribute

Specifies location information to support code snippets in the language service.

ProvideServiceAttribute

Registers a language service as a Visual Studio service. All services supplied in managed code use this attribute.

Notes to Implementers

This attribute class cannot be inherited from so there is nothing to implement.

Notes to Callers

This attribute class is typically applied to your primary VSPackage class, although it can appear on any class. This attribute class can appear multiple times and in any order, once for each property page and node in the property page tree.

Examples

This example shows how this user-defined attribute is used to register two property pages ("General" and "Indent") and a property page node ("Formatting") that contains the "Indent" property page. Note how the second parameter to the constructor specifies the position in the registry relative to the node.

Notes

Visual C# allows for a shorthand form of a user-defined attribute by dropping the "Attribute" part of the name. This shorthand form is used in this and all other examples throughout this class.

using Microsoft.VisualStudio.Shell;

namespace MyLanguagePackage
{
    internal class MyConstants
    {
        public const string languageName                = "MyLanguage";
        public const string formattingNodeResIDAsString = "#108";
        public const string generalPageResIDAsString    = "#109";
        public const string indentPageResIDAsString     = "#110";
    }

    [ProvideLanguageEditorOptionPage(MyConstants.languageName,
                                     "General",  // property page
                                     MyConstants.generalPageResIDAsString,
        // Optional language service properties
        OptionPageGuid = "{12434534-cecd-48e7-a866-45cad2e8b169}"
                                    )]
    [ProvideLanguageEditorOptionPage(MyConstants.languageName,
                                     "Formatting",  // property node
                                     MyConstants.formattingNodeResIDAsString
                                    )]
    [ProvideLanguageEditorOptionPage(MyConstants.languageName,
                                     @"Formatting\Indent",  // property page
                                     MyConstants.indentPageResIDAsString,
        // Optional language service properties
        OptionPageGuid = "{12434556-cecd-48e7-a866-45cad2e8b169}"
                                    )]

    class MyLanguagePackage
    {
    }
}

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Shell.ProvideOptionDialogPageAttribute
        Microsoft.VisualStudio.Shell.ProvideLanguageEditorOptionPageAttribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ProvideLanguageEditorOptionPageAttribute Members

Microsoft.VisualStudio.Shell Namespace