C# DebuggerDisplay中的跨语言数据行索引
我正在尝试自定义调试对象工具提示。为了实现这一点,我在Visualizers文件夹()中有一个库,其中包括C# DebuggerDisplay中的跨语言数据行索引,c#,vb.net,visual-studio,visual-studio-2017,debuggerdisplay,C#,Vb.net,Visual Studio,Visual Studio 2017,Debuggerdisplay,我正在尝试自定义调试对象工具提示。为了实现这一点,我在Visualizers文件夹()中有一个库,其中包括Assembly:DebuggerDisplayattributes() 我希望看到vb.net中的DataRow索引 或者用c# 问题在于,表达式是在调试时计算的,并且对象自引用(Mexthis)在两种语言中是不同的。所以我得到了 CS0103当前上下文中不存在名称“Me” 在调试c#代码时的工具提示中 有没有一种方法可以使用两种语言通用的语法获取DataRow的索引?的源代码 显示
Assembly:DebuggerDisplay
attributes()
我希望看到vb.net中的DataRow索引
或者用c#
问题在于,表达式是在调试时计算的,并且对象自引用(Me
xthis
)在两种语言中是不同的。所以我得到了
CS0103当前上下文中不存在名称“Me”
在调试c#代码时的工具提示中
有没有一种方法可以使用两种语言通用的语法获取DataRow的索引?的源代码
显示它返回
如果我们假设直接调用GetIndexByNode
并直接传递DataRow.RBTreeNodeId
值是有效的,那么下面的方法应该可以工作
[assembly: DebuggerDisplay(@"Index = {Table.Rows.list.GetIndexByNode(RBTreeNodeId)}", Target = typeof(System.Data.DataRow))]
public Int32 IndexOf(DataRow row) {
if ((null == row) || (row.Table != this.table) || ((0 == row.RBTreeNodeId) && (row.RowState == DataRowState.Detached))) //Webdata 102857
return -1;
return list.IndexOf(row.RBTreeNodeId, row);
}
public int IndexOf (int nodeId, K item)
{
int index = -1;
// BIG ASSUMPTION: There is not satellite tree, this is INDEX_ONLY.
if (nodeId != NIL)
{
if ( (Object) Key(nodeId) == (Object)item) {
return GetIndexByNode(nodeId);
}
if ( (index=IndexOf(Left(nodeId), item)) != -1) {
return index;
}
if ( (index=IndexOf(Right(nodeId), item)) != -1) {
return index;
}
}
return index;
}
[assembly: DebuggerDisplay(@"Index = {Table.Rows.list.GetIndexByNode(RBTreeNodeId)}", Target = typeof(System.Data.DataRow))]