Closed jpobst closed 2 weeks ago
With this updated api-VanillaIceCream.xml
, the only reported constant mismatch is the one reported in #9000, which was caused by an error in our enumification process:
Mismatch: android/app/ApplicationExitInfo.REASON_OTHER 10 != 13 [API-30]
Draft commit message:
Context: https://github.com/xamarin/xamarin-android/issues/9000
Context: ac3b405759dfcb3f24a551e8f408ed551b78612f
In Issue #9000, we learned that:
- Constant values can change between Android API levels
- `api-merge` does not update constant values in the final `api.xml`
if they do change
Update `api-merge` to update constant values if they change, and update
`api-VanillaIceCream.xml` with the new `api-merge` logic.
@jpobst wrote:
With this updated api-VanillaIceCream.xml, the only reported constant mismatch is the one reported in #9000, which was caused by an error in our enumification process:
Mismatch: android/app/ApplicationExitInfo.REASON_OTHER 10 != 13 [API-30]
Where does this "Mismatch" message come from? I don't see anything in this PR which would emit such a message, and git grep 'Mismatch: '
doesn't find anything either.
It is a quick local script I wrote that compares map.csv
to api.xml
.
We can leave the bones of it here for future reference:
class MismatchedEnumValues
{
static string enum_csv = @"C:\code\xamarin-android\src\Mono.Android\map.csv";
static string api_xml = @"C:\code\xamarin-android-backport\src\Mono.Android\Profiles\api-VanillaIceCream.xml";
public static void Do ()
{
var consts = ConstantsParser.FromEnumMapCsv (enum_csv).Where (c => c.Action.In (ConstantAction.Enumify)).ToList ();
var xml = new XmlDocument ();
xml.Load (api_xml);
foreach (var c in consts) {
var package = c.JavaPackage.StartsWith ("I:") ? c.JavaPackage.Substring (2) : c.JavaPackage;
var elem = xml.SelectSingleNode ($"/api/package[@name='{package.Replace ('/', '.')}']/*[@name='{c.JavaType.Replace ('$', '.')}']/field[@name='{c.JavaName}']");
if (elem is null) {
Console.WriteLine ($"Orphan: Could not find {c.JavaPackage}.{c.JavaType}.{c.JavaName} [API-{c.ApiLevel}]");
continue;
}
var value = elem.Attributes? ["value"]?.Value ?? "";
if (value != c.Value)
Console.WriteLine ($"Mismatch: {c.JavaPackage}/{c.JavaType}.{c.JavaName} {c.Value} != {value} [API-{c.ApiLevel}]");
}
}
}
(Requires a reference to Java.Interop.Tools.Generator
project.)
Context: https://github.com/xamarin/xamarin-android/issues/9000
In https://github.com/xamarin/xamarin-android/issues/9000, we learned that:
api-merge
does not update constant values in the finalapi.xml
if they do changeUpdate
api-merge
to update constant values if they change, and updateapi-VanillaIceCream.xml
with the newapi-merge
logic.