Share via


ProvideLanguageExtensionAttribute Class

Associates a file extension with a particular language service.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Shell.ProvideLanguageExtensionAttribute

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideLanguageExtensionAttribute _
    Inherits RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideLanguageExtensionAttribute : RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = true)]
public ref class ProvideLanguageExtensionAttribute sealed : public RegistrationAttribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type ProvideLanguageExtensionAttribute =  
    class 
        inherit RegistrationAttribute 
    end
public final class ProvideLanguageExtensionAttribute extends RegistrationAttribute

The ProvideLanguageExtensionAttribute type exposes the following members.

Constructors

  Name Description
Public method ProvideLanguageExtensionAttribute(String, String) Initializes a new instance of the ProvideLanguageExtensionAttribute attribute, using the specified language service GUID.
Public method ProvideLanguageExtensionAttribute(Type, String) Initializes a new instance of the ProvideLanguageExtensionAttribute attribute, using the type of your language service class.

Top

Properties

  Name Description
Public property Extension Returns the associated file extension.
Public property LanguageService Returns the language GUID.
Public property TypeId Gets the current instance of this attribute. (Inherited from RegistrationAttribute.)

Top

Methods

  Name Description
Public method Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public method Register Puts the file extension and language service GUID into the registry. (Overrides RegistrationAttribute.Register(RegistrationAttribute.RegistrationContext).)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method Unregister Removes the file extension and language service GUID from the registry. (Overrides RegistrationAttribute.Unregister(RegistrationAttribute.RegistrationContext).)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)

Top

Remarks

This user-defined C# attribute is used to register with Visual Studio a file extension for a particular language service. This attribute puts the necessary information into the assembly's metadata that is later retrieved and used by regpkg.exe. You must still register the language service itself; this attribute only makes the association between the file extension and the language service. For more information, see Registering VSPackages.

You can use multiple instances of this attribute to associate multiple file extensions with your language service.

The registry key that is affected by this attribute exists under the Visual Studio registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[X.Y]\
  Languages\
    File Extensions\
      [FileExtension]\
        (Default) = RG_SZ: [LanguageServiceGuid]

where:

  • [X.Y] is a Visual Studio version number such as 8.0 or 8.0exp.

  • [FileExtension] is a string containing the file extension with the leading period; for example, "myext".

  • [LanguageServiceGuid] is the GUID of your language service; for example, {B614A40A-80D9-4FAC-A6AD-FC2868FFF7CD}.

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

Use this attribute on your VSPackage to associate a file extension with your language service.

Examples

This example shows how to associate the file extension ".myext" with a language service.

Note

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
{
    [ProvideLanguageExtension(typeof(MyLanguageService), ".myext")]
    public class MyLanguagePackage : Package
    {
    }
}

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

Microsoft.VisualStudio.Shell Namespace