-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersBugResolution-By DesignThe behavior reported in the issue matches the current designThe behavior reported in the issue matches the current designVerified
Description
The documentation on DataFlowAnalysis.WrittenOutside reads
The set of local variables that are written outside a region.
However, when I perform data flow analysis, I'm noticing that this is being returned as a parameter symbol within WrittenOutside.
Is this the intended behavior? Is this considered a local variable in this context? If so, should it not also be contained within AlwaysAssigned as this must always be assigned?
Here is the code I'm running:
var tree = CSharpSyntaxTree.ParseText(@"
public class Sample
{
public void Foo()
{
int[] lcolSample = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4};
for (int lintCount1 = 0; lintCount1 < 10; lintCount1++)
{
Prog1(lintCount1);
int[] lcolSample1 = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 };
lintCount3 = lintCount3 + 100;
lintCount1 = lintCount1 + 2;
lcolSample1[lintCount1 - 1] = lcolSample[lintCount1] + 100;
}
}
}");
var Mscorlib = PortableExecutableReference.CreateFromAssembly(typeof(object).Assembly);
var compilation = CSharpCompilation.Create("MyCompilation",
syntaxTrees: new[] { tree }, references: new[] { Mscorlib });
var model = compilation.GetSemanticModel(tree);
var forStatement = tree.GetRoot().DescendantNodes().OfType<ForStatementSyntax>().Single();
DataFlowAnalysis result = model.AnalyzeDataFlow(forStatement);
//Contains two symbols: this and lcolSample
var writtenOutside = result.WrittenOutside;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersBugResolution-By DesignThe behavior reported in the issue matches the current designThe behavior reported in the issue matches the current designVerified