…1369)
Context: bc44f08
If "something goes wrong" and the `*.jlo.xml` files contain
`//jcw-types/type` elements that are *missing* the `//type/@package`
attribute, then an exception is thrown:
System.InvalidOperationException: Missing required attribute 'package'
at Java.Interop.Tools.JavaCallableWrappers.Extensions.XmlExtensions.GetRequiredAttribute(XElement xml, String name)
at Java.Interop.Tools.JavaCallableWrappers.Adapters.XmlImporter.ImportType(XElement xml)
at Java.Interop.Tools.JavaCallableWrappers.Adapters.XmlImporter.Import(XElement xml)
at Xamarin.Android.Tasks.JavaObjectsXmlFile.Import(String filename, JavaObjectsXmlFileReadType readType)
at Xamarin.Android.Tasks.GenerateJavaCallableWrappers.GenerateWrappers(List`1 assemblies)
at Xamarin.Android.Tasks.GenerateJavaCallableWrappers.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute()
Which is all well and good, except ***I have no idea what's broken***.
*Something* within dotnet/android should be updated so that the file
causing the exception is mentioned, but we can also improve the
`InvalidOperationException` to contain at least a "breadcrumb" for
what's going wrong.
Update the `InvalidOperationException` to also include the contents
of the `XElement.ToString()` which is missing the required attribute.
We can then at least search file contents to find the "offending" file.
This provides a more useful exception message:
System.InvalidOperationException: Missing required attribute 'package' within element `<type name="SKCanvasElementImpl" package="" application_java_class="android.support.multidex.MultiDexApplication" mono_runtime_initialization="mono.MonoPackageManager.LoadApplication (context);" extends_type="Uno.WinUI.Graphics2DSK.SKCanvasElement" partial_assembly_qualified_name="SKCanvasElementImpl, SamplesApp">
<constructors>
<constructor name="SKCanvasElementImpl" method="n_.ctor:(Landroid/content/Context;)V:" jni_signature="(Landroid/content/Context;)V" managed_parameters="Android.Content.Context, Mono.Android" params="android.content.Context p0" retval="void" is_dynamically_registered="True" super_call="p0" activate_call="p0" />
</constructors>
</type>`.
at Java.Interop.Tools.JavaCallableWrappers.Extensions.XmlExtensions.GetRequiredAttribute(XElement xml, String name)
at Java.Interop.Tools.JavaCallableWrappers.Adapters.XmlImporter.ImportType(XElement xml)
at Java.Interop.Tools.JavaCallableWrappers.Adapters.XmlImporter.Import(XElement xml)
at Xamarin.Android.Tasks.JavaObjectsXmlFile.Import(String filename, JavaObjectsXmlFileReadType readType)
at Xamarin.Android.Tasks.GenerateJavaCallableWrappers.GenerateWrappers(List`1 assemblies)
at Xamarin.Android.Tasks.GenerateJavaCallableWrappers.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute()
Which shows *two* problems:
1. The `package` attribute *is* present, but
2. The `package` attribute is the empty string.
Which should be supported! The global package is A Thing That Exists™;
it should be supported! (Has *been* supported?!)
Update `XmlImporter.ImportType()` so that `package` is *not* required.
Update `tests/Java.Interop.Tools.JavaCallableWrappers-Tests` to add
an explicit test for a type in the Java global package.