[generator] Use new ObsoletedOSPlatformAttribute for generated code (#15941)

- Part of https://github.com/xamarin/xamarin-macios/issues/15849
- A bit of dead code was removed while I was reviewing things.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This commit is contained in:
Chris Hamons 2022-10-06 11:15:51 -05:00 коммит произвёл GitHub
Родитель d8b991e0e6
Коммит 83ed66e7d6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
32 изменённых файлов: 133 добавлений и 215 удалений

Просмотреть файл

@ -13,6 +13,7 @@ namespace ARKit {
#if NET
[SupportedOSPlatform ("ios14.0")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[iOS (14,0)]
#endif
@ -22,6 +23,7 @@ namespace ARKit {
#if NET
[SupportedOSPlatform ("ios14.0")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[iOS (14,0)]
#endif

Просмотреть файл

@ -462,10 +462,10 @@ namespace CoreFoundation {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11")]
[ObsoletedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
#else
[Deprecated (PlatformName.iOS, 9, 0)]
[Deprecated (PlatformName.MacOSX, 10, 11)]
@ -479,10 +479,10 @@ namespace CoreFoundation {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'NSUrlSession' instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message : "Use 'NSUrlSession' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 11, message : "Use 'NSUrlSession' instead.")]
@ -502,10 +502,10 @@ namespace CoreFoundation {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11")]
[ObsoletedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
#else
[Deprecated (PlatformName.iOS, 9,0)]
[Deprecated (PlatformName.MacOSX, 10,11)]
@ -520,10 +520,10 @@ namespace CoreFoundation {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'NSUrlSession' instead.")]
#else
[Deprecated (PlatformName.iOS, 9,0, message : "Use 'NSUrlSession' instead.")]
[Deprecated (PlatformName.MacOSX, 10,11, message : "Use 'NSUrlSession' instead.")]

Просмотреть файл

@ -149,12 +149,10 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.10")]
[UnsupportedOSPlatform ("ios8.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.10")]
[ObsoletedOSPlatform ("ios8.0")]
[ObsoletedOSPlatform ("ios9.0")]
#else
[Deprecated (PlatformName.iOS, 8, 0)]
[Deprecated (PlatformName.TvOS, 9, 0)]
@ -185,12 +183,10 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.10")]
[UnsupportedOSPlatform ("ios8.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.10")]
[ObsoletedOSPlatform ("ios8.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
#else
[Deprecated (PlatformName.iOS, 8, 0)]
[Deprecated (PlatformName.TvOS, 9, 0)]
@ -351,9 +347,9 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.10")]
[ObsoletedOSPlatform ("ios9.0")]
#else
[Deprecated (PlatformName.iOS, 9,0)]
@ -367,10 +363,10 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CopyMasterTimebase' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CopyMasterTimebase' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CopyMasterTimebase' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'CopyMasterTimebase' instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message : "Use 'CopyMasterTimebase' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 11, message : "Use 'CopyMasterTimebase' instead.")]
@ -389,9 +385,9 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.10")]
[ObsoletedOSPlatform ("ios9.0")]
#else
[Deprecated (PlatformName.iOS, 9,0)]
@ -405,10 +401,10 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CopyMasterClock' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CopyMasterClock' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CopyMasterClock' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'CopyMasterClock' instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message : "Use 'CopyMasterClock' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 11, message : "Use 'CopyMasterClock' instead.")]
@ -427,8 +423,8 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.11")]
[ObsoletedOSPlatform ("ios9.0")]
#else
@ -443,10 +439,10 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CopyMaster' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CopyMaster' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CopyMaster' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'CopyMaster' instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message : "Use 'CopyMaster' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 11, message : "Use 'CopyMaster' instead.")]
@ -465,8 +461,8 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.11")]
[ObsoletedOSPlatform ("ios9.0")]
#else
@ -481,10 +477,10 @@ namespace CoreMedia {
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CopyUltimateMasterClock' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CopyUltimateMasterClock' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CopyUltimateMasterClock' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'CopyUltimateMasterClock' instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message : "Use 'CopyUltimateMasterClock' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 11, message : "Use 'CopyUltimateMasterClock' instead.")]
@ -616,9 +612,7 @@ namespace CoreMedia {
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.10")]
[UnsupportedOSPlatform ("ios8.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.10")]
[ObsoletedOSPlatform ("ios8.0")]
@ -642,9 +636,7 @@ namespace CoreMedia {
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.10")]
[UnsupportedOSPlatform ("ios8.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.10")]
[ObsoletedOSPlatform ("ios8.0")]
@ -663,9 +655,7 @@ namespace CoreMedia {
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.10")]
[UnsupportedOSPlatform ("ios8.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
[ObsoletedOSPlatform ("macos10.10")]
[ObsoletedOSPlatform ("ios8.0")]
@ -771,9 +761,6 @@ namespace CoreMedia {
[SupportedOSPlatform ("ios9.0")]
[SupportedOSPlatform ("macos10.11")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CMTimebaseGetMasterTimebase' instead.")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CMTimebaseGetMasterTimebase' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CMTimebaseGetMasterTimebase' instead.")]
@ -795,9 +782,7 @@ namespace CoreMedia {
[SupportedOSPlatform ("macos10.11")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'CMTimebaseGetMasterClock' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CMTimebaseGetMasterClock' instead.")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CMTimebaseGetMasterClock' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CMTimebaseGetMasterClock' instead.")]
@ -816,9 +801,6 @@ namespace CoreMedia {
[SupportedOSPlatform ("ios9.0")]
[SupportedOSPlatform ("macos10.11")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CMTimebaseGetMaster' instead.")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CMTimebaseGetMaster' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CMTimebaseGetMaster' instead.")]
@ -839,9 +821,6 @@ namespace CoreMedia {
[SupportedOSPlatform ("ios9.0")]
[SupportedOSPlatform ("macos10.11")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos9.0")]
[UnsupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'CMTimebaseGetUltimateMasterClock' instead.")]
[ObsoletedOSPlatform ("macos10.11", "Use 'CMTimebaseGetUltimateMasterClock' instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use 'CMTimebaseGetUltimateMasterClock' instead.")]

Просмотреть файл

@ -24,6 +24,7 @@ namespace NetworkExtension {
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
#else
[iOS (13,0)]
#endif
@ -37,6 +38,7 @@ namespace NetworkExtension {
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
#else
[iOS (13,0)]
#endif

Просмотреть файл

@ -22,6 +22,7 @@ namespace NetworkExtension {
[SupportedOSPlatform ("macos10.11")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[Mac (10,11)]
#endif

Просмотреть файл

@ -47,6 +47,7 @@ namespace PassKit {
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("macos11.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[Watch (4,0)]
[iOS (11,0)]
@ -60,6 +61,7 @@ namespace PassKit {
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("macos11.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[Watch (4,0)]
[iOS (11,0)]

Просмотреть файл

@ -23,6 +23,7 @@ namespace PdfKit {
[SupportedOSPlatform ("macos10.12")]
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[Mac (10,12)]
#endif
@ -38,6 +39,7 @@ namespace PdfKit {
[SupportedOSPlatform ("macos10.12")]
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[Mac (10,12)]
#endif
@ -55,6 +57,7 @@ namespace PdfKit {
[SupportedOSPlatform ("macos10.12")]
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[Mac (10,12)]
#endif
@ -77,6 +80,7 @@ namespace PdfKit {
[SupportedOSPlatform ("macos10.13")]
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
#else
[Mac (10,13)]
#endif

Просмотреть файл

@ -16,6 +16,7 @@ namespace WebKit {
[SupportedOSPlatform ("macos11.3")]
[SupportedOSPlatform ("ios14.5")]
[SupportedOSPlatform ("maccatalyst14.5")]
[UnsupportedOSPlatform ("tvos")]
#else
[Mac (11,3)]
[iOS (14,5)]

Просмотреть файл

@ -932,43 +932,25 @@ public abstract class AvailabilityBaseAttribute : Attribute {
}
}
void GenerateObsolete (StringBuilder builder)
{
GeneratePlatformDefine (builder);
builder.Append ("[Obsolete (\"Starting with ");
GeneratePlatformNameAndVersion (builder);
if (!String.IsNullOrEmpty (Message))
builder.Append (' ').Append (Message);
else
builder.Append ('.'); // intro check messages to they end with a '.'
// TODO add a URL (wiki?) and DiagnosticId (one per platform?) for documentation
builder.AppendLine ("\", DiagnosticId = \"BI1234\", UrlFormat = \"https://github.com/xamarin/xamarin-macios/wiki/Obsolete\")]");
builder.AppendLine ("#endif");
}
void GenerateAdvice (StringBuilder builder)
{
GeneratePlatformDefine (builder);
builder.Append ("[Advice (\"Starting with ");
GeneratePlatformNameAndVersion (builder);
if (!String.IsNullOrEmpty (Message))
builder.Append (' ').Append (Message);
else
builder.Append ('.'); // intro check messages to they end with a '.'
// TODO add a URL (wiki?) and DiagnosticId (one per platform?) for documentation
builder.AppendLine ("\")]");
builder.AppendLine ("#endif");
}
void GenerateUnsupported (StringBuilder builder)
{
builder.Append ("[UnsupportedOSPlatform (\"");
GeneratePlatformNameAndVersion (builder);
builder.AppendLine ("\")]");
builder.Append ("\"");
if (!String.IsNullOrEmpty (Message))
builder.Append (", \"").Append (Message).Append ('"');
builder.AppendLine (")]");
}
void GenerateDeprecated (StringBuilder builder)
{
builder.Append ("[ObsoletedOSPlatform (\"");
GeneratePlatformNameAndVersion (builder);
builder.Append ("\"");
if (!String.IsNullOrEmpty (Message))
builder.Append (", \"").Append (Message).Append ('"');
builder.AppendLine (")]");
}
void GenerateSupported (StringBuilder builder)
@ -1012,11 +994,9 @@ public abstract class AvailabilityBaseAttribute : Attribute {
GenerateSupported (builder);
break;
case AvailabilityKind.Deprecated:
GenerateAdvice (builder);
GenerateUnsupported (builder);
GenerateDeprecated (builder);
break;
case AvailabilityKind.Obsoleted:
GenerateObsolete (builder);
GenerateUnsupported (builder);
break;
case AvailabilityKind.Unavailable:

Просмотреть файл

@ -3542,14 +3542,16 @@ public partial class Generator : IMemberGatherer {
}
}
static void AddImpliedCatalyst (List<AvailabilityBaseAttribute> memberAvailability)
static void AddImpliedPlatforms (List<AvailabilityBaseAttribute> memberAvailability)
{
if (!PlatformMarkedUnavailable (PlatformName.MacCatalyst, memberAvailability) &&
!PlatformHasIntroduced (PlatformName.MacCatalyst, memberAvailability)) {
foreach (var attr in memberAvailability.Where (v => v.Platform == PlatformName.iOS).ToList()) {
var newAttribute = CloneFromOtherPlatform (attr, PlatformName.MacCatalyst);
if (IsValidToCopyTo (memberAvailability, newAttribute, allowIntroducedOnUnavailable: true)) {
memberAvailability.Add (newAttribute);
foreach (var platform in new [] { PlatformName.MacCatalyst, PlatformName.TvOS }) {
if (!PlatformMarkedUnavailable (platform, memberAvailability) &&
!PlatformHasIntroduced (platform, memberAvailability)) {
foreach (var attr in memberAvailability.Where (v => v.Platform == PlatformName.iOS).ToList()) {
var newAttribute = CloneFromOtherPlatform (attr, platform);
if (IsValidToCopyTo (memberAvailability, newAttribute, allowIntroducedOnUnavailable: true)) {
memberAvailability.Add (newAttribute);
}
}
}
}
@ -3566,7 +3568,7 @@ public partial class Generator : IMemberGatherer {
}
// Especially for TV and Catalyst some entire namespaces are removed via framework_sources.
// However, almost all of those bindings are [iOS] which AddImpliedCatalyst and other places
// However, almost all of those bindings are [iOS] which AddImpliedPlatforms and other places
// happily turn into other platforms.
// As a final step, if we are on a namespace that flatly doesn't exist, drop it. Then if we don't have a not supported, add it
void StripIntroducedOnNamespaceNotIncluded (List<AvailabilityBaseAttribute> memberAvailability, MemberInfo context)
@ -3575,7 +3577,7 @@ public partial class Generator : IMemberGatherer {
var droppedPlatforms = new HashSet<PlatformName>();
// Walk all members and look for introduced that are nonsense for our containing class's platform
foreach (var introduced in memberAvailability.Where (a => a.AvailabilityKind == AvailabilityKind.Introduced).ToList()) {
foreach (var introduced in memberAvailability.Where (a => a.AvailabilityKind == AvailabilityKind.Introduced || a.AvailabilityKind == AvailabilityKind.Deprecated).ToList()) {
// Hack - WebKit namespace has two distinct implementations with different types
// It can not be hacked in IsInSupportedFramework as AddUnlistedAvailability
// will add iOS implied to the mac version and so on. So hard code it here...
@ -3616,27 +3618,6 @@ public partial class Generator : IMemberGatherer {
}
}
// Both deprecated and obsolete turn into UnsupportedOSPlatform, so we have to match more generally
static bool ImpliedKindsMatch (AvailabilityKind left, AvailabilityKind right)
{
return ConvertKindToMatchKind (left) == ConvertKindToMatchKind (right);
}
static bool ConvertKindToMatchKind (AvailabilityKind kind)
{
switch (kind)
{
case AvailabilityKind.Introduced:
return true;
case AvailabilityKind.Deprecated:
case AvailabilityKind.Obsoleted:
case AvailabilityKind.Unavailable:
return false;
default:
throw new NotImplementedException ($"ConvertKindToMatchKind with unknown kind {kind}");
}
}
// This assumes the compiler implements property methods as get_ or set_ prefixes
static PropertyInfo GetProperyFromGetSetMethod (MethodInfo method)
{
@ -3717,17 +3698,17 @@ public partial class Generator : IMemberGatherer {
// Copy down any unavailable from the parent before expanding, since a [NoMacCatalyst] on the type trumps [iOS] on a member
CopyValidAttributes (memberAvailability, availabilityToConsider.Where (attr => attr.AvailabilityKind != AvailabilityKind.Introduced));
// Add implied catalyst from [iOS] _before_ copying down from parent if no catalyst attributes
// Add implied catalyst\TVOS from [iOS] _before_ copying down from parent if no catalyst\TVOS attributes
// As those take precedent. We will do this a second time later in a moment..
AddImpliedCatalyst (memberAvailability);
AddImpliedPlatforms (memberAvailability);
// Now copy it down introduced from the parent
CopyValidAttributes (memberAvailability, availabilityToConsider.Where (attr => attr.AvailabilityKind == AvailabilityKind.Introduced));
// Now expand the implied catalyst from [iOS] a second time
// Now expand the implied catalyst\TVOS from [iOS] a second time
// This is needed in some cases where the only iOS information is in the
// parent context, but we want to let any local iOS override a catalyst on the parent
AddImpliedCatalyst (memberAvailability);
// parent context, but we want to let any local iOS override a catalyst\TVOS on the parent
AddImpliedPlatforms (memberAvailability);
if (!BindThirdPartyLibrary) {
// If all of this implication gives us something silly, like being introduced

Просмотреть файл

@ -216,11 +216,11 @@ namespace Xamarin.Tests
if (platform != attributePlatform)
continue;
if (attr is UnsupportedOSPlatformAttribute) {
// At this point we can't ascertain that the API is available, only that it's unavailable,
// so only return in that case. We need to check the SupportedOSPlatform attributes
// to see if the API is available.
if (attr is UnsupportedOSPlatformAttribute || attr is ObsoletedOSPlatformAttribute) {
var isUnsupported = version is not null && targetPlatform.Version >= version;
// At this point we can't ascertain that the API is available, only that it's unavailable,
// so only return in that case. We need to check the SupportedOSPlatform attributes
// to see if the API is available.
if (isUnsupported)
return false;
}

Просмотреть файл

@ -241,7 +241,7 @@ namespace GeneratorTests
var preserves = allMembers.Sum ((v) => v.CustomAttributes.Count ((ca) => ca.AttributeType.Name == attrib));
Assert.AreEqual (
#if NET
36, // This number should be lower - https://github.com/xamarin/xamarin-macios/issues/14802
48, // This number should be lower - https://github.com/xamarin/xamarin-macios/issues/14802
#else
10,
#endif

Просмотреть файл

@ -332,6 +332,10 @@ namespace Introspection {
if (uaPlatform == Platform)
return true;
}
if (a is ObsoletedOSPlatformAttribute ab && ab.TryParse (out ApplePlatform? ubPlatform, out version)) {
if (ubPlatform == Platform)
return true;
}
#else
if (ca is UnavailableAttribute ua) {
if (ua.Platform == Platform)

Просмотреть файл

@ -23,6 +23,7 @@ using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using NUnit.Framework;
using Xamarin.Utils;
@ -192,6 +193,15 @@ namespace Introspection {
}
}
public bool MemberHasObsolete (MemberInfo member)
{
#if NET
return member.GetCustomAttributes<ObsoletedOSPlatformAttribute> (false).Any();
#else
return member.GetCustomAttribute<ObsoleteAttribute> () != null;
#endif
}
/// <summary>
/// Gets the assembly on which the test fixture will reflect the NSObject-derived types.
/// The default implementation returns the assembly where NSObject is defined, e.g.

Просмотреть файл

@ -244,8 +244,7 @@ namespace Introspection {
{
if (member == null)
return false;
var ca = member.GetCustomAttribute<ObsoleteAttribute> ();
return ca != null || base.SkipDueToAttribute (member);
return MemberHasObsolete (member) || base.SkipDueToAttribute (member);
}
[Test]

Просмотреть файл

@ -199,7 +199,7 @@ namespace Introspection {
if (p.PropertyType.FullName != NSStringType)
continue;
if (p.GetCustomAttribute<ObsoleteAttribute> () != null)
if (MemberHasObsolete (p))
continue;
string name;

Просмотреть файл

@ -771,13 +771,8 @@ namespace Introspection
return false;
if (mi.GetCustomAttributes<ObsoleteAttribute> (true).Any ())
return true;
#if NET
if (mi.GetCustomAttributes<UnsupportedOSPlatformAttribute> (true).Any ((v) => v.TryParse (out ApplePlatform? platform, out var _) && platform == PlatformInfo.Host.Name))
if (MemberHasObsolete (mi))
return true;
#else
if (mi.GetCustomAttributes<ObsoletedAttribute> (true).Any ())
return true;
#endif
return IsObsolete (mi.DeclaringType);
}

Просмотреть файл

@ -43,6 +43,7 @@ namespace Extrospection
return false;
}
// Confusingly enough, ObsoletedOSPlatformAttribute is a deprecation not obsolete attribute in NET7
public static bool HasDeprecated (CustomAttribute attribute, Platforms platform) => HasMatchingPlatformAttribute ("DeprecatedAttribute", attribute, platform);
public static bool HasObsoleted (CustomAttribute attribute, Platforms platform) => HasMatchingPlatformAttribute ("ObsoletedAttribute", attribute, platform);
@ -63,8 +64,16 @@ namespace Extrospection
return false;
}
public static bool HasObsoletedOSPlatform (CustomAttribute attribute, Platforms platform)
{
if (attribute.Constructor.DeclaringType.Name == "ObsoletedOSPlatformAttribute")
return IsOSPlatformAttribute (attribute, platform);
return false;
}
public static bool HasObsolete (CustomAttribute attribute, Platforms platform)
{
// This intentionally does not include "ObsoletedOSPlatformAttribute", as that is for deprecation not obsolete
return attribute.Constructor.DeclaringType.Name == "ObsoleteAttribute";
}
@ -85,7 +94,7 @@ namespace Extrospection
version = new Version ((int)attribute.ConstructorArguments[1].Value, (int)attribute.ConstructorArguments[2].Value, (int)attribute.ConstructorArguments[3].Value);
return true;
default:
throw new InvalidOperationException ("GetPlatformVersion with unexpected number of arguments {attribute.ConstructorArguments.Count}");
throw new InvalidOperationException ($"GetPlatformVersion with unexpected number of arguments {attribute.ConstructorArguments.Count} {attribute.Constructor.DeclaringType.Name}");
}
}
@ -106,16 +115,31 @@ namespace Extrospection
if (Skip (item))
return false;
// Properties are a special case as it is generated on the property itself and not the individual get_ \ set_ methods
// Cecil does not have a link between the MethodDefinition we have and the hosting PropertyDefinition, so we have to dig to find the match
if (item is MethodDefinition method) {
PropertyDefinition property = method.DeclaringType.Properties.FirstOrDefault (p => p.GetMethod == method || p.SetMethod == method);
if (property != null && HasAnyDeprecationForCurrentPlatform (property)) {
return true;
}
}
// This allows us to accept [Deprecated (iOS)] for watch and tv, which many of our bindings currently have
// If we want to force seperate tv\watch attributes remove GetRelatedPlatforms and just check Helpers.Platform
// If we want to force separate tv\watch attributes remove GetRelatedPlatforms and just check Helpers.Platform
if (Helpers.IsDotNet) {
foreach (var attribute in item.CustomAttributes) {
if (AttributeHelpers.HasObsolete (attribute, Helpers.Platform))
return true;
// The only related platforms for .NET is iOS for Mac Catalyst
if (AttributeHelpers.HasUnsupportedOSPlatform (attribute, Helpers.Platform))
// Consider 'HasObsoletedOSPlatform' (Deprecated) and 'UnsupportedOSPlatform' (Obsoleted/Unavailable)
if (AttributeHelpers.HasObsoletedOSPlatform (attribute, Helpers.Platform) ||
AttributeHelpers.HasUnsupportedOSPlatform (attribute, Helpers.Platform))
return true;
if (Helpers.Platform == Platforms.MacCatalyst && AttributeHelpers.HasUnsupportedOSPlatform (attribute, Platforms.iOS))
// The only related platforms for .NET is iOS for Mac Catalyst
if (Helpers.Platform == Platforms.MacCatalyst &&
(AttributeHelpers.HasObsoletedOSPlatform (attribute, Platforms.iOS) ||
AttributeHelpers.HasUnsupportedOSPlatform (attribute, Platforms.iOS)))
return true;
}
} else {
@ -188,6 +212,7 @@ namespace Extrospection
switch (attrib.AttributeType.Name) {
case "SupportedOSPlatformAttribute":
case "UnsupportedOSPlatformAttribute":
case "ObsoletedOSPlatformAttribute":
var platformName = (string) attrib.ConstructorArguments [0].Value;
return platformName.StartsWith (platform.AsPlatformAttributeString (), StringComparison.OrdinalIgnoreCase);
default:

Просмотреть файл

@ -112,6 +112,10 @@ namespace Extrospection {
if (AttributeHelpers.IsOSPlatformAttribute (ca, Platform))
return false;
break;
case "ObsoletedOSPlatformAttribute":
if (AttributeHelpers.IsOSPlatformAttribute (ca, Platform))
return false;
break;
}
}
return true;

Просмотреть файл

@ -1,3 +0,0 @@
!deprecated-attribute-missing! NSManagedObjectContext::init missing a [Deprecated] attribute
!deprecated-attribute-missing! NSPropertyDescription::isStoredInExternalRecord missing a [Deprecated] attribute
!deprecated-attribute-missing! NSPropertyDescription::setStoredInExternalRecord: missing a [Deprecated] attribute

Просмотреть файл

@ -1,2 +0,0 @@
!deprecated-attribute-missing! CFReadStreamCreateForHTTPRequest missing a [Deprecated] attribute
!deprecated-attribute-missing! CFReadStreamCreateForStreamedHTTPRequest missing a [Deprecated] attribute

Просмотреть файл

@ -1 +0,0 @@
!deprecated-attribute-missing! CIImage::initWithTexture:size:flipped:colorSpace: missing a [Deprecated] attribute

Просмотреть файл

@ -1,2 +0,0 @@
!deprecated-attribute-missing! CLGeocoder::geocodeAddressDictionary:completionHandler: missing a [Deprecated] attribute
!deprecated-attribute-missing! CLPlacemark::addressDictionary missing a [Deprecated] attribute

Просмотреть файл

@ -1,4 +0,0 @@
!deprecated-attribute-missing! CMTimebaseGetMaster missing a [Deprecated] attribute
!deprecated-attribute-missing! CMTimebaseGetMasterClock missing a [Deprecated] attribute
!deprecated-attribute-missing! CMTimebaseGetMasterTimebase missing a [Deprecated] attribute
!deprecated-attribute-missing! CMTimebaseGetUltimateMasterClock missing a [Deprecated] attribute

Просмотреть файл

@ -144,11 +144,3 @@
!extra-enum-value! Managed value 2 for NSItemProviderRepresentationVisibility.Group is available for the current platform while the value in the native header is not
!extra-enum-value! Managed value 2048 for NSUrlBookmarkCreationOptions.WithSecurityScope is available for the current platform while the value in the native header is not
!extra-enum-value! Managed value 4096 for NSUrlBookmarkCreationOptions.SecurityScopeAllowOnlyReadAccess is available for the current platform while the value in the native header is not
!deprecated-attribute-missing! NSDateComponents::setWeek: missing a [Deprecated] attribute
!deprecated-attribute-missing! NSDateComponents::week missing a [Deprecated] attribute
!deprecated-attribute-missing! NSNetService::resolve missing a [Deprecated] attribute
!deprecated-attribute-missing! NSProcessInfo::operatingSystem missing a [Deprecated] attribute
!deprecated-attribute-missing! NSProcessInfo::operatingSystemName missing a [Deprecated] attribute
!deprecated-attribute-missing! NSURLConnection::initWithRequest:delegate: missing a [Deprecated] attribute
!deprecated-attribute-missing! NSURLConnection::initWithRequest:delegate:startImmediately: missing a [Deprecated] attribute
!deprecated-attribute-missing! NSUserDefaults::persistentDomainNames missing a [Deprecated] attribute

Просмотреть файл

@ -1,2 +0,0 @@
!deprecated-attribute-missing! GKLocalPlayer::loadFriendPlayersWithCompletionHandler: missing a [Deprecated] attribute
!deprecated-attribute-missing! GKTurnBasedMatch::endMatchInTurnWithMatchData:scores:achievements:completionHandler: missing a [Deprecated] attribute

Просмотреть файл

@ -1 +0,0 @@
!deprecated-attribute-missing! INPlayMediaIntent::initWithMediaItems:mediaContainer:playShuffled:playbackRepeatMode:resumePlayback: missing a [Deprecated] attribute

Просмотреть файл

@ -1,11 +1,2 @@
!deprecated-attribute-missing! MPMediaItemArtwork::imageCropRect missing a [Deprecated] attribute
!deprecated-attribute-missing! MPMediaItemArtwork::initWithImage: missing a [Deprecated] attribute
!deprecated-attribute-missing! MPVolumeView::areWirelessRoutesAvailable missing a [Deprecated] attribute
!deprecated-attribute-missing! MPVolumeView::isWirelessRouteActive missing a [Deprecated] attribute
!deprecated-attribute-missing! MPVolumeView::routeButtonImageForState: missing a [Deprecated] attribute
!deprecated-attribute-missing! MPVolumeView::routeButtonRectForBounds: missing a [Deprecated] attribute
!deprecated-attribute-missing! MPVolumeView::setRouteButtonImage:forState: missing a [Deprecated] attribute
!deprecated-attribute-missing! MPVolumeView::setShowsRouteButton: missing a [Deprecated] attribute
!deprecated-attribute-missing! MPVolumeView::showsRouteButton missing a [Deprecated] attribute
!missing-protocol! MPMediaPlayback not bound
!missing-protocol-conformance! MPMusicPlayerController should conform to MPMediaPlayback

Просмотреть файл

@ -1 +0,0 @@
!deprecated-attribute-missing! MDLMesh::makeVerticesUnique missing a [Deprecated] attribute

Просмотреть файл

@ -1 +0,0 @@
!deprecated-attribute-missing! RPScreenRecorder::startRecordingWithMicrophoneEnabled:handler: missing a [Deprecated] attribute

Просмотреть файл

@ -1,2 +0,0 @@
!deprecated-attribute-missing! SKDownload::contentLength missing a [Deprecated] attribute
!deprecated-attribute-missing! SKDownload::downloadState missing a [Deprecated] attribute

Просмотреть файл

@ -1,5 +1,3 @@
!deprecated-attribute-missing! UISearchController::searchControllerObservedScrollView missing a [Deprecated] attribute
!deprecated-attribute-missing! UISearchController::setSearchControllerObservedScrollView: missing a [Deprecated] attribute
!missing-selector! NSDiffableDataSourceSectionTransaction::difference not bound
!missing-selector! NSDiffableDataSourceTransaction::difference not bound
!missing-selector! UICollectionViewDiffableDataSourceReorderingHandlers::canReorderItemHandler not bound
@ -18,39 +16,6 @@
!missing-selector! UICollectionViewDiffableDataSourceSectionSnapshotHandlers::snapshotForExpandingParentItemHandler not bound
!missing-selector! UICollectionViewDiffableDataSourceSectionSnapshotHandlers::willCollapseItemHandler not bound
!missing-selector! UICollectionViewDiffableDataSourceSectionSnapshotHandlers::willExpandItemHandler not bound
!deprecated-attribute-missing! UIApplication::openURL: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIApplication::windows missing a [Deprecated] attribute
!deprecated-attribute-missing! UIApplicationDelegate::application:didReceiveRemoteNotification: missing a [Deprecated] attribute
!deprecated-attribute-missing! UICollectionViewDelegate::collectionView:canPerformAction:forItemAtIndexPath:withSender: missing a [Deprecated] attribute
!deprecated-attribute-missing! UICollectionViewDelegate::collectionView:performAction:forItemAtIndexPath:withSender: missing a [Deprecated] attribute
!deprecated-attribute-missing! UICollectionViewDelegate::collectionView:shouldShowMenuForItemAtIndexPath: missing a [Deprecated] attribute
!deprecated-attribute-missing! UICollectionViewDelegate::collectionView:targetIndexPathForMoveFromItemAtIndexPath:toProposedIndexPath: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIFocusGuide::preferredFocusedView missing a [Deprecated] attribute
!deprecated-attribute-missing! UIFocusGuide::setPreferredFocusedView: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIPopoverController missing a [Deprecated] attribute
!deprecated-attribute-missing! UIPopoverControllerDelegate::popoverController:willRepositionPopoverToRect:inView: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIPopoverControllerDelegate::popoverControllerDidDismissPopover: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIPopoverControllerDelegate::popoverControllerShouldDismissPopover: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIStoryboardPopoverSegue missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewCell::detailTextLabel missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewCell::imageView missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewCell::textLabel missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewDelegate::tableView:canPerformAction:forRowAtIndexPath:withSender: missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewDelegate::tableView:performAction:forRowAtIndexPath:withSender: missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewDelegate::tableView:shouldShowMenuForRowAtIndexPath: missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewHeaderFooterView::detailTextLabel missing a [Deprecated] attribute
!deprecated-attribute-missing! UITableViewHeaderFooterView::textLabel missing a [Deprecated] attribute
!deprecated-attribute-missing! UITextViewDelegate::textView:shouldInteractWithTextAttachment:inRange: missing a [Deprecated] attribute
!deprecated-attribute-missing! UITextViewDelegate::textView:shouldInteractWithURL:inRange: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewController::isModalInPopover missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewController::previewActionItems missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewController::registerForPreviewingWithDelegate:sourceView: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewController::segueForUnwindingToViewController:fromViewController:identifier: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewController::setModalInPopover: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewController::unregisterForPreviewingWithContext: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewController::viewControllerForUnwindSegueAction:fromViewController:withSender: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewControllerPreviewingDelegate::previewingContext:commitViewController: missing a [Deprecated] attribute
!deprecated-attribute-missing! UIViewControllerPreviewingDelegate::previewingContext:viewControllerForLocation: missing a [Deprecated] attribute
!missing-enum-value! UICollectionLayoutListAppearance native value UICollectionLayoutListAppearanceInsetGrouped = 2 not bound
!missing-enum-value! UICollectionLayoutListAppearance native value UICollectionLayoutListAppearanceSidebar = 3 not bound
!missing-enum-value! UICollectionLayoutListAppearance native value UICollectionLayoutListAppearanceSidebarPlain = 4 not bound