最近,我开始使用Roslyn提供的数据流分析API,并在WrittenInside字段和Locations字段中找到了一些模糊的值。
考虑以下主要方法中的代码片段
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. }
这是我在这个论坛上的第一个问题。如果以上所提供的信息不够,请询问其他细节。提前谢谢..。
发布于 2014-09-11 08:15:20
数据流分析对象从不将lcolSample[]在WrittenInside字段中显示为在for循环中写入的符号
是的,因为该符号不是写在循环中的(即没有lcolSample = whatever
)。由lcolSample
符号表示的数组的一个元素是在循环中编写的,这是非常不同的。我不知道如何使用Roslyn的数据流分析找到这样的写。
lintCount1上的Locations属性只显示声明它的位置(语句2)。有什么方法可以找到写lintCount1的所有位置吗?
DataFlowAnalysis
对象只给出符号,访问它们的Location
没有多大意义(因为这个位置与数据流分析无关)。
在我看来,您的两个问题听起来都是合理的特性请求,您可能想让它们成为关于罗斯林回购。
https://stackoverflow.com/questions/25629159
复制相似问题