Share via


VCCodeStruct.ValidateMember Method

Validates that the proposed name is a valid Visual C++ name for the kind given in the context of the parent object.

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

Syntax

'Declaration
Function ValidateMember ( _
    bstrName As String, _
    Kind As vsCMElement, _
    bstrType As String _
) As Boolean
bool ValidateMember(
    string bstrName,
    vsCMElement Kind,
    string bstrType
)
bool ValidateMember(
    [InAttribute] String^ bstrName, 
    [InAttribute] vsCMElement Kind, 
    [InAttribute] String^ bstrType
)
abstract ValidateMember : 
        bstrName:string * 
        Kind:vsCMElement * 
        bstrType:string -> bool
function ValidateMember(
    bstrName : String, 
    Kind : vsCMElement, 
    bstrType : String
) : boolean

Parameters

  • bstrName
    Type: String

    Required. The name of the object being validated.

  • bstrType
    Type: String

    Optional. The type of object being validated.

Return Value

Type: Boolean
true if the proposed name is a valid Visual C++ name; otherwise, false.

Remarks

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

Examples

This example validates a method name and then, if valid, adds a method with that name to the class.

[Visual Basic]

Sub AddMethod()
    Dim vcCM As VCCodeModel
    Dim classElement As VCCodeClass
    Dim type As String
    vcCM = DTE.Solution.Item(1).CodeModel
    classElement = vcCM.Classes.Item(1)
    type = "int"
    If (vcCM.ValidateMember("Method1", vsCMElement.vsCMElementFunction, type)) Then
        classElement.AddFunction("Method1", vsCMFunction.vsCMFunctionFunction, type)
    End If
End Sub

.NET Framework Security

See Also

Reference

VCCodeStruct Interface

Microsoft.VisualStudio.VCCodeModel Namespace