2013-07-05 2 views
2

.NET Framework에서 인터페이스를 구현할 때 Visual Studio에서 주석 (및 영역과 같은 다른 장점)을 생성하는 사례를 보았습니다.인터페이스에 주석 추가

좋은 예가 IDisposable입니다. 구현하면 Visual Studio에서 다음 코드 블록을 생성합니다.

#Region "IDisposable Support" 
    Private disposedValue As Boolean ' To detect redundant calls 

    ' IDisposable 
    Protected Overridable Sub Dispose(disposing As Boolean) 
     If Not Me.disposedValue Then 
      If disposing Then 
       ' TODO: dispose managed state (managed objects). 
      End If 

      ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. 
      ' TODO: set large fields to null. 
     End If 
     Me.disposedValue = True 
    End Sub 

    ' TODO: override Finalize() only if Dispose(ByVal disposing As Boolean) above has code to free unmanaged resources. 
    'Protected Overrides Sub Finalize() 
    ' ' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above. 
    ' Dispose(False) 
    ' MyBase.Finalize() 
    'End Sub 

    ' This code added by Visual Basic to correctly implement the disposable pattern. 
    Public Sub Dispose() Implements IDisposable.Dispose 
     ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. 
     Dispose(True) 
     GC.SuppressFinalize(Me) 
    End Sub 
#End Region 

이 코드는 내 코드에서 할 수 있습니까? 그렇다면 어떻게? 인터페이스의 메소드에 메소드의 일반적인 목적이 무엇인지 구현 자에게 알려주는 몇 가지 설명을 추가하고 싶습니다.

+1

가능한 복제본 [VB.net : Custom 'TODO : List on an Interface] (http://stackoverflow.com/questions/2884036/vb-net-custom-todo-list-on-an-interface) –

답변

0

100 % 당신이 묻고있는 것이지만 여기에 있다면 확실하지 않습니다. 당신의 방법 정의 유형 '' '

편집기 위

그 방법을 사용하는 경우 인텔리을 구동하는 데 사용되는 XML의 조각으로 그을 확장합니다.

Private Sub Import(ByVal ImportFileName As String, ByRef OutFileName As String) 

''' <summary> 
''' Imports data from import file into Output File 
''' </summary> 
''' <param name="ImportFileName">the fully qualified path to the import file</param> 
''' <param name="OutFileName">the fully qualified path for the output file</param> 
''' <remarks>all the widgets need to be thoroughly castigated</remarks> 
Private Sub Import(ByVal ImportFileName As String, ByRef OutFileName As String) 

가되고,이 반입 방법 제공된 힌트가 사용될 때마다 파라미터의 이름과 함께 표시된다.

+0

아마 내가 얻을 수있는 가장 가까운 방법 일 것이지만, 실제로 인터페이스에 대한 인라인 코드 문서를 제공 할 방법을 찾고 있습니다. 구현을 쓴 프로그래머 만이 그것을 읽는 사람 만 볼 수 있습니다. –

+0

'IDisposable'을 구현 한 VB에서 클래스를 작성했다면, 무슨 뜻인지 알게 될 것입니다. 인터페이스를 추가하자 마자 TODO 주석을 사용하여 기본 구현을 구현합니다. 이것은 내가하고 싶은 일과 정확하게 같습니다. –

+0

나는 IDisposable 인터페이스를 사용했고 정확히 무슨 뜻인지 알고 있습니다. 하지만 위의 링크 된 질문에 따르면 IDisposable에 대한 멋진 TODO 항목은 VS 편집기에 하드 코딩되어 있습니다. 가장 좋은 과정은 미리보기를 가지고있는 것입니다. –