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 method
Additional Context
IDE-Specific Issue?
Reactions are currently unavailable
Description
The warning
TUnit0023is given for a member variable of typeFunc<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:
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
Additional Context
IDE-Specific Issue?
dotnet testordotnet run, not just in my IDE