Share via


CodeClass2 Interface

Represents a class in source code.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Syntax

'Declaration
<GuidAttribute("295ADCD4-B052-49EE-934E-C6B36862A7C6")> _
Public Interface CodeClass2 _
    Inherits CodeClass
[GuidAttribute("295ADCD4-B052-49EE-934E-C6B36862A7C6")]
public interface CodeClass2 : CodeClass
[GuidAttribute(L"295ADCD4-B052-49EE-934E-C6B36862A7C6")]
public interface class CodeClass2 : CodeClass
[<GuidAttribute("295ADCD4-B052-49EE-934E-C6B36862A7C6")>]
type CodeClass2 =  
    interface 
        interface CodeClass 
    end
public interface CodeClass2 extends CodeClass

The CodeClass2 type exposes the following members.

Properties

  Name Description
Public property Access Sets or gets the access attributes of this code class.
Public property Attributes Gets a collection of all of the attributes for the code class.
Public property Bases Gets a collection of classes from which this code class derives.
Public property Children Gets a collection of objects contained within this code class.
Public property ClassKind Infrastructure. Microsoft Internal Use Only.
Public property Collection Gets the collection contained within the code class.
Public property Comment Sets or gets the comment associated with the code class.
Public property DataTypeKind Sets of gets the relationship of this class with other classes.
Public property DerivedTypes Gets a collection of objects derived from the code class. Not implemented in Visual C#.
Public property DocComment Gets or sets the document comment for the code class.
Public property DTE Gets the top-level extensibility object.
Public property EndPoint Gets the edit point that is the location of the end of the code class.
Public property Extender Returns the requested Extender object if it is available for the code class. Not implemented in Visual C#.
Public property ExtenderCATID Gets the Extender category ID (CATID) for the code class. Not implemented in Visual C#.
Public property ExtenderNames Gets a list of available Extenders for the code class. Not implemented in Visual C#.
Public property FullName Gets the full path and name of the file of the code class.
Public property ImplementedInterfaces Gets a collection of interfaces implemented by the code class.
Public property InfoLocation Gets the capabilities of the code model.
Public property InheritanceKind Gets or sets a value indicating whether a class may be used to create a new class.
Public property IsAbstract Sets or gets whether or not the code class is declared as abstract.
Public property IsCodeType Gets a value indicating whether a CodeType object can be obtained from the code class.
Public property IsDerivedFrom Gets a value indicating whether the code class has another code class as its base.
Public property IsGeneric Gets a value indicating whether the current class or struct is a generic.
Public property IsShared Gets or sets the shared (static) status of the class.
Public property Kind Gets an enumeration indicating the type of class.
Public property Language Gets the programming language used to author the class.
Public property Members Gets a collection of code elements contained by the class.
Public property Name Sets or gets the name of the class.
Public property Namespace Gets a CodeNamespace object defining the parent namespace of the class.
Public property Parent Gets the immediate parent object of the class.
Public property PartialClasses Infrastructure. Microsoft Internal Use Only.
Public property Parts Gets parts of a class.
Public property ProjectItem Gets the ProjectItem associated with the given object.
Public property StartPoint Gets a TextPoint object that defines the beginning of the class.

Top

Methods

  Name Description
Public method AddAttribute Creates a new attribute code construct and inserts the class in the correct location.
Public method AddBase Adds an item to the list of inherited objects.
Public method AddClass Creates a new class in the specified code class.
Public method AddDelegate Creates a new delegate in the specified class.
Public method AddEnum Creates a new enumeration in the class.
Public method AddEvent Adds a class event.
Public method AddFunction Creates a new function in the class.
Public method AddImplementedInterface Adds an interface to the list of inherited objects.
Public method AddProperty Creates a new property construct in the class.
Public method AddStruct Creates a new structure in the class.
Public method AddVariable Creates a new variable in the class.
Public method GetEndPoint Gets a TextPoint object that marks the end of the class.
Public method GetStartPoint Gets a TextPoint object that defines the beginning of the class.
Public method RemoveBase Removes an object from the list of bases.
Public method RemoveInterface Removes an interface from the list of implemented interfaces.
Public method RemoveMember Removes a member of the class.

Top

Remarks

With the introduction of blueprints and partial classes, there may be more than one CodeClass object per class that gets compiled. There is one instance of a CodeClass object for each class contained in a file. The CodeClass2 object can determine if it represents a partial or complete class, and whether it is implemented as an XML blueprint or as code. Edits or additions to the CodeClass2 object may only be written into this portion (and file) of the class.

Note

The values of code model elements such as classes, structs, functions, attributes, delegates, and so forth can be non-deterministic after making certain kinds of edits, meaning that their values cannot be relied upon to always remain the same. For more information, see the section Code Model Element Values Can Change in Discovering Code by Using the Code Model (Visual Basic).

Examples

[Visual Basic]

' Macro code.
Sub CodeClass2Example()
    ' Iterates through the main class and
    ' lists its parts.
    Dim sel As TextSelection
    Dim myClass1 As EnvDTE80.CodeClass2
    Dim classPart As EnvDTE80.CodeClass2

    sel = applicationObject.ActiveDocument.Selection
    myClass1 = sel.ActivePoint.CodeElement _
    (vsCMElement.vsCMElementClass)
    If myClass1.ClassKind = _
    vsCMClassKind.vsCMClassKindMainClass Then
        For Each classPart In myClass1.Collection
            MsgBox(classPart.Name)
        Next
    End If
End Sub

See Also

Reference

EnvDTE80 Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples

Discovering Code by Using the Code Model (Visual Basic)

Discovering Code by Using the Code Model (Visual C#)