I recently started working with the data flow analysis APIs provided by Roslyn, and finding the values ββpresented in the WrittenInside field and the Locations field is a bit ambiguous.
Consider the code snippet in the main method below
1. int[] lcolSample = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; 2. for (int lintCount1 = 0; lintCount1 < 10; lintCount1++) 3. { 4. Prog1(lintCount1); 5. int[] lcolSample1 = new int[10] { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; 6. lintCount3 = lintCount3 + 100; 7. lintCount1 = lintCount1 + 2; 8. lcolSample[lintCount1-1] = lcolSample1[lintCount1] + 100; 9. }
If I execute DFA on for a node loop, the result of the data flow analysis object will never display lcolSample [] in the WrittenInside field as a character that is written inside the loop. The reason is that it is declared outside the node on which the data flow analysis is performed. But in the ReadInside field this symbol is displayed. Is there a way to find out all the characters that change / write inside the given node, even if they are declared outside the node on which DFA is running?
The variable lintCount1 is written twice (statement 2 and 7) and read twice. The Locations property on lintCount1 shows only the place where it is declared (statement 2). Is there a way to find all the places where lintCount1 is written? Find all the links to this symbol will give all the places where the symbol is used, but I need the places where they are written, but not read.
This is my first question on this forum. Please request any other information if the information above is insufficient. Thanks in advance.
source share