Closed stephentoub closed 5 years ago
Tagging @mavasani @jasonmalinowski . Looks like incomplete testing on the new using-local-variable feature. Was the IDE checklist not updated?
Duplicate of #32100 - @chsienki given the number of IDE analyzers that are now based on IOperation, I believe #32100 should be treated as higher priority as missing IOperation/CFG support for new language constructs will almost certainly lead to false positives from the analyzers.
Also tagging @jcouv so #32100 can be prioritized.
@stephentoub @CyrusNajmabadi to clarify the issue here - compiler does not implement any IOperation/CFG support for using declarations, which leads to all IOperation/CFG based analyzers seeing these as regular variable declarations with no implicit Dispose invocation. I have had to special case this scenario based on syntax at bunch of places in analyzers repo as well, which is ugly for any language agnostic IOperation/CFG based analysis.
@mavasani Understood. Personally, I woudn't consider the language feature 'done' unless we actually had the proper IOp information exposed.
Closing as dupe of https://github.com/dotnet/roslyn/issues/36502 https://github.com/dotnet/roslyn/issues/32100
We're prioritizing nullable analysis hard at the moment, but IOperation support for some C# 8 features is on our radar.
Version Used: 3.2.0-beta3-19307-02+a87b8ee11cb50f233d288cf86b99e315a408afa4
Steps to Reproduce:
class Program { static void Main() { using var write = new WriteOnDispose(); Console.WriteLine("almost 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:Actual Behavior: The
using
gets removed, which means the disposable's Dispose method is never invoked. The refactored program only outputs: