diff --git a/build-tools/api-merge/ApiDescription.cs b/build-tools/api-merge/ApiDescription.cs index 85eaf4a2fa3..b0965b5ac01 100644 --- a/build-tools/api-merge/ApiDescription.cs +++ b/build-tools/api-merge/ApiDescription.cs @@ -15,6 +15,7 @@ class ApiDescription { public static bool HackGenericTypeParameterNames = true; XDocument Contents; + XAttribute contentsPlatform; Dictionary Types = new Dictionary(); public ApiDescription (string source) @@ -26,6 +27,8 @@ public ApiDescription (string source) foreach (var package in api.Elements ("package")) { AddPackage (package, platform); } + + contentsPlatform = api.Attributes ("platform").LastOrDefault (); } XElement GetRoot (XDocument doc, string sourcePath, out string platform) @@ -52,6 +55,12 @@ public void Merge (string apiLocation) var n = XDocument.Load (apiLocation); string platform = null; XElement api = GetRoot (n, apiLocation, out platform); + if (!String.IsNullOrEmpty (platform) && contentsPlatform != null) { + // Update the api platform to the current document's value. Documents are + // sorted in ascending order, so we'll end up with the latest platform in + // the merged document, as it should be. + contentsPlatform.SetValue (platform); + } foreach (var npackage in api.Elements ("package")) { var spackage = GetPackage ((string) npackage.Attribute ("name"));