DebuggerDisplay 中的跨语言 DataRow 索引

Cross language DataRow index in DebuggerDisplay

我正在尝试自定义调试对象工具提示。为此,我有一个包含 Assembly: DebuggerDisplay 属性 (Can the DebuggerDisplay attribute be applied to types one doesn't own?) in Visualizers folder (How to: Install a Visualizer) 的库。

我想查看 DataRow 索引,所以我在 vb.net

<Assembly: DebuggerDisplay("Idx = {Table.Rows.IndexOf(Me)}", Target:=GetType(DataRow))> 

或在 c#

[assembly: DebuggerDisplay(@"Idx = {Table.Rows.IndexOf(this)}", Target = typeof(DataRow))] 

问题是表达式是在调试时计算的,对象自引用 (Me x this) 在两种语言中是不同的。所以我得到

CS0103  The name 'Me' does not exist in the current context

在我调试 C# 代码时的工具提示中。

有没有办法用两种语言通用的语法获取DataRow的索引?

Rows.IndexOf

的源代码
    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);
    }

表明它 returns list.IndexOf

的结果
    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;
    }

如果我们假设直接调用 GetIndexByNode 并直接传递 DataRow.RBTreeNodeId 值是有效的,那么以下应该有效。

[assembly: DebuggerDisplay(@"Index = {Table.Rows.list.GetIndexByNode(RBTreeNodeId)}", Target = typeof(System.Data.DataRow))]