可移植类库配置文件78缺少与属性相关的方法/属性

Art*_*ter 6 c# xamarin.ios xamarin.android portable-class-library xamarin

在我的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);
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Ste*_*ary 13

问题:似乎GetCustomAttributes()和Attributes属性在Profile78中不可用.为什么??

Profile78包括对Windows Store 8的支持(如我的博客中所述),并且Windows Store具有更高效的Type基于反射的实现.基本上,你只需要打电话Type.GetTypeInfo来获得一个TypeInfo,从那里它应该是非常简单的.