Reputation: 21
In VS 2015, when I click 'Find All References' on a class definition for a class that implements IDisposable, it returns MyBase.Finalize()
for every class which implements IDisposable.
NOTE: This happens when I click 'Find All References' on the class definition itself (i.e. Public Class Test123
). If I click 'Find All References' on the implementation (i.e. New Test123
) then it only fetches instances which use that specific New
constructor. This is also confusing. In VS 2010, the class definition itself and all implementations were grouped together in one list, but in 2015 they are NOT.
Refer to the screenshot below. Even when I mousehover over class Test123
, it highlights the MyBase.Finalize()
method for both Test123
and Test456
Visual Studio 2010 does NOT do this. Is this a bug, or a 'new feature'?
The difficulty this causes is that for the current project at work, we manually implement IDisposable
for every class. So when I click 'Find All References' on any class, it takes 10-20 seconds to find the references, and then it displays thousands of instances of MyBase.Finalize()
(one for every single class), and it's basically completely useless.
Screenshot (I can't directly insert pictures with my acct yet)
Public Class Form1
Dim a As New Test123
Dim b As New Test456
End Class
Public Class Test123
Implements IDisposable
Dim A As Double = 0
'Dispose Implementation
Dim mbDisposed As Boolean = False
Public Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
Private Overloads Sub Dispose(ByVal lbDisposing As Boolean)
If Not mbDisposed Then
If lbDisposing Then
'Dispose of all nullable objects
End If
End If
mbDisposed = True
End Sub
Protected Overrides Sub Finalize()
Dispose(False)
MyBase.Finalize()
End Sub
End Class
Public Class Test456
Implements IDisposable
Dim B As Double = 1
'Dispose Implementation
Dim mbDisposed As Boolean = False
Public Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
Private Overloads Sub Dispose(ByVal lbDisposing As Boolean)
If Not mbDisposed Then
If lbDisposing Then
'Dispose of all nullable objects
End If
End If
mbDisposed = True
End Sub
Protected Overrides Sub Finalize()
Dispose(False)
MyBase.Finalize()
End Sub
End Class
Upvotes: 2
Views: 548
Reputation: 21
I downloaded Visual Studio 2017 RC. The "Find All References" window now contains a filtering combo box. If i select "Group by: Definition Only", then the actual references I'm trying to find appear in the first "group" in the list.
All the Finalize()
methods from every other class in the project in the project are still listed, but they are placed in separate groups below. So technically this bug still exists, but I am able to easily filter out the garbage that I don't want to see as shown in this snapshot
Upvotes: 0
Reputation: 328
For a given method for example, try to use "Call Hierarchy" on it to see 3 groups of calls:
Helping ?
Upvotes: 2