Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
BaseAdapter<T>'s GetItem is implemented as taking the .net object and wrapping it in a Java object (which is fine):
public override Java.Lang.Object GetItem(int position)
However, the only exposed way to un-wrap this object is via JavaCast. However, that requires that the return type be an IJavaObject:
public static TResult JavaCast<TResult>(this IJavaObject instance) where TResult : class, IJavaObject
I have an object that actually is a .net object, and does not implement IJavaObject. However, it was originally obtained via GetItem and thus wrapped into an Java Object. I have no access to the original adapter at this point of the code.
Therefore, I have no way to convert this Java Object back to my .net object, short of doing manual reflection. (JavaConvert.FromJavaObject<> would work, but it is marked as internal.)
I have checked the definition of BaseAdapter<T> and Javacast.
Screencast regarding same:
I’ll need confirmation from the developer if this is a bug.
Leaving as NEW for now.
To some extent, the problem is that Java.Lang.Object exists as parameter or return types at all; see Bug #6085. That won't be fixed anytime soon.
In the meantime, how are you getting the internal wrapper? Ideally, you shouldn't know that it's there...which clearly isn't happening. Adding some public "unwrap" method also isn't ideal, as then you'd need to know it exists so that you can manually unwrap instances, which just seems like a different kind of pain.
I'd like to better understand your usage scenario, so I can see if there's a better way to support it.
I am closing this bug due to a lack of response requested by https://bugzilla.xamarin.com/show_bug.cgi?id=21253#c2
Please feel free to reopen this bug once you can add sufficient information.