ConditionalAttribute 可用于消除呼叫取决于所定义的编译器的符号的显着的方法。我假设我们不能创建该类自己,因为编译器必须专门寻找它。
The ConditionalAttribute can be used to remove calls to a marked method depending on the compiler symbols defined. I'm assuming we could not create this class ourselves since the compiler must be looking for it specifically.
我想知道其他班级也有编译器,或者使用的语言,我们不能code自己。
I was wondering what other classes there are that the compiler, or language uses that we could not code ourselves.
推荐答案-
编译器查找 [ExtensionAttribute] 指示扩展方法(和包含扩展方法的类)。
The compiler looks for [ExtensionAttribute] to indicate extension methods (and classes containing extension methods).
[ DynamicAttribute] 是用来表示一个成员都应该为类型进行治疗动态(即使会员类型本身也只是对象)
[DynamicAttribute] is used to indicate that a member should be treated as type dynamic (even though the member type itself will just be object)
[InternalsVisibleTo] 允许一个程序集访问另一个人的内部成员。
[InternalsVisibleTo] allows one assembly to access the internal members of another.
基本上去翻 System.Runtime.CompilerServices 命名空间,并检查存在的属性......许多人将予以特殊的在的编译器,即使它不是C#编译器(例如: DateTimeConstantAttribute 是不使用C#编译器,据我所知,但 DecimalConstantAttribute 是,它是的可能的是,C#编译器的消耗的恒的DateTime 即使它不会产生这些价值观......)
Basically look through the System.Runtime.CompilerServices namespace, and examine the attributes in there... many of them will be handled specially by a compiler, even if it's not the C# compiler (e.g. DateTimeConstantAttribute isn't used by the C# compiler as far as I'm aware, but DecimalConstantAttribute is. It's possible that the C# compiler will consume constant DateTime values even though it won't produce them...)
更多推荐
ConditionalAttribute等特殊类
发布评论