CodeElements Interface

A collection of objects representing code constructs in a source file.

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

Syntax

'Declaration
<GuidAttribute("0CFBC2B5-0D4E-11D3-8997-00C04F688DDE")> _
Public Interface CodeElements _
    Inherits IEnumerable
[GuidAttribute("0CFBC2B5-0D4E-11D3-8997-00C04F688DDE")]
public interface CodeElements : IEnumerable
[GuidAttribute(L"0CFBC2B5-0D4E-11D3-8997-00C04F688DDE")]
public interface class CodeElements : IEnumerable
[<GuidAttribute("0CFBC2B5-0D4E-11D3-8997-00C04F688DDE")>]
type CodeElements =  
    interface 
        interface IEnumerable 
    end
public interface CodeElements extends IEnumerable

The CodeElements type exposes the following members.

Properties

  Name Description
Public property Count Gets a value indicating the number of objects in the CodeElements collection.
Public property DTE Gets the top-level extensibility object.
Public property Parent Gets the immediate parent object of a CodeElements collection.

Top

Methods

  Name Description
Public method CreateUniqueID Creates a programmatic identifier that does not collide with other identifiers in the scope and that follows the current language naming rules.
Public method GetEnumerator Returns an enumerator for items in the CodeElements collection.
Public method Item Returns a CodeElement object in a CodeElements collection.
Public method Reserved1 Infrastructure. Microsoft Internal Use Only.

Top

Remarks

CodeElements contains all elements in source files, members of classes, and so forth. It is automatically updated if an item is added to or removed from an open document or through the code model.

You can navigate through code elements using ProjectItem.FileCodeModel.CodeElements.

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

See Also

Reference

EnvDTE Namespace

CodeElement

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