我很好奇是否有可能在运行时跟踪对象引用下的操作(复制,访问等)。 例如,如果我调试以下代码:运行时对象参考跟踪
private static void Main(string[] args)
{
// Creating new object and reference.
var myList = new List<int>();
// a) Copying a reference to method.
UpdateList(myList);
}
private static void UpdateList(IList<int> list)
{
// b) Copying the reference.
var localList = list;
// c) Accessing the object through copied reference.
localList.Add(1);
// d) Copying a reference to method.
int count = GetListElementsCount(localList);
}
private static int GetListElementsCount(IList<int> list)
{
// Another reference access.
// Breakpoint here.
return list.Count;
}
将断点设置成GetListElementsCount
,我可以看看通过list
说法起源和它(A,B,C,d)所做的更改? Roslyn编译器是否为此提供了一些C#API?
非常感谢。
HTTP://source.roslyn。 IO /#Microsoft.CodeAnalysis /编译/ DataFlowAnalysis.cs – SLaks