diff --git a/src/UIKit/UIAccessibility.cs b/src/UIKit/UIAccessibility.cs index c4325c8deec8..7fe889e1e58b 100644 --- a/src/UIKit/UIAccessibility.cs +++ b/src/UIKit/UIAccessibility.cs @@ -37,23 +37,21 @@ public enum UIAccessibilityZoomType : long { public static partial class UIAccessibility { // UIAccessibility.h [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static /* BOOL */ bool UIAccessibilityIsVoiceOverRunning (); + extern static /* BOOL */ byte UIAccessibilityIsVoiceOverRunning (); static public bool IsVoiceOverRunning { get { - return UIAccessibilityIsVoiceOverRunning (); + return UIAccessibilityIsVoiceOverRunning () != 0; } } // UIAccessibility.h [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static /* BOOL */ bool UIAccessibilityIsMonoAudioEnabled (); + extern static /* BOOL */ byte UIAccessibilityIsMonoAudioEnabled (); static public bool IsMonoAudioEnabled { get { - return UIAccessibilityIsMonoAudioEnabled (); + return UIAccessibilityIsMonoAudioEnabled () != 0; } } @@ -85,8 +83,7 @@ public static NSObject FocusedElement (string assistiveTechnologyIdentifier) [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static /* BOOL */ bool UIAccessibilityIsShakeToUndoEnabled (); + extern static /* BOOL */ byte UIAccessibilityIsShakeToUndoEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -95,40 +92,37 @@ public static NSObject FocusedElement (string assistiveTechnologyIdentifier) #endif public static bool IsShakeToUndoEnabled { get { - return UIAccessibilityIsShakeToUndoEnabled (); + return UIAccessibilityIsShakeToUndoEnabled () != 0; } } // UIAccessibility.h [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static /* BOOL */ bool UIAccessibilityIsClosedCaptioningEnabled (); + extern static /* BOOL */ byte UIAccessibilityIsClosedCaptioningEnabled (); static public bool IsClosedCaptioningEnabled { get { - return UIAccessibilityIsClosedCaptioningEnabled (); + return UIAccessibilityIsClosedCaptioningEnabled () != 0; } } // UIAccessibility.h [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static /* BOOL */ bool UIAccessibilityIsInvertColorsEnabled (); + extern static /* BOOL */ byte UIAccessibilityIsInvertColorsEnabled (); static public bool IsInvertColorsEnabled { get { - return UIAccessibilityIsInvertColorsEnabled (); + return UIAccessibilityIsInvertColorsEnabled () != 0; } } // UIAccessibility.h [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static /* BOOL */ bool UIAccessibilityIsGuidedAccessEnabled (); + extern static /* BOOL */ byte UIAccessibilityIsGuidedAccessEnabled (); static public bool IsGuidedAccessEnabled { get { - return UIAccessibilityIsGuidedAccessEnabled (); + return UIAccessibilityIsGuidedAccessEnabled () != 0; } } @@ -229,7 +223,7 @@ public static CGRect ConvertFrameToScreenCoordinates (CGRect rect, UIView view) [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - extern unsafe static void UIAccessibilityRequestGuidedAccessSession (/* BOOL */ [MarshalAs (UnmanagedType.I1)] bool enable, /* void(^completionHandler)(BOOL didSucceed) */ BlockLiteral* completionHandler); + extern unsafe static void UIAccessibilityRequestGuidedAccessSession (/* BOOL */ byte enable, /* void(^completionHandler)(BOOL didSucceed) */ BlockLiteral* completionHandler); #if NET [SupportedOSPlatform ("ios")] @@ -247,7 +241,7 @@ public static void RequestGuidedAccessSession (bool enable, Action complet using var block = new BlockLiteral (); block.SetupBlock (callback, completionHandler); #endif - UIAccessibilityRequestGuidedAccessSession (enable, &block); + UIAccessibilityRequestGuidedAccessSession (enable ? (byte) 1 : (byte) 0, &block); } } @@ -287,8 +281,7 @@ static unsafe void TrampolineRequestGuidedAccessSession (IntPtr block, byte enab [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityDarkerSystemColorsEnabled (); + static extern byte UIAccessibilityDarkerSystemColorsEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -297,7 +290,7 @@ static unsafe void TrampolineRequestGuidedAccessSession (IntPtr block, byte enab #endif public static bool DarkerSystemColorsEnabled { get { - return UIAccessibilityDarkerSystemColorsEnabled (); + return UIAccessibilityDarkerSystemColorsEnabled () != 0; } } @@ -305,7 +298,7 @@ public static bool DarkerSystemColorsEnabled { [Obsolete ("Use 'DarkerSystemColorsEnabled' instead.")] public static bool DarkerSystemColosEnabled { get { - return UIAccessibilityDarkerSystemColorsEnabled (); + return UIAccessibilityDarkerSystemColorsEnabled () != 0; } } #endif @@ -316,8 +309,7 @@ public static bool DarkerSystemColosEnabled { [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsBoldTextEnabled (); + static extern byte UIAccessibilityIsBoldTextEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -326,7 +318,7 @@ public static bool DarkerSystemColosEnabled { #endif public static bool IsBoldTextEnabled { get { - return UIAccessibilityIsBoldTextEnabled (); + return UIAccessibilityIsBoldTextEnabled () != 0; } } @@ -340,8 +332,7 @@ public static bool IsBoldTextEnabled { [MacCatalyst (14, 0)] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityButtonShapesEnabled (); + static extern byte UIAccessibilityButtonShapesEnabled (); #if NET [SupportedOSPlatform ("tvos14.0")] @@ -352,7 +343,7 @@ public static bool IsBoldTextEnabled { [iOS (14, 0)] [MacCatalyst (14, 0)] #endif - public static bool ButtonShapesEnabled => UIAccessibilityButtonShapesEnabled (); + public static bool ButtonShapesEnabled => UIAccessibilityButtonShapesEnabled () != 0; #if NET [SupportedOSPlatform ("ios")] @@ -360,8 +351,7 @@ public static bool IsBoldTextEnabled { [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsGrayscaleEnabled (); + static extern byte UIAccessibilityIsGrayscaleEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -370,7 +360,7 @@ public static bool IsBoldTextEnabled { #endif static public bool IsGrayscaleEnabled { get { - return UIAccessibilityIsGrayscaleEnabled (); + return UIAccessibilityIsGrayscaleEnabled () != 0; } } @@ -380,8 +370,7 @@ static public bool IsGrayscaleEnabled { [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsReduceMotionEnabled (); + static extern byte UIAccessibilityIsReduceMotionEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -390,7 +379,7 @@ static public bool IsGrayscaleEnabled { #endif static public bool IsReduceMotionEnabled { get { - return UIAccessibilityIsReduceMotionEnabled (); + return UIAccessibilityIsReduceMotionEnabled () != 0; } } @@ -404,8 +393,7 @@ static public bool IsReduceMotionEnabled { [MacCatalyst (14, 0)] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityPrefersCrossFadeTransitions (); + static extern byte UIAccessibilityPrefersCrossFadeTransitions (); #if NET [SupportedOSPlatform ("tvos14.0")] @@ -416,7 +404,7 @@ static public bool IsReduceMotionEnabled { [iOS (14, 0)] [MacCatalyst (14, 0)] #endif - public static bool PrefersCrossFadeTransitions => UIAccessibilityPrefersCrossFadeTransitions (); + public static bool PrefersCrossFadeTransitions => UIAccessibilityPrefersCrossFadeTransitions () != 0; #if NET [SupportedOSPlatform ("ios13.0")] @@ -427,8 +415,7 @@ static public bool IsReduceMotionEnabled { [TV (13, 0)] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsVideoAutoplayEnabled (); + static extern byte UIAccessibilityIsVideoAutoplayEnabled (); #if NET [SupportedOSPlatform ("ios13.0")] @@ -438,7 +425,7 @@ static public bool IsReduceMotionEnabled { [iOS (13, 0)] [TV (13, 0)] #endif - static public bool IsVideoAutoplayEnabled => UIAccessibilityIsVideoAutoplayEnabled (); + static public bool IsVideoAutoplayEnabled => UIAccessibilityIsVideoAutoplayEnabled () != 0; #if NET [SupportedOSPlatform ("ios")] @@ -446,8 +433,7 @@ static public bool IsReduceMotionEnabled { [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsReduceTransparencyEnabled (); + static extern byte UIAccessibilityIsReduceTransparencyEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -456,7 +442,7 @@ static public bool IsReduceMotionEnabled { #endif static public bool IsReduceTransparencyEnabled { get { - return UIAccessibilityIsReduceTransparencyEnabled (); + return UIAccessibilityIsReduceTransparencyEnabled () != 0; } } @@ -466,8 +452,7 @@ static public bool IsReduceTransparencyEnabled { [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsSwitchControlRunning (); + static extern byte UIAccessibilityIsSwitchControlRunning (); #if NET [SupportedOSPlatform ("ios")] @@ -476,7 +461,7 @@ static public bool IsReduceTransparencyEnabled { #endif static public bool IsSwitchControlRunning { get { - return UIAccessibilityIsSwitchControlRunning (); + return UIAccessibilityIsSwitchControlRunning () != 0; } } @@ -486,8 +471,7 @@ static public bool IsSwitchControlRunning { [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsSpeakSelectionEnabled (); + static extern byte UIAccessibilityIsSpeakSelectionEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -496,7 +480,7 @@ static public bool IsSwitchControlRunning { #endif static public bool IsSpeakSelectionEnabled { get { - return UIAccessibilityIsSpeakSelectionEnabled (); + return UIAccessibilityIsSpeakSelectionEnabled () != 0; } } @@ -506,8 +490,7 @@ static public bool IsSpeakSelectionEnabled { [SupportedOSPlatform ("tvos")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsSpeakScreenEnabled (); + static extern byte UIAccessibilityIsSpeakScreenEnabled (); #if NET [SupportedOSPlatform ("ios")] @@ -516,7 +499,7 @@ static public bool IsSpeakSelectionEnabled { #endif static public bool IsSpeakScreenEnabled { get { - return UIAccessibilityIsSpeakScreenEnabled (); + return UIAccessibilityIsSpeakScreenEnabled () != 0; } } @@ -526,8 +509,7 @@ static public bool IsSpeakScreenEnabled { [SupportedOSPlatform ("maccatalyst")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsAssistiveTouchRunning (); + static extern byte UIAccessibilityIsAssistiveTouchRunning (); #if NET [SupportedOSPlatform ("ios")] @@ -536,7 +518,7 @@ static public bool IsSpeakScreenEnabled { #endif public static bool IsAssistiveTouchRunning { get { - return UIAccessibilityIsAssistiveTouchRunning (); + return UIAccessibilityIsAssistiveTouchRunning () != 0; } } @@ -549,8 +531,7 @@ public static bool IsAssistiveTouchRunning { [TV (13, 0)] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityShouldDifferentiateWithoutColor (); + static extern byte UIAccessibilityShouldDifferentiateWithoutColor (); #if NET [SupportedOSPlatform ("ios13.0")] @@ -560,7 +541,7 @@ public static bool IsAssistiveTouchRunning { [iOS (13, 0)] [TV (13, 0)] #endif - public static bool ShouldDifferentiateWithoutColor => UIAccessibilityShouldDifferentiateWithoutColor (); + public static bool ShouldDifferentiateWithoutColor => UIAccessibilityShouldDifferentiateWithoutColor () != 0; #if NET [SupportedOSPlatform ("ios13.0")] @@ -571,8 +552,7 @@ public static bool IsAssistiveTouchRunning { [TV (13, 0)] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIAccessibilityIsOnOffSwitchLabelsEnabled (); + static extern byte UIAccessibilityIsOnOffSwitchLabelsEnabled (); #if NET [SupportedOSPlatform ("ios13.0")] @@ -582,7 +562,7 @@ public static bool IsAssistiveTouchRunning { [iOS (13, 0)] [TV (13, 0)] #endif - public static bool IsOnOffSwitchLabelsEnabled => UIAccessibilityIsOnOffSwitchLabelsEnabled (); + public static bool IsOnOffSwitchLabelsEnabled => UIAccessibilityIsOnOffSwitchLabelsEnabled () != 0; #if !TVOS #if NET diff --git a/src/UIKit/UIContentSizeCategory.cs b/src/UIKit/UIContentSizeCategory.cs index 86269c7bb620..7c694a9a33ce 100644 --- a/src/UIKit/UIContentSizeCategory.cs +++ b/src/UIKit/UIContentSizeCategory.cs @@ -41,8 +41,7 @@ public static NSComparisonResult Compare (UIContentSizeCategory category1, UICon [SupportedOSPlatform ("maccatalyst")] #endif [DllImport (Constants.UIKitLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool UIContentSizeCategoryIsAccessibilityCategory (IntPtr /* NSString */ category); + static extern byte UIContentSizeCategoryIsAccessibilityCategory (IntPtr /* NSString */ category); #if NET [SupportedOSPlatform ("ios")] @@ -55,7 +54,7 @@ static public bool IsAccessibilityCategory (this UIContentSizeCategory self) if (c1 is null) throw new ArgumentException ($"Unknown 'UIContentSizeCategory' value"); - return UIContentSizeCategoryIsAccessibilityCategory (c1.Handle); + return UIContentSizeCategoryIsAccessibilityCategory (c1.Handle) != 0; } } } diff --git a/src/UIKit/UIGuidedAccessRestriction.cs b/src/UIKit/UIGuidedAccessRestriction.cs index 1177c3a3d9b8..4a519988d658 100644 --- a/src/UIKit/UIGuidedAccessRestriction.cs +++ b/src/UIKit/UIGuidedAccessRestriction.cs @@ -50,7 +50,7 @@ public static UIGuidedAccessRestrictionState GetState (string restrictionIdentif [iOS (12,2)] #endif [DllImport (Constants.UIKitLibrary)] - static unsafe extern void UIGuidedAccessConfigureAccessibilityFeatures (/* UIGuidedAccessAccessibilityFeature */ nuint features, [MarshalAs (UnmanagedType.I1)] bool enabled, BlockLiteral* completion); + static unsafe extern void UIGuidedAccessConfigureAccessibilityFeatures (/* UIGuidedAccessAccessibilityFeature */ nuint features, byte enabled, BlockLiteral* completion); #if NET // [SupportedOSPlatform ("ios12.2")] -- Not valid for Delegates @@ -106,7 +106,7 @@ public static void ConfigureAccessibilityFeatures (UIGuidedAccessAccessibilityFe using var block = new BlockLiteral (); block.SetupBlockUnsafe (UIGuidedAccessConfigureAccessibilityFeaturesTrampoline.Handler, completionHandler); #endif - UIGuidedAccessConfigureAccessibilityFeatures ((nuint) (ulong) features, enabled, &block); + UIGuidedAccessConfigureAccessibilityFeatures ((nuint) (ulong) features, enabled ? (byte) 1 : (byte) 0, &block); } } diff --git a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs index 25cee30bd483..1cb33b1903e0 100644 --- a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs +++ b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs @@ -551,27 +551,6 @@ public partial class BlittablePInvokes { "System.Boolean SystemConfiguration.NetworkReachability::SCNetworkReachabilitySetCallback(System.IntPtr,method System.Void *(System.IntPtr,SystemConfiguration.NetworkReachabilityFlags,System.IntPtr),System.IntPtr)", "System.Boolean SystemConfiguration.NetworkReachability::SCNetworkReachabilitySetCallback(System.IntPtr,method System.Void *(System.IntPtr,SystemConfiguration.NetworkReachabilityFlags,System.IntPtr),SystemConfiguration.NetworkReachability/SCNetworkReachabilityContext&)", "System.Boolean SystemConfiguration.NetworkReachability::SCNetworkReachabilitySetDispatchQueue(System.IntPtr,System.IntPtr)", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityButtonShapesEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityDarkerSystemColorsEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsAssistiveTouchRunning()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsBoldTextEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsClosedCaptioningEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsGrayscaleEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsGuidedAccessEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsInvertColorsEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsMonoAudioEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsOnOffSwitchLabelsEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsReduceMotionEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsReduceTransparencyEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsShakeToUndoEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsSpeakScreenEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsSpeakSelectionEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsSwitchControlRunning()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsVideoAutoplayEnabled()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityIsVoiceOverRunning()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityPrefersCrossFadeTransitions()", - "System.Boolean UIKit.UIAccessibility::UIAccessibilityShouldDifferentiateWithoutColor()", - "System.Boolean UIKit.UIContentSizeCategoryExtensions::UIContentSizeCategoryIsAccessibilityCategory(System.IntPtr)", "System.Boolean UIKit.UIFloatRange::UIFloatRangeIsInfinite(UIKit.UIFloatRange)", "System.Boolean UIKit.UIVideo::UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(System.IntPtr)", "System.Boolean VideoToolbox.VTDecompressionSession::VTIsHardwareDecodeSupported(CoreMedia.CMVideoCodecType)", @@ -844,9 +823,7 @@ public partial class BlittablePInvokes { "System.Void ObjCRuntime.Protocol::protocol_addProperty(System.IntPtr,System.IntPtr,System.IntPtr*,System.Int32,System.Boolean,System.Boolean)", "System.Void ObjCRuntime.Runtime::xamarin_switch_gchandle(System.IntPtr,System.Boolean)", "System.Void OpenGLES.EAGLContext::EAGLGetVersion(System.UIntPtr&,System.UIntPtr&)", - "System.Void UIKit.UIAccessibility::UIAccessibilityRequestGuidedAccessSession(System.Boolean,ObjCRuntime.BlockLiteral*)", "System.Void UIKit.UIGraphics::BeginImageContextWithOptions(CoreGraphics.CGSize,System.Boolean,System.Runtime.InteropServices.NFloat)", - "System.Void UIKit.UIGuidedAccessRestriction::UIGuidedAccessConfigureAccessibilityFeatures(System.UIntPtr,System.Boolean,ObjCRuntime.BlockLiteral*)", "VideoToolbox.VTStatus VideoToolbox.VTCompressionSession::VTCompressionSessionCreate(System.IntPtr,System.Int32,System.Int32,CoreMedia.CMVideoCodecType,System.IntPtr,System.IntPtr,System.IntPtr,method System.Void *(System.IntPtr,System.IntPtr,VideoToolbox.VTStatus,VideoToolbox.VTEncodeInfoFlags,System.IntPtr),System.IntPtr,System.IntPtr&)", "VideoToolbox.VTStatus VideoToolbox.VTCompressionSession::VTCompressionSessionEncodeFrame(System.IntPtr,System.IntPtr,CoreMedia.CMTime,CoreMedia.CMTime,System.IntPtr,System.IntPtr,VideoToolbox.VTEncodeInfoFlags&)", "VideoToolbox.VTStatus VideoToolbox.VTCompressionSession::VTCompressionSessionEndPass(System.IntPtr,System.Byte&,System.IntPtr)",