向接口添加注释

时间:2013-07-05 17:50:36

标签: vb.net interface

我在.NET框架中看到了一些案例,当你实现一个接口时,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 个答案:

答案 0 :(得分: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)

每当使用此导入方法时,提供的提示将与参数名称一起显示。