在哪里可以了解与调试“魔法姓名” [英] Where to learn about VS debugger 'magic names'

查看:140
本文介绍了在哪里可以了解与调试“魔法姓名”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你曾经使用反射,你可能注意到C#编译器生成类型,方法,字段和局部变量,通过调试器值得特别的显示。例如,对于'CS $'开始局部变量不显示给用户。还有其他一些特殊的命名约定封闭类型的匿名方法,自动属性的支持领域,等等。

If you've ever used Reflector, you probably noticed that the C# compiler generates types, methods, fields, and local variables, that deserve 'special' display by the debugger. For instance, local variables beginning with 'CS$' are not displayed to the user. There are other special naming conventions for closure types of anonymous methods, backing fields of automatic properties, and so on.

我的问题:在哪里可以了解这些命名约定?有谁知道一些文档?

My question: where to learn about these naming conventions? Does anyone know about some documentation?

我的目标是让PostSharp 2.0使用相同的约定。

My objective is to make PostSharp 2.0 use the same conventions.

推荐答案

这是编译器的无证实施细则,并随时更改。

These are undocumented implementation details of the compiler, and subject to change at any time.

不过,由于我是一个好人,这里有一些这些细节:

However, since I'm a nice guy, here are some of those details:

如果你有一个未使用的局部变量,优化消除,我们发射了它的调试信息反正到PDB。我们坚持后缀 __删除$ 到这样的变量使调试器都知道,他们是在源$ C ​​$ C,但不会再在二进制psented $ P $

If you have an unused local variable that the optimizer removes, we emit debug info for it anyway into the PDB. We stuck the suffix __Deleted$ onto such variables so that the debugger knows that they were in source code but not represented in the binary.

临时变量时隙给出名称与图案的CS $ X $ Y,其中X为临时一种和Y是迄今分配临时的数量。临时种类分别是:

Temporary variable slots allocated by the compiler are given names with the pattern CS$X$Y, where X is the "temporary kind" and Y is the number of temporaries allocated so far. The temporary kinds are:

0 --> short lived temporaries
1 --> return value temporaries
2 --> temporaries generated for lock statements
3 --> temporaries generated for using statements
4 --> durable temporaries
5 --> the result of get enumerator in a foreach
6 --> the array storage in a foreach
7 --> the array index storage in a foreach.  

8和264之间的

临时种是多维数组的附加数组索引存储。

Temporary kinds between 8 and 264 are additional array index storages for multidimensional arrays.

临时种以上264用于涉及固定语句固定字符串临时

Temporary kinds above 264 are used for temporaries involving the fixed statement fixing a string.

特殊的编译器生成的名称是为生成的:

Special compiler-generated names are generated for:

1 --> the iterator state ("state")
2 --> the value of current in an iterator ("current")
3 --> a saved parameter in an iterator
4 --> a hoisted 'this' in an iterator ("this")
5 --> a hoisted local in an iterator
6 --> the hoisted locals from an outer scope
7 --> a hoisted wrapped value ("wrap")
8 --> the closure class instance ("locals")
9 --> the cached delegate instance ("CachedAnonymousMethodDelegate")
a --> the iterator instance ("iterator")
b --> an anonymous method
c --> anonymous method closure class ("DisplayClass")
d --> iterator class
e --> fixed buffer struct ("FixedBuffer")
f --> anonymous type ("AnonymousType")
g --> initializer local ("initLocal")
h --> query expression temporary ("TransparentIdentifier")
i --> anonymous type field ("Field")
j --> anonymous type type parameter ("TPar")
k --> auto prop field ("BackingField")
l --> iterator thread id
m --> iterator finally ("Finally")
n --> fabricated method ("FabricatedMethod")
o --> dynamic container class ("SiteContainer")
p --> dynamic call site ("Site")
q --> dynamic delegate ("SiteDelegate")
r --> com ref call local ("ComRefCallLocal")
s --> lock taken local ("LockTaken")

产生神奇名称的模式是: P< N> C__SI 其中:


  • P是CS $缓存的代表和展示类的实例,否则空。

  • N是与事情相关的原始名称,如果任何

  • C是1字通过上面所列小号

  • S是一个描述性的后缀(当前,状态,等等),这样你就不必有上述读取元数据时记忆的表。

  • 我是一个可选的唯一编号

这篇关于在哪里可以了解与调试“魔法姓名”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆