Export (0) Print
Expand All

CodeClass2 Interface

Represents a class in source code.

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

public interface CodeClass2 : CodeClass

The CodeClass2 type exposes the following members.

Public propertyAccessSets or gets the access attributes of this code class.
Public propertyAttributesGets a collection of all of the attributes for the code class.
Public propertyBasesGets a collection of classes from which this code class derives.
Public propertyChildrenGets a collection of objects contained within this code class.
Public propertyClassKindInfrastructure. Microsoft Internal Use Only.
Public propertyCollectionGets the collection contained within the code class.
Public propertyCommentSets or gets the comment associated with the code class.
Public propertyDataTypeKindSets of gets the relationship of this class with other classes.
Public propertyDerivedTypesGets a collection of objects derived from the code class. Not implemented in Visual C#.
Public propertyDocCommentGets or sets the document comment for the code class.
Public propertyDTEGets the top-level extensibility object.
Public propertyEndPointGets the edit point that is the location of the end of the code class.
Public propertyExtenderReturns the requested Extender object if it is available for the code class. Not implemented in Visual C#.
Public propertyExtenderCATIDGets the Extender category ID (CATID) for the code class. Not implemented in Visual C#.
Public propertyExtenderNamesGets a list of available Extenders for the code class. Not implemented in Visual C#.
Public propertyFullNameGets the full path and name of the file of the code class.
Public propertyImplementedInterfacesGets a collection of interfaces implemented by the code class.
Public propertyInfoLocationGets the capabilities of the code model.
Public propertyInheritanceKindGets or sets a value indicating whether a class may be used to create a new class.
Public propertyIsAbstractSets or gets whether or not the code class is declared as abstract.
Public propertyIsCodeTypeGets a value indicating whether a CodeType object can be obtained from the code class.
Public propertyIsDerivedFromGets a value indicating whether the code class has another code class as its base.
Public propertyIsGenericGets a value indicating whether the current class or struct is a generic.
Public propertyIsSharedGets or sets the shared (static) status of the class.
Public propertyKindGets an enumeration indicating the type of class.
Public propertyLanguageGets the programming language used to author the class.
Public propertyMembersGets a collection of code elements contained by the class.
Public propertyNameSets or gets the name of the class.
Public propertyNamespaceGets a CodeNamespace object defining the parent namespace of the class.
Public propertyParentGets the immediate parent object of the class.
Public propertyPartialClassesInfrastructure. Microsoft Internal Use Only.
Public propertyPartsGets parts of a class.
Public propertyProjectItemGets the ProjectItem associated with the given object.
Public propertyStartPointGets a TextPoint object that defines the beginning of the class.

Public methodAddAttributeCreates a new attribute code construct and inserts the class in the correct location.
Public methodAddBaseAdds an item to the list of inherited objects.
Public methodAddClassCreates a new class in the specified code class.
Public methodAddDelegateCreates a new delegate in the specified class.
Public methodAddEnumCreates a new enumeration in the class.
Public methodAddEventAdds a class event.
Public methodAddFunctionCreates a new function in the class.
Public methodAddImplementedInterfaceAdds an interface to the list of inherited objects.
Public methodAddPropertyCreates a new property construct in the class.
Public methodAddStructCreates a new structure in the class.
Public methodAddVariableCreates a new variable in the class.
Public methodGetEndPointGets a TextPoint object that marks the end of the class.
Public methodGetStartPointGets a TextPoint object that defines the beginning of the class.
Public methodRemoveBaseRemoves an object from the list of bases.
Public methodRemoveInterfaceRemoves an interface from the list of implemented interfaces.
Public methodRemoveMemberRemoves a member of the class.

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.


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

[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 _
    If myClass1.ClassKind = _
    vsCMClassKind.vsCMClassKindMainClass Then
        For Each classPart In myClass1.Collection
    End If
End Sub

Community Additions

© 2014 Microsoft