Skip to content

Commit

Permalink
[api-merge] Add removed-since info (#8897)
Browse files Browse the repository at this point in the history
Our process of building `Mono.Android.dll`'s `api.xml` using
`api-merge` does not take into consideration that API could be
*removed* from `android.jar`.

Track API removals by adding a `removed-since="API-LEVEL"` attribute
to API members that no longer exists.

Note this information is not currently consumed anywhere, but having
this data will allow us to determine if we want to make modifications
to handle it in future PRs.  Potentially
[`[UnsupportedOSPlatformAttribute]`][0] is a good solution for this.

[0]: https://learn.microsoft.com/dotnet/api/system.runtime.versioning.unsupportedosplatformattribute?view=net-8.0
  • Loading branch information
jpobst authored Apr 26, 2024
1 parent 24fb6ab commit 944d306
Show file tree
Hide file tree
Showing 2 changed files with 663 additions and 646 deletions.
17 changes: 17 additions & 0 deletions build-tools/api-merge/ApiDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ public void Merge (XDocument n, string apiLocation)
}
}
#endif
foreach (var smember in stype.Elements ()) {
var nmember = GetMember (ntype, smember);

if (nmember is null)
SetRemovedSince (smember, platform);
}

foreach (var nmember in ntype.Elements ()) {
var smember = GetMember (stype, nmember);
if (smember == null) {
Expand Down Expand Up @@ -308,6 +315,16 @@ void SetDeprecatedSince (XElement element, string platform)
deprecatedSince.SetValue (platform);
}

void SetRemovedSince (XElement element, string platform)
{
if (element is null)
return;

// Don't replace an earlier removal, as we want to keep the earliest one.
if (!element.Attributes ("removed-since").Any ())
element.Add (new XAttribute ("removed-since", platform));
}

XElement AddWithLocation (XElement old, XElement child, string location)
{
child.Add (new XAttribute ("merge.SourceFile", location));
Expand Down
Loading

0 comments on commit 944d306

Please sign in to comment.