You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaDictionary.Get() can currently throw the following two different exceptions instead:
InvalidCastException
NullReferenceException
Depending on the goals of the Java exception wrapping, throwing different System exceptions from JavaDictionary.Get() than the ones documented for IDictionary.Item[Object] might be unintended. Maybe only the exception conditions documented for IDictionary.Item[Object] (like "key is null") need to be surfaced as System exceptions, and other exceptions, if any, can be left as Java exceptions?
Related scenarios
If this JavaDictionary.Get() scenario does look good to change, then there are probably a few additional similar cases to change too.
Another slightly different case is JavaCollection.Add(). I think it might have been wrapped because JavaCollection implements ICollection, but I just noticed today that the non-generic ICollection interface doesn't include an Add() method. Only the generic ICollection<T> includes an Add() method. So maybe JavaCollection.Add() doesn't need to wrap any exceptions?
The text was updated successfully, but these errors were encountered:
Additional background context: From a first quick chat with @jonpryor, it sounded like this might be unintentional, so I added an issue here to help with tracking potential changes to the behavior.
One more interesting case is AndroidClientHandler, which currently throws exceptions like Java.Net.UnknownHostException instead of System.Net.Http.HttpRequestException. I think that type might have been unintentionally overlooked in the first set of changes because it isn't a binding for an existing Android or Java type.
Context
60363ef added an option to wrap
Java
exception types in .NET exception types for certain Android APIs.JavaDictionary.Get()
is an example:https://github.com/xamarin/xamarin-android/blob/8d7557aad23a3c0724e1996aade3072b1a09f298/src/Mono.Android/Android.Runtime/JavaDictionary.cs#L72-L86
Expected behavior
JavaDictionary
inherits fromJava.Lang.Object
and implementsIDictionary
:https://github.com/xamarin/xamarin-android/blob/8d7557aad23a3c0724e1996aade3072b1a09f298/src/Mono.Android/Android.Runtime/JavaDictionary.cs#L12
The documentation for the
IDictionary.Item[Object]
indexer property mentions two exceptions:ArgumentNullException
NotSupportedException
Actual behavior
JavaDictionary.Get()
can currently throw the following two different exceptions instead:InvalidCastException
NullReferenceException
Depending on the goals of the Java exception wrapping, throwing different System exceptions from
JavaDictionary.Get()
than the ones documented forIDictionary.Item[Object]
might be unintended. Maybe only the exception conditions documented forIDictionary.Item[Object]
(like "key
isnull
") need to be surfaced as System exceptions, and other exceptions, if any, can be left as Java exceptions?Related scenarios
If this
JavaDictionary.Get()
scenario does look good to change, then there are probably a few additional similar cases to change too.Another slightly different case is
JavaCollection.Add()
. I think it might have been wrapped becauseJavaCollection
implementsICollection
, but I just noticed today that the non-genericICollection
interface doesn't include anAdd()
method. Only the genericICollection<T>
includes anAdd()
method. So maybeJavaCollection.Add()
doesn't need to wrap any exceptions?The text was updated successfully, but these errors were encountered: