Port Class Library Profile 78 Missing Attribute Methods / Properties

In my main PCL project (WP8, Android, iOS, Xamarin, MvvmCross) I use custom attributes. The extension method Type.GetCustomAttributes () allows me to examine the attributes used.

Using PCL Profile104 works well. But since I want to use async / await, I will need to use PCL Profile78 (and .NET 4.5)

Problem: It seems that GetCustomAttributes () and the Attributes property are not available in Profile78. Why??

Note: I am exploring a workaround by creating a PCL Profile 104 profile class library and wrapping GetCustomAttributes (), and then referencing this library from the PCL Profile78 library. However, extension methods do not seem to be supported ...

Code example:

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); } 

enter image description here

+6
source share
1 answer

Problem: It seems that GetCustomAttributes () and the Attributes property are not available in Profile78. Why??

Profile 78 includes support for the Windows Store 8 (as noted on my blog) and the Windows Store has a more efficient implementation of Type restriction . Essentially, you just need to call Type.GetTypeInfo to get TypeInfo , and from there it should be pretty simple.

+13
source

Source: https://habr.com/ru/post/957246/


All Articles