VCCodeModel Interface

An object providing project-level access to any contained code element.

Namespace:  Microsoft.VisualStudio.VCCodeModel
Assembly:  Microsoft.VisualStudio.VCCodeModel (in Microsoft.VisualStudio.VCCodeModel.dll)

Syntax

'Declaration
<GuidAttribute("E6691CDE-9A41-4891-8D8C-C1E93958E6A0")> _
Public Interface VCCodeModel _
    Inherits CodeModel2
[GuidAttribute("E6691CDE-9A41-4891-8D8C-C1E93958E6A0")]
public interface VCCodeModel : CodeModel2
[GuidAttribute(L"E6691CDE-9A41-4891-8D8C-C1E93958E6A0")]
public interface class VCCodeModel : CodeModel2
[<GuidAttribute("E6691CDE-9A41-4891-8D8C-C1E93958E6A0")>]
type VCCodeModel =  
    interface 
        interface CodeModel2 
    end
public interface VCCodeModel extends CodeModel2

The VCCodeModel type exposes the following members.

Properties

  Name Description
Public property Attributes Gets a collection of all of the attributes for the object.
Public property Classes Gets a collection of classes for the object.
Public property CodeElements Gets a collection of code elements.
Public property Delegates Gets a collection of delegates for the object.
Public property DialogClasses Gets a collection of dialog classes.
Public property DTE Gets the top-level extensibility object.
Public property Enums Gets a collection of enumerations for the object.
Public property Functions Gets a collection of functions for the object.
Public property IDLImports Gets the collection of Import statements from the .idl file of the parent object.
Public property IDLLibraries Gets the collection of Library elements on the object.
Public property Imports Gets the collection of #import statements for the parent object.
Public property Includes Gets the collection of #include statements for the object.
Public property Interfaces Gets the collection of interfaces for the object.
Public property IsCaseSensitive Gets a value indicating whether a code element is case-sensitive.
Public property IsSynchronized Determines whether VCCodeModel is in sync with the source code for the solution.
Public property Language Gets the programming language used to author the code.
Public property Macros Gets the collection of macros (#define statements) for the object.
Public property Maps Gets the collection of maps for the object.
Public property Namespaces Gets the collection of namespaces for the object.
Public property Parent Gets the immediate parent object of a given object.
Public property Structs Gets the collection of structure elements for the object.
Public property Typedefs Gets the collection of Typedef elements for the object.
Public property Unions Gets the collection of Union elements for the object.
Public property UsingAliases Gets the collection of alias elements for the object.
Public property Usings Gets the collection of #using elements for the object.
Public property Variables Gets the collection of variables for the object.

Top

Methods

  Name Description
Public method AbortTransaction Cancels the current transaction.
Public method AddAttribute Creates a new attribute code construct and inserts the code in the correct location.
Public method AddClass Creates a new class code construct and inserts the code in the correct location.
Public method AddDelegate Creates a new delegate code construct and inserts the code in the correct location.
Public method AddEnum Creates a new enumeration code construct and inserts the code in the correct location.
Public method AddFunction Creates a new function code construct and inserts the code in the correct location.
Public method AddIDLImport Adds a new import statement to a specific .idl file.
Public method AddIDLLibrary Adds a new library statement to a specific .idl file.
Public method AddImport Adds a #import element to a specific file.
Public method AddInclude Adds a #include element to a specific file.
Public method AddInterface Creates a new interface code construct and inserts the code in the correct location.
Public method AddMacro Adds a #define element to a specific file.
Public method AddMap Adds a map entry to the object.
Public method AddNamespace Creates a new namespace code construct and inserts the code in the correct location.
Public method AddStruct Creates a new structure code construct and inserts the code in the correct location.
Public method AddTypedef Adds a typedef element to a specific file.
Public method AddUnion Adds a union element to the VCCodeModel object.
Public method AddUsing Adds a #using element to a specific file.
Public method AddUsingAlias Adds a using alias.
Public method AddVariable Creates a new variable code construct and inserts the code in the correct location.
Public method CodeElementFromFullName Gets a collection of the specified code elements for the object.
Public method CodeElementFromFullName2 Gets a collection of the specified code elements for the object. It is identical to CodeElementFromFullName, except that it ignores namespaces during lookup.
Public method CodeTypeFromFullName Returns a code element based on a fully qualified name.
Public method CodeTypeFromFullName2 Returns a code element based on a fully qualified name. It is identical to CodeTypeFromFullName except that it will attempt typedef resolution.
Public method CommitTransaction Commits the current transaction for the object.
Public method CreateCodeTypeRef A CodeTypeRef object based on the data type indicator passed.
Public method DotNetNameFromLanguageSpecific Translates the namespace to a .NET form.
Public method ElementFromID Not implemented.
Public method GetClassesDerivedFrom Returns the classes derived from the specified class.
Public method IsValidID Returns whether a specified name is a valid programmatic identifier for the current language.
Public method LanguageSpecificNameFromDotNet Translates from the fully qualified name to an unmanaged namespace form.
Public method Remove Removes the specified project from the solution.
Public method RemoveEx Removes the specified project from the solution.
Public method StartTransaction Begins a transaction.
Public method Synchronize Synchronizes all code model objects in the solution with edits made to source files.
Public method SynchronizeCancellable Displays a dialog box that has a progress bar. The user can cancel waiting and unblock the thread.
Public method SynchronizeFiles Ensures that the FileCodeModel property on a project file is not null.
Public method ValidateMember Validates that the proposed name is a valid C++ name for the kind given in the context of the parent object.
Public method ValidateMemberName Validates the name of an element.

Top

Remarks

The VCCodeModel object provides code model functionality to various languages supported by Visual Studio (including Visual C++) at the project level.

Primarily, this object is used to find any code element accessible within a project (given a fully-qualified name). In addition, the object specifies the programming language in which the project is written.

Note

A large part of the functionality of this object is provided by the Visual Studio CodeModel2 object.

When using a VCCodeModel object within a managed project, include Microsoft.VisualStudio.VCCodeModel.dll as a reference. For more information about adding references to a managed project, see How to: Add or Remove References By Using the Add Reference Dialog Box.

See How to: Compile Example Code for Visual C++ Code Model Extensibility for information about how to compile and run this sample.

Examples

This function returns the VCCodeModel object representing the first project in a solution.

Function GetVCCodeModel() As VCCodeModel
    GetVCCodeModel = Nothing
    Dim codeModel As CodeModel
    Dim vcCodeModel As VCCodeModel
    Dim solution As Solution
    solution = DTE.Solution
    If (solution Is Nothing) Then
        MsgBox("A Solution is not open")
        Exit Function
    Else
        If (DTE.Solution.Count <> 0) Then
            codeModel = DTE.Solution.Item(1).CodeModel
            vcCodeModel = CType(codeModel, VCCodeModel)
            If (vcCodeModel Is Nothing) Then
                MsgBox("The first project is not a VC++ project.")
                Exit Function
            Else
                GetVCCodeModel = vcCodeModel
            End If
        End If
    End If
End Function

See Also

Reference

Microsoft.VisualStudio.VCCodeModel Namespace