Object creation and disposal inside local functions is not properly processed by NUnit1032 analyzer.
The following is considered invalid (despite being correct):
[TestFixture]
public class DisposableTest
{
private IDisposable? disposable;
[SetUp]
public void SetUp()
{
disposable = new DisposableClass();
}
[TearDown]
public void TearDown()
{
RunDispose();
void RunDispose()
{
disposable.Dispose();
}
}
}
And the following passes (although the field is not disposed):
[TestFixture]
public class DisposableTest
{
private IDisposable? disposable;
[SetUp]
public void SetUp()
{
Initialize();
void Initialize()
{
disposable = new DisposableClass();
}
}
[TearDown]
public void TearDown()
{
}
}
Object creation and disposal inside local functions is not properly processed by NUnit1032 analyzer.
The following is considered invalid (despite being correct):
And the following passes (although the field is not disposed):