-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Milestone
Description
Version Used:
3.2.0-beta3-19307-02+a87b8ee11cb50f233d288cf86b99e315a408afa4
Steps to Reproduce:
- Use this program
using System;
class Program
{
static void Main()
{
using var write = new WriteOnDispose();
Console.WriteLine("almost done");
}
class WriteOnDispose : IDisposable
{
public void Dispose() => Console.WriteLine("done");
}
}using System;
class Program
{
static void Main()
{
_ = new WriteOnDispose();
Console.WriteLine("almost done");
}
class WriteOnDispose : IDisposable
{
public void Dispose() => Console.WriteLine("done");
}
}Expected Behavior:
Either the refactoring shouldn't be offered, or it should be done in a way that doesn't remove the using. After refactoring the program should still output:
almost done
done
Actual Behavior:
The using gets removed, which means the disposable's Dispose method is never invoked. The refactored program only outputs:
almost done
