This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tree = CSharpSyntaxTree.ParseText(@" | |
public class Sample | |
{ | |
public void Foo() | |
{ | |
int[] outerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; | |
for (int index = 0; index < 10; index++) | |
{ | |
int[] innerArray = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; | |
index = index + 2; | |
outerArray[index - 1] = 5; | |
} | |
} | |
}"); | |
var Mscorlib = MetadataReference.CreateFromFile(typeof(object).Assembly.Location); | |
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment