-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support BoundUsingLocalDeclarations in IOperation and CFG #32100
Comments
Once fixed, please verify this scenario (copied from #33464): Using-declaration should not trigger RemoveUnusedValues. I suspect this is a compiler issue, as the We should also test ExtractMethod on a using-declaration (tracked by this issue) |
Maybe the same as #33464. using var x1 = File.OpenText("test");
var x2 = x1.ReadToEnd(); Expect: var x2 = File.OpenText("test").ReadToEnd(); [jcouv update:] Yes. Also we can close this issue when we've fixed/verified the InlineVariable scenario. |
#36502 - another report where IOperation/CFG based analyses in IDE is falling over due to this issue. There are now at least 4 known IDE features that give false results due to this missing support. |
also reported here |
Adding more context to @jinujoseph's comment: We have added new CFG/dataflow analysis based dispose analyzers in the IDE in 16.2, and they generate false positives due to this missing support: using System.Diagnostics;
public class Class1
{
public void M()
{
using Process _ = new Process // Dispose analyzer flags this object creation as not-disposed.
{
StartInfo = new ProcessStartInfo()
};
}
} |
Workaround for dotnet#32100 for Dev16.2
I have created #36734 to workaround this issue in couple of IDE analyzers. When the IOperation/CFG support has been added for using declarations, kindly revert the product workarounds in that PR and ensure the added unit tests still pass. |
Workaround for missing IOperation/CFG support for using declarations: dotnet/roslyn#32100 Fixes dotnet#2703
Fixed with #39125 |
BoundUsingLocalDeclarations are currently implemented as OperationKind.None, and return the List of local declarations as its children. We should implement this correctly with an Operation node.
We should also support CFG correctly with using declarations. Currently we report the using declaration as OperationKind.None in a single block, and thus don't report the actual underlying block structure generated by lowering.
[jcouv update:] When fixing this, let's also verify IDE behavior got fixed. For example #36502
The text was updated successfully, but these errors were encountered: