다음을 통해 공유


CodeClass.DocComment 속성

현재 코드 모델 요소에 대한 문서 주석을 가져오거나 설정합니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Property DocComment As String
    Get
    Set
string DocComment { get; set; }
property String^ DocComment {
    String^ get ();
    void set (String^ value);
}
abstract DocComment : string with get, set
function get DocComment () : String
function set DocComment (value : String)

속성 값

형식: System.String
특수한 문서 주석이나 특성을 포함하는 문자열입니다.

설명

DocComment가 Visual Basic 및 Visual C++와 함께 작동될 때에는 Visual C#와 함께 작동될 때와는 다르게 작동됩니다. Visual C#은 DocComment로 반환되는 XML을 <doc> 태그로 둘러싸지만, Visual Basic와 Visual C++는 그렇지 않습니다. 예를 들어 Visual Basic 및 Visual C++이 다음을 반환합니다.

<summary>
</summary>
<value>
</value>

반면, Visual C#는 다음을 반환합니다.

<doc>
  <summary>
  </summary>
  <value>
  </value>
</doc>

따라서 항상 프로그래밍 언어를 염두에 두고 그에 따라 XML 결과의 처리 방식을 조정해야 합니다.

DocComment는 코드에 있는 특수한 문서 주석이나 특성을 반환합니다. 코드 모델을 구현하는 언어에 문서 주석 메커니즘이 없거나 코드 요소와 관련된 문서 주석이나 특성이 없으면 DocComment에서 빈 문자열을 반환합니다.

참고

클래스, 구조체, 함수, 특성, 대리자 등의 코드 모델 요소를 특정한 방식으로 편집한 후에는 요소의 값이 명확하지 않을 수 있습니다. 즉, 요소의 값이 항상 같다고 할 수 없습니다. 자세한 내용은 코드 모델을 사용하여 코드 검색(Visual Basic)의 "코드 모델 요소 값이 변경될 수 있음" 단원을 참조하십시오.

예제

Public Sub CodeClassExample(ByVal dte As DTE2) 
    ' Before running this example, open a code document from a
    ' project and place the insertion point inside a class definition.
    Try
        Dim objTextSel As TextSelection
        Dim objCodeCls As CodeClass
        Dim objCodeType As CodeType
        Dim objCMElem As vsCMElement
        objTextSel = CType(dte.ActiveDocument.Selection, TextSelection)
        objCodeCls = CType(objTextSel.ActivePoint.CodeElement _
          (vsCMElement.vsCMElementClass), CodeClass)
        ' Add DocComment to CodeClass objCodeClass.
        objCodeCls.DocComment = "<DOC>DocComment for the CodeClass _
          object</DOC>"
        MsgBox(objCodeCls.DocComment)
        ' Test if a CodeType object is obtainable from the CodeClass.
        If objCodeCls.IsCodeType Then
            ' We can cast the CodeClass to a CodeType
            objCodeType = CType(objCodeCls, CodeType)
        Else 
            ' The CodeClass object is not a CodeType but is
            ' some Kind of element
            objCMElem = objCodeCls.Kind
        End If
    Catch ex As Exception
        MsgBox.Show(ex.Message)
    End Try
End Sub
public void CodeClassExample(DTE2 dte)
{ 
   // Before running this example, open a code document from a
   // project and place the insertion point inside a class definition.
   try
   {
      TextSelection objTextSel;
      CodeClass objCodeCls;
      CodeType objCodeType;
      vsCMElement objCMElem;
      objTextSel = (TextSelection)dte.ActiveDocument.Selection;
      objCodeCls = (CodeClass)objTextSel.ActivePoint.get_CodeElement
        (vsCMElement.vsCMElementClass);
      // Add DocComment to CodeClass objCodeClass.
      objCodeCls.DocComment = "<DOC>DocComment for the CodeClass 
        object</DOC>";
      MessageBox.Show(objCodeCls.DocComment);
      // Test if a CodeType object is obtainable from the CodeClass.
      if (objCodeCls.IsCodeType)
      { // then we can cast the CodeClass to a CodeType
         objCodeType = (CodeType)objCodeCls;
      }
      else // the CodeClass object is not a CodeType but is
      {    // some Kind of element
         objCMElem = objCodeCls.Kind;
      }
   }
   catch (Exception ex)
   { 
      MessageBox.Show(ex.Message);
   }
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

CodeClass 인터페이스

EnvDTE 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행

코드 모델을 사용하여 코드 검색(Visual Basic)

코드 모델을 사용하여 코드 검색(Visual C#)