【发布时间】:2013-11-13 12:45:26
【问题描述】:
在我的 PCL 核心项目(WP8、Android、iOS、Xamarin、MvvmCross)中,我使用自定义属性。 Type.GetCustomAttributes() 扩展方法让我检查使用的属性。
使用 PCL Profile104 效果很好。但是因为我想使用 async/await,所以我需要使用 PCL Profile78(和 .NET 4.5)
问题:似乎 GetCustomAttributes() 和 Attributes 属性在 Profile78 中不可用。为什么??
注意: 我正在通过创建 PCL Profile 104 类库并包装 GetCustomAttributes() 然后从我的 PCL Profile78 库中引用该库来研究解决方法。但是似乎不支持扩展方法...
示例代码:
public Pcl78Class()
{
Type t = this.GetType();
var attributes = t.Attributes;
var customAttributes = t.GetCustomAttributes(true);
// another weird thing: Why is VS CodeCompletion telling me it knows CustomAttributeExtensions class and methods?
//System.Reflection.CustomAttributeExtensions.GetCustomAttributes(t);
}
【问题讨论】:
-
这也发生在 Profile7 中
标签: c# xamarin.ios xamarin.android xamarin portable-class-library