Skip to content

[Bug]: TUnit0023 is not suppressed when the IDisposable interface is explicitly implemented #6804

Description

@kzrnm

Bug report checklist

  • I've searched existing issues to ensure this isn't a duplicate
  • I've read the documentation and this isn't expected behavior
  • I'm using the latest version of TUnit

Description

TUnit0023 is reported when Dispose() is called by casting to IDisposable as shown below.

Expected Behavior

No warning

Actual Behavior

TUnit0023: obj should be disposed within a clean up method

Steps to Reproduce

class MyObject : IDisposable
{
    void IDisposable.Dispose() => throw new NotImplementedException();
}
public sealed class MyTest : IDisposable
{
    public MyTest()
    {
        obj = new();
    }
    readonly MyObject obj;
    public void Dispose() => ((IDisposable)obj).Dispose();

    [Test]
    public void Test() { }
}

TUnit Version

1.67.0

.NET Version

any

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

Additional Context

No response

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions