“特殊名称”的目的和含义和“ rtspecialname”在IL [英] Purpose and Meaning of "specialname" and "rtspecialname" in IL

查看:222
本文介绍了“特殊名称”的目的和含义和“ rtspecialname”在IL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在特别想了解IL代码和C#内部结构,我编写了一个简单的c#hello world程序,其代码为:

I am trying to understand the IL code and C# internals specifically nowadays, i wrote a simple c# hello world program whose code is :

using System;
class Program
{
    public static void Main()
    {
       Console.WriteLine("Hello World");
    }
}

这是为<$的构造函数生成的IL c $ c> Program class:

.method public hidebysig specialname rtspecialname 
        instance void  .ctor() cil managed
{
  // Code size       7 (0x7)
  .maxstack  8
  IL_0000:  ldarg.0
  IL_0001:  call       instance void [mscorlib]System.Object::.ctor()
  IL_0006:  ret
} // end of method Program::.ctor

我无法理解 specialname rtspecialname 的含义和目的是什么? p>

I am not able to understand what is the meaning and purpose of specialname and rtspecialname or what's the use of them ?

推荐答案

每个 ECMA 355标准


rtspecialname 表示此项目的名称对CLI具有特殊意义。当前没有定义的特殊类型名称;这是供将来使用。任何标有 rtspecialname 的项目也应标有 specialname

rtspecialname indicates that the name of this item has special significance to the CLI. There are no currently defined special type names; this is for future use. Any item marked rtspecialname shall also be marked specialname.

特殊名称表示该项目的名称对CLI以外的工具可能具有特殊的意义。参见,例如,分区I。

specialname indicates that the name of this item can have special significance to tools other than the CLI. See, for example, Partition I .

这些属性由工具或运行时使用,以确定属性或方法是否具有特殊用途或重要性-一个示例( SpecialNameAttribute还允许使用其他哪些巧妙的技巧?)标记一个运算符以防止与用户名称空间冲突。我在标准中看到的另一个是属性的获取器和设置器,看来您引用的 Main 方法是另一个示例。

These attributes are used either by tools or the runtime to determine if an attribute or method has a special use or significance - one example (What other neat tricks does the SpecialNameAttribute allow?) is to mark an operator to prevent collisions with the user namespace. Another one I see in the standard is for getters and setters of properties, and it appears that the Main method you cited is another example.

尽管我将原始问题标记为重复,但该问题的范围略有不同,此处的答案可能会更清楚。我还是希望。

Although I marked the original question as a duplicate, this question is slightly different in scope and the answer here might shed some more light. I hope anyway.

这篇关于“特殊名称”的目的和含义和“ rtspecialname”在IL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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