-
-
Notifications
You must be signed in to change notification settings - Fork 118
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The warning TUnit0023 is given for a member variable of type Func<IDisposable>, but the member variable itself cannot be disposed of.
Expected Behavior
I would not expect a compiler warning.
Actual Behavior
Compiling the below code results in the warning error TUnit0023: _factory should be disposed within a clean up method.
Steps to Reproduce
Compile the following code in a TUnit project:
public interface IMyInterface : IDisposable
{
}
public class MyClass : IMyInterface
{
public void Dispose()
{
Console.WriteLine("disposed");
}
}
public class ExampleTest
{
private readonly Func<IMyInterface> _factory = () => new MyClass();
[Test]
public async Task Test1()
{
using var t = _factory();
}
}TUnit Version
1.9.2
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
error TUnit0023: _factory should be disposed within a clean up methodAdditional Context
IDE-Specific Issue?
- I've confirmed this issue occurs when running via
dotnet testordotnet run, not just in my IDE
Reactions are currently unavailable
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't working