2016-03-20 1 views
4

クラスから属性を取得しようとしていますが、GetCustomAttributesメソッドがないようです。 CoreCLRで属性を取得する方法は?CoreCLRのType.GetCustomAttributesメソッドはどこですか?

using System.Reflection; 

class FooBar { 
    FooBar() { 
     GetType().GetCustomAttributes(); // does not compile 
     GetType().GetField("test").GetCustomAttributes(); // compiles 
    } 
} 

答えて

7

あなたはSystem.Reflection名前空間の拡張メソッドであるType.GetTypeInfo()でそれを得る、TypeInfoを試してみてください。

これはchanged with .NET 4.5.

関連する問題