次の方法で共有


CodeFunction.FunctionKind Property

Definition

Gets an enumeration describing how a function is used.

public:
 property EnvDTE::vsCMFunction FunctionKind { EnvDTE::vsCMFunction get(); };
public:
 property EnvDTE::vsCMFunction FunctionKind { EnvDTE::vsCMFunction get(); };
[System.Runtime.InteropServices.DispId(32)]
public EnvDTE.vsCMFunction FunctionKind { [System.Runtime.InteropServices.DispId(32)] [System.Runtime.InteropServices.TypeLibFunc(1024)] get; }
[<System.Runtime.InteropServices.DispId(32)>]
[<get: System.Runtime.InteropServices.DispId(32)>]
[<get: System.Runtime.InteropServices.TypeLibFunc(1024)>]
member this.FunctionKind : EnvDTE.vsCMFunction
Public ReadOnly Property FunctionKind As vsCMFunction

Property Value

A vsCMFunction value.

Attributes

Examples

 Sub FunctionKindExample(ByVal dte As DTE2)  

    ' Before running this example, open a code document from a project  
    ' and place the insertion point inside a function.  
    Try  
        ' Retrieve the CodeFunction at the insertion point.  
        Dim sel As TextSelection = _  
            CType(dte.ActiveDocument.Selection, TextSelection)  
        Dim fun As CodeFunction = _  
            CType(sel.ActivePoint.CodeElement( _  
            vsCMElement.vsCMElementFunction), CodeFunction)  

        MsgBox(fun.Name & "'s kind is " & fun.FunctionKind.ToString())  
    Catch ex As Exception  
        MsgBox(ex.Message)  
    End Try  

End Sub  
 public void FunctionKindExample(DTE2 dte)  
{  
    // Before running this example, open a code document from a project  
    // and place the insertion point inside a function.  
    try  
    {  
        // Retrieve the CodeFunction at the insertion point.  
        TextSelection sel =   
            (TextSelection)dte.ActiveDocument.Selection;  
        CodeFunction fun =   
            (CodeFunction)sel.ActivePoint.get_CodeElement(  
            vsCMElement.vsCMElementFunction);  

        MessageBox.Show(fun.Name + "'s kind is " +   
            fun.FunctionKind.ToString());  
    }  
    catch (Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

Remarks

FunctionKind returns the type of the function, such as a Property Get, a Property Let, a Sub, or a Function.

The vsCMFunction values are meant to be bitwise OR'd together. Visual C++ combines several of these values to accurately describe a function. For example: virtual int MyProc() const = 0;.

MyProc results in a value of (vsCMFunctionFunction | vsCMFunctionVirtual | vsCMFunctionConstant | vsCMFunctionPure | vsCMFunctionTopLevel).

Another example is : inline void AnotherOne().

This results in a value of (vsCMFunctionSub | vsCMFunctionInline, vsCMFunctionTopLevel).

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

Applies to