Closed CoolCoderSuper closed 3 weeks ago
So I figured out how to reproduce it.
Public Class A
Implements ITest1, IDisposable
Public Sub New(c As Uri)
End Sub
Public Sub Dispose()
End Sub
Public Sub DifferentDispose() Implements IDisposable.Dispose
Dispose()
End Sub
End Class
Public NotInheritable Class B
Implements IDisposable
Private ReadOnly a As A
Public Sub New(c As String, d As String)
a = New A(New Uri(c))
End Sub
Public Sub Dispose() Implements IDisposable.Dispose
a.Dispose()
End Sub
End Class
Public Interface ITest1
Inherits IDisposable
End Interface
The bad code from OllamaSharp
//
// Summary:
// Releases the resources used by the OllamaSharp.OllamaApiClient instance. Disposes
// the internal HTTP client if it was created internally.
public void Dispose()
{
if (_disposeHttpClient)
{
_client?.Dispose();
}
}
void IDisposable.Dispose()
{
Dispose();
}
I assume this should be fixed there.
Analyzer
Diagnostic ID: CA2213:
Disposeable field not disposed
Describe the bug
Steps To Reproduce
Expected behavior
I would assume that it would no longer give the warning since it is diposed.
Actual behavior
It gives the warning.
Additional context
I don't quite understand what triggers it since this works:
It only ever breaks when using the OllamaApiClient type from OllamaSharp. As soon I change it to say explicitly IDisposable it works.