Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xtro] Skip native enum values that aren't available on the current platform. #21958

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions src/Metal/MTLEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -956,14 +956,39 @@ public enum MTLPipelineOption : ulong {
/// <summary>Enumerates the hardware feature sets that are available on a device.</summary>
[Native]
public enum MTLFeatureSet : ulong {
#if XAMCORE_5_0
[NoMacCatalyst]
#elif __MACCATALYST__
[Obsolete ("Not available on the current platform.")]
#endif
[NoTV, NoMac]
iOS_GPUFamily1_v1 = 0,
#if XAMCORE_5_0
[NoMacCatalyst]
#elif __MACCATALYST__
[Obsolete ("Not available on the current platform.")]
#endif
[NoTV, NoMac]
iOS_GPUFamily1_v2 = 2,
#if XAMCORE_5_0
[NoMacCatalyst]
#elif __MACCATALYST__
[Obsolete ("Not available on the current platform.")]
#endif
[NoTV, NoMac]
iOS_GPUFamily2_v1 = 1,
#if XAMCORE_5_0
[NoMacCatalyst]
#elif __MACCATALYST__
[Obsolete ("Not available on the current platform.")]
#endif
[NoTV, NoMac]
iOS_GPUFamily2_v2 = 3,
#if XAMCORE_5_0
[NoMacCatalyst]
#elif __MACCATALYST__
[Obsolete ("Not available on the current platform.")]
#endif
[NoTV, NoMac]
iOS_GPUFamily3_v1 = 4,
[NoTV, NoMac, NoMacCatalyst]
Expand Down Expand Up @@ -995,29 +1020,14 @@ public enum MTLFeatureSet : ulong {
[NoiOS, NoTV, NoMacCatalyst]
macOS_GPUFamily1_v1 = 10000,

#if !NET
[Obsolete ("Use 'macOS_GPUFamily1_v1' instead.")]
OSX_GPUFamily1_v1 = macOS_GPUFamily1_v1,
#endif

[NoiOS, NoTV]
[NoMacCatalyst]
macOS_GPUFamily1_v2 = 10001,

#if !NET
[Obsolete ("Use 'macOS_GPUFamily1_v2' instead.")]
OSX_GPUFamily1_v2 = macOS_GPUFamily1_v2,
#endif

[NoiOS, NoTV]
[NoMacCatalyst]
macOS_ReadWriteTextureTier2 = 10002,

#if !NET
[Obsolete ("Use 'macOS_ReadWriteTextureTier2' instead.")]
OSX_ReadWriteTextureTier2 = macOS_ReadWriteTextureTier2,
#endif

[NoiOS, NoTV]
[NoMacCatalyst]
macOS_GPUFamily1_v3 = 10003,
Expand All @@ -1030,9 +1040,10 @@ public enum MTLFeatureSet : ulong {
[NoMacCatalyst]
macOS_GPUFamily2_v1 = 10005,

#if !NET
[Obsolete ("Use 'tvOS_GPUFamily1_v1' instead.")]
TVOS_GPUFamily1_v1 = 30000,
#if XAMCORE_5_0
[NoMacCatalyst]
#elif __MACCATALYST__
[Obsolete ("Not available on the current platform.")]
#endif

[NoiOS, NoMac]
Expand Down
6 changes: 6 additions & 0 deletions src/oslog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ enum OSLogMessageComponentArgumentCategory : long {
[TV (15, 0), iOS (15, 0), MacCatalyst (15, 0)]
[Native]
enum OSLogStoreScope : long {
#if XAMCORE_5_0
[NoTV, NoiOS, NoMacCatalyst]
#endif
#if !MONOMAC
[Obsolete ("Not available on the current platform.")]
#endif
System = 0,
CurrentProcessIdentifier = 1,
}
Expand Down
4 changes: 0 additions & 4 deletions tests/cecil-tests/AttributeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ public void FindSupportedOnElementsThatDoNotExistInThatAssembly ()
continue;
}
foreach (var member in GetAllTypeMembers (type)) {
// If a member is hidden, it's probably because it's broken in some way, so don't consider it.
if (ObsoleteTest.HasEditorBrowseableNeverAttribute (member))
continue;

var mentionedPlatforms = GetAvailabilityAttributes (member).ToList ();
if (mentionedPlatforms.Any ()) {
var claimedPlatforms = GetSupportedAvailabilityAttributes (member).ToList ();
Expand Down
1 change: 0 additions & 1 deletion tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16865,7 +16865,6 @@ F:OSLog.OSLogMessageComponentArgumentCategory.String
F:OSLog.OSLogMessageComponentArgumentCategory.UInt64
F:OSLog.OSLogMessageComponentArgumentCategory.Undefined
F:OSLog.OSLogStoreScope.CurrentProcessIdentifier
F:OSLog.OSLogStoreScope.System
F:PassKit.PKAddPassButtonStyle.Black
F:PassKit.PKAddPassButtonStyle.Outline
F:PassKit.PKAddPaymentPassError.SystemCancelled
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion tests/xtro-sharpie/api-annotations-dotnet/iOS-OSLog.todo

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
!missing-pinvoke! MIDISendEventList is not bound
!missing-pinvoke! MIDISourceCreateWithProtocol is not bound

# header's clearly say this enum value is not supported on macOS, yet xtro claims it is
!missing-enum-value! MidiNotificationMessageId native value kMIDIMsgInternalStart = 4096 not bound
!missing-pinvoke! MIDIEventPacketSysexBytesForGroup is not bound
!missing-pinvoke! MIDISendUMPSysex is not bound
!missing-pinvoke! MIDISendUMPSysex8 is not bound

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion tests/xtro-sharpie/api-annotations-dotnet/tvOS-OSLog.todo

This file was deleted.

3 changes: 0 additions & 3 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-UIKit.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,6 @@
## Enums not needed on tvOS
!missing-enum! UIListSeparatorVisibility not bound
!missing-enum! UIPrintRenderingQuality not bound
!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

# Not binding for now, does not make sense on tvOS
!missing-selector! +UITextInputContext::current not bound
Expand Down
19 changes: 15 additions & 4 deletions tests/xtro-sharpie/xtro-sharpie/EnumCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,12 @@ public override void VisitEnumDecl (EnumDecl decl, VisitKind visitKind)

// couldn't find a matching managed enum value for the native enum value
// don't report deprecated native enum values (or if the native enum itself is deprecated) as missing
if (!valueDecl.IsDeprecated () && !decl.IsDeprecated ())
if (!valueDecl.IsDeprecated () && !decl.IsDeprecated ()) {
// skip native enum values that aren't available on the current platform, unless it's an error enum.
if (!valueDecl.IsAvailable () && !IsErrorEnum (mname))
continue;
Log.On (framework).Add ($"!missing-enum-value! {type.Name} native value {valueName} = {value} not bound");
}
}
}

Expand Down Expand Up @@ -280,14 +284,21 @@ public override void VisitEnumDecl (EnumDecl decl, VisitKind visitKind)
Log.On (framework).Add ($"!wrong-enum-size! {name} managed {managed_size} vs native {native_size}");
}

static bool IsErrorEnum (string typeName)
{
if (typeName.EndsWith ("Error", StringComparison.Ordinal))
return true;
if (typeName.EndsWith ("ErrorCode", StringComparison.Ordinal))
return true;
return false;
}

static bool IsErrorEnum (TypeDefinition type)
{
if (!type.IsEnum)
return false;

if (type.Name.EndsWith ("Error", StringComparison.Ordinal))
return true;
if (type.Name.EndsWith ("ErrorCode", StringComparison.Ordinal))
if (IsErrorEnum (type.Name))
return true;

if (!type.HasCustomAttributes)
Expand Down
Loading