Visual Studio / Resharper:导航到重写方法

时间:2013-10-25 11:45:51

标签: vb.net visual-studio-2010 inheritance navigation resharper

我有一个基类Base和一个继承自这个基类的类Child。基类是IDisposable

我调用了Dispose类的Child方法。有没有办法导航到Child中的被覆盖的实现?

Dim oChild as Child
oChild.Dispose()

当我选择Dispose()方法时按F12,我最终会在Base.Dispose()而不是Child.Dispose()。请注意,声明为Child类型。

P.S。:我确实有ReSharper,所以如果有人使用ReSharper有一个简单的解决方案,那也可以。

编辑(代码示例):

Public Class CBase
  Implements IDisposable

  Private disposedValue As Boolean ' To detect redundant calls

  ' IDisposable
  Protected Overridable Sub Dispose(disposing As Boolean)
    If Not Me.disposedValue Then
      If disposing Then
        ' Disposing etc.
      End If
    End If
    Me.disposedValue = True
  End Sub

  Public Sub Dispose() Implements IDisposable.Dispose
    Dispose(True)
    GC.SuppressFinalize(Me)
  End Sub

End Class

Public Class CChild
  Inherits CBase

  Protected Overrides Sub Dispose(disposing As Boolean)
    Try
      If disposing Then
        ' Dispose child specific
      End If
    Finally
      MyBase.Dispose(disposing)
    End Try
  End Sub

End Class

Public Class CExample

  Public Sub ProvideExample()
    Dim oChild As New CChild
    oChild.Dispose() ' F12 on this leads me to CBase.Dispose
  End Sub

End Class

1 个答案:

答案 0 :(得分:0)

是否有任何代码被覆盖的方法?

因为通常如果你按F12,你就没有到达基地。我认为只有在被覆盖的方法中没有别的东西?