CoreCLR中的Type.GetCustomAttributes方法在哪里?

x2b*_*ool 4 .net c# reflection coreclr asp.net-core

我试图从类中获取属性,似乎没有GetCustomAttributes方法.如何在CoreCLR中获取属性?

using System.Reflection;

class FooBar {
    FooBar() {
        GetType().GetCustomAttributes(); // does not compile
        GetType().GetField("test").GetCustomAttributes(); // compiles
    }
}
Run Code Online (Sandbox Code Playgroud)

Fel*_* K. 7

试试吧TypeInfo,你可以Type.GetTypeInfo()System.Reflection名称空间获取扩展方法.

这已在.NET 4.5中更改.