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
'Usage
Dim instance As CodeClass2
[GuidAttribute("295ADCD4-B052-49EE-934E-C6B36862A7C6")]
public interface CodeClass2 : CodeClass
[GuidAttribute(L"295ADCD4-B052-49EE-934E-C6B36862A7C6")]
public interface class CodeClass2 : CodeClass
public interface CodeClass2 extends CodeClass

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

' 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

CodeClass2 Members

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#)