Skip to content

Commit 944d306

Browse files
authored
[api-merge] Add removed-since info (#8897)
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
1 parent 24fb6ab commit 944d306

File tree

2 files changed

+663
-646
lines changed

2 files changed

+663
-646
lines changed

build-tools/api-merge/ApiDescription.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ public void Merge (XDocument n, string apiLocation)
121121
}
122122
}
123123
#endif
124+
foreach (var smember in stype.Elements ()) {
125+
var nmember = GetMember (ntype, smember);
126+
127+
if (nmember is null)
128+
SetRemovedSince (smember, platform);
129+
}
130+
124131
foreach (var nmember in ntype.Elements ()) {
125132
var smember = GetMember (stype, nmember);
126133
if (smember == null) {
@@ -308,6 +315,16 @@ void SetDeprecatedSince (XElement element, string platform)
308315
deprecatedSince.SetValue (platform);
309316
}
310317

318+
void SetRemovedSince (XElement element, string platform)
319+
{
320+
if (element is null)
321+
return;
322+
323+
// Don't replace an earlier removal, as we want to keep the earliest one.
324+
if (!element.Attributes ("removed-since").Any ())
325+
element.Add (new XAttribute ("removed-since", platform));
326+
}
327+
311328
XElement AddWithLocation (XElement old, XElement child, string location)
312329
{
313330
child.Add (new XAttribute ("merge.SourceFile", location));

0 commit comments

Comments
 (0)