The minimal program below gives a CA2202 warning: Object PList.GetEnumerator()
can be disposed more than once in method Module1.Main()
. [This is cut-and-pasted from the warning message]/
If you change the List contents to, say, Integer the warning disappears. It also disappears if you take out the surrounding Do loop.
I'm using Visual Studio Community 2017 on Windows 7.
Module Module1
Sub Main()
Dim KVP As KeyValuePair(Of Integer, List(Of Object))
Dim PList As New SortedList(Of Integer, List(Of Object))
Do While True
For Each KVP In PList
Next KVP
Loop
End Sub
End Module
I can always ignore the warning but I'm intrigued as to why such a simple program can produce it. Any experts here with any ideas?