Bug 32236 - Binding Generates Attribute Property of Type "Java.Lang.Class" which cannot be set in a C# Attribute
Summary: Binding Generates Attribute Property of Type "Java.Lang.Class" which cannot b...
Status: RESOLVED FEATURE
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 5.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2015-07-21 17:12 UTC by Jon Douglas [MSFT]
Modified: 2015-07-22 04:19 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description Jon Douglas [MSFT] 2015-07-21 17:12:40 UTC
*Description

Given a third party binding, the following Attribute was generated:

[Annotation("com.htc.blinkfeed.annotation.BlinkFeedPlugin")]
  public class BlinkFeedPluginAttribute : Attribute
  {
    [Register("timelineProvider")]
    public Class TimelineProvider { get; set; }
   }

However it seems that we cannot simply cast this to the Java equivalent of Class via to use in an Attribute:

Java.Lang.Class.FromType(typeof(MyClass));

EX:

[BlinkFeedPlugin(TimelineProvider=Java.Lang.Class.FromType(typeof(MyClass));)] 

As C# attributes need to be known at compilation time, and based on documentation it seems we can send in a Type as a workaround. I believe we would want to bind "Class" as a "Type" so we can simply use "typeof(MyClass)" in the Attribute.

Potential Usage:

Register("timelineProvider")]
    public Type TimelineProvider { get; set; }

[BlinkFeedPlugin(TimelineProvider=typeof(MyTimelineProvider))] 

*Reproduction

https://www.dropbox.com/s/n7jy63pk1hzg5it/BlinkFeed.zip?dl=0

*Version Information

Xamarin 3.11.666
Xamarin.Android 5.1.4.16
Comment 1 Atsushi Eno 2015-07-21 17:32:25 UTC
Supported annotation values are limited to whatever possible under .NET constraints. Classes can never be that.