Skip to content

Commit 39a3b87

Browse files
authored
[ApiXmlAdjuster] Add additional expected attributes (#476)
Context: dotnet/android#3223 Context: https://jenkins.mono-project.com/job/xamarin-android-pr-pipeline-debug/619/ Commit a30523e breaks the xamarin-android build, as it introduces new XML attributes to `class-parse` output which `Xamarin.Android.Tools.ApiXmlAdjuster` doesn't appreciate: Unhandled Exception: System.Exception: …/xamarin-android/bin/BuildDebug/api/api-10.xml.class-parse (16,7): Element 'class' has an unexpected attribute: 'source-file-name'. Expected attributes are: source-file-name at Xamarin.Android.Tools.ApiXmlAdjuster.XmlUtil.CheckExtraneousAttributes (System.String elementName, System.Xml.XmlReader reader, System.String[] expected) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiLoaderExtensions.LoadTypeAttributes (Xamarin.Android.Tools.ApiXmlAdjuster.JavaType type, System.Xml.XmlReader reader, System.String[] otherAllowedAttributes) at Xamarin.Android.Tools.ApiXmlAdjuster.JavaApiLoaderExtensions.Load (Xamarin.Android.Tools.ApiXmlAdjuster.JavaClass kls, System.Xml.XmlReader reader) Update `Xamarin.Android.Tools.ApiXmlAdjuster` so that the new attributes introduced in a30523e are considered acceptable. Additionally, fix the error message so that it *actually* lists the "expected attributes", instead of repeating the *un*-expected attribute.
1 parent 6dd1cf4 commit 39a3b87

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Xamarin.Android.Tools.ApiXmlAdjuster/JavaApiXmlLoaderExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@ public static void Load (this JavaPackage package, XmlReader reader, bool isRefe
8484
static readonly string [] expected_type_attributes = new String [] {
8585
"abstract",
8686
"deprecated",
87+
"enclosing-method-jni-type",
88+
"enclosing-method-name",
89+
"enclosing-method-signature",
8790
"final",
91+
"jni-signature",
8892
"name",
93+
"source-file-name",
8994
"static",
9095
"visibility",
91-
"jni-signature",
9296
};
9397

9498
internal static void LoadTypeAttributes (this JavaType type, XmlReader reader, params string [] otherAllowedAttributes)

src/Xamarin.Android.Tools.ApiXmlAdjuster/XmlUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static Exception UnexpectedAttribute (XmlReader reader, string elementNam
2424
{
2525
if (reader.NodeType != XmlNodeType.Attribute)
2626
throw new ArgumentException (string.Format ("Internal error: XmlReader should be positioned on attribute, but it is on {0}", reader.NodeType));
27-
return new Exception (string.Format ("{0}: Element '{1}' has an unexpected attribute: '{2}'. Expected attributes are: {2}",
27+
return new Exception (string.Format ("{0}: Element '{1}' has an unexpected attribute: '{2}'. Expected attributes are: {3}",
2828
GetLocation (reader), elementName, reader.LocalName, string.Join (", ", expected)));
2929
}
3030

0 commit comments

Comments
 (0)