From 4e48aa2ae1e24d2d9a005e3e40f4faab043b6d89 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Sat, 10 Apr 2021 11:09:14 -0400 Subject: [PATCH 1/2] [generator][dotnet] Add support for `[Uns|S]upportedOSPlatformAttribute` (#10580) This moves our current/legacy attributes to the ones added in dotnet 5 [1]. Short Forms (only in bindings) | Old | New | |---------------------------------------|-------------------------------------| | [iOS (7,0)] | [SupportedOSPlatform ("ios7.0")] | | [NoIOS] | [UnsupportedOSPlatform ("ios")] | Long Forms | Old | New | |---------------------------------------|-------------------------------------| | [Introduced (PlatformName.iOS, 7,0)] | [SupportedOSPlatform ("ios7.0")] | | [Obsoleted (PlatformName.iOS, 12,1)] | [Obsolete (...)] | | [Deprecated (PlatformName.iOS, 14,3)] | [UnsupportedOSPlatform ("ios14.3")] | | [Unavailable (PlatformName.iOS)] | [UnsupportedOSPlatform ("ios")] | Other changes * `[SupportedOSPlatform]` and `[UnsupportedOSPlatform]` are not allowed on `interface` [2] which means they cannot be used for protocols. This is currently handled by inlining the existing attributes on all members. * `[ObsoletedInOSPlatform]` was removed in net5 RC. This PR is now mapping the existing attributes to `[Obsolote]`, however multiple ones cannot be added so they need to be platform specific. Remaining work (manual bindings update) tracked in https://github.com/xamarin/xamarin-macios/issues/11055 References * [1] https://github.com/xamarin/xamarin-macios/issues/10170 * [2] https://github.com/dotnet/runtime/issues/47599 * [3] https://github.com/dotnet/runtime/issues/47601 --- src/CoreAnimation/CALayer.cs | 2 + src/CoreFoundation/Dispatch.cs | 32 ++++++ src/CoreFoundation/OSLog.cs | 3 + src/CoreGraphics/CGColorConversionInfo.cs | 4 + src/CoreGraphics/CGColorConverter.cs | 16 ++- src/CoreGraphics/CGColorSpace.cs | 54 +++++++++- src/CoreText/CTStringAttributes.cs | 4 + src/GameController/GCMicroGamepadSnapshot.cs | 4 +- src/GameplayKit/GKObstacleGraph.cs | 2 + src/GameplayKit/GKPath.cs | 4 + src/GameplayKit/GKPrimitives.cs | 6 ++ src/GameplayKit/NSArray_GameplayKit.cs | 3 + src/HealthKit/EnumsCompat.cs | 4 - src/HomeKit/HMCharacteristicMetadata.cs | 2 + src/HomeKit/HMCharacteristicProperties.cs | 2 + src/HomeKit/HMHome.cs | 2 + src/HomeKit/HMService.cs | 2 + src/Makefile | 6 +- src/MapKit/MKOverlayView.cs | 2 + src/MapKit/MapKit.cs | 8 ++ src/Metal/Defs.cs | 12 +++ src/Metal/MTLVertexDescriptor.cs | 8 ++ src/ModelIO/MDLMesh.cs | 18 ++++ src/ModelIO/MDLVertexDescriptor.cs | 4 + src/ObjCRuntime/PlatformAvailability2.cs | 74 +++++++++++++ src/OpenGLES/EAGLContext.cs | 2 + src/Security/Certificate.cs | 54 ++++++++++ src/Security/SslContext.cs | 16 +++ src/StoreKit/SKAdNetworkCompat.cs | 6 ++ src/TVServices/TVContentItemImageShape.cs | 37 +++++++ src/TVServices/TVEnums.cs | 30 +++--- src/UIKit/UIAccessibility.cs | 67 ++++++++++++ src/VideoToolbox/VTCompressionSession.cs | 6 ++ src/WatchKit/iOS/WKAccessibility.cs | 5 + .../iOS/WKAccessibilityImageRegion.cs | 5 + src/WatchKit/iOS/WKErrorCode.cs | 10 ++ src/WatchKit/iOS/WKImageAnimatable.cs | 12 +++ src/WatchKit/iOS/WKInterfaceButton.cs | 5 + src/WatchKit/iOS/WKInterfaceController.cs | 5 + src/WatchKit/iOS/WKInterfaceDate.cs | 5 + src/WatchKit/iOS/WKInterfaceDevice.cs | 5 + src/WatchKit/iOS/WKInterfaceGroup.cs | 5 + src/WatchKit/iOS/WKInterfaceImage.cs | 5 + src/WatchKit/iOS/WKInterfaceLabel.cs | 5 + src/WatchKit/iOS/WKInterfaceMap.cs | 5 + src/WatchKit/iOS/WKInterfaceMapPinColor.cs | 5 + src/WatchKit/iOS/WKInterfaceObject.cs | 5 + src/WatchKit/iOS/WKInterfaceSeparator.cs | 5 + src/WatchKit/iOS/WKInterfaceSlider.cs | 5 + src/WatchKit/iOS/WKInterfaceSwitch.cs | 5 + src/WatchKit/iOS/WKInterfaceTable.cs | 5 + src/WatchKit/iOS/WKInterfaceTimer.cs | 5 + src/WatchKit/iOS/WKMenuItemIcon.cs | 5 + src/WatchKit/iOS/WKTextInputMode.cs | 5 + .../WKUserNotificationInterfaceController.cs | 5 + .../iOS/WKUserNotificationInterfaceType.cs | 5 + src/appkit.cs | 1 + src/avfoundation.cs | 1 + src/bgen/bgen.csproj | 3 + src/corebluetooth.cs | 1 - src/frameworks.sources | 5 +- src/generate-type-forwarders/Program.cs | 27 ++++- src/generator.cs | 38 ++++++- src/generator.csproj | 3 + tests/common/PlatformInfo.cs | 61 +++++++++++ tests/generator/BGenTests.cs | 17 ++- tests/generator/bug35176.cs | 6 +- tests/introspection/ApiAvailabilityTest.cs | 101 ++++++++++++++++-- tests/introspection/ApiSignatureTest.cs | 1 + .../Jenkins/NUnitTestTasksEnumerable.cs | 2 +- tests/xharness/MonoNativeInfo.cs | 8 +- tests/xharness/Targets/TVOSTarget.cs | 2 +- 72 files changed, 849 insertions(+), 51 deletions(-) create mode 100644 src/TVServices/TVContentItemImageShape.cs diff --git a/src/CoreAnimation/CALayer.cs b/src/CoreAnimation/CALayer.cs index 2b963b5495f0..79077f789c1d 100644 --- a/src/CoreAnimation/CALayer.cs +++ b/src/CoreAnimation/CALayer.cs @@ -133,7 +133,9 @@ public virtual CAAutoresizingMask AutoresizinMask { } } #endif +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public CAContentsFormat ContentsFormat { get { return CAContentsFormatExtensions.GetValue (_ContentsFormat); } set { _ContentsFormat = value.GetConstant ()!; } diff --git a/src/CoreFoundation/Dispatch.cs b/src/CoreFoundation/Dispatch.cs index f7cf10c32378..c81d0380822c 100644 --- a/src/CoreFoundation/Dispatch.cs +++ b/src/CoreFoundation/Dispatch.cs @@ -152,20 +152,24 @@ public void SetTargetQueue (DispatchQueue queue) [DllImport (Constants.libcLibrary)] internal extern static void dispatch_suspend (IntPtr o); +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif public void Activate () { dispatch_activate (GetCheckedHandle ()); } [DllImport (Constants.libcLibrary)] +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif extern static void dispatch_activate (/* dispatch_object_t */ IntPtr @object); #endif // !COREBUILD } @@ -204,10 +208,12 @@ public DispatchQueue (string label, bool concurrent) throw new Exception ("Error creating dispatch queue"); } +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif public DispatchQueue (string label, Attributes attributes, DispatchQueue target = null) : base (dispatch_queue_create_with_target (label, attributes?.Create () ?? IntPtr.Zero, target.GetHandle ()), true) { @@ -223,7 +229,9 @@ public string Label { } } +#if !NET [iOS (7,0)] +#endif public static string CurrentQueueLabel { get { return Marshal.PtrToStringAnsi (dispatch_queue_get_label (IntPtr.Zero)); @@ -467,8 +475,10 @@ public object GetSpecific (IntPtr key) return gchandle.Target; } +#if !NET [Mac (10,10)] [iOS (8,0)] +#endif public DispatchQualityOfService GetQualityOfService (out int relative_priority) { unsafe { @@ -477,8 +487,10 @@ public DispatchQualityOfService GetQualityOfService (out int relative_priority) } } +#if !NET [Mac (10,10)] [iOS (8,0)] +#endif public DispatchQualityOfService QualityOfService { get { unsafe { @@ -493,10 +505,12 @@ public DispatchQualityOfService QualityOfService { [DllImport (Constants.libcLibrary)] extern static IntPtr dispatch_queue_create (string label, IntPtr attr); +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif [DllImport (Constants.libcLibrary)] extern static IntPtr dispatch_queue_create_with_target (string label, IntPtr attr, IntPtr target); @@ -549,8 +563,10 @@ public DispatchQualityOfService QualityOfService { [DllImport(Constants.libcLibrary)] extern static IntPtr dispatch_queue_get_specific (IntPtr queue, /* const void* */ IntPtr key); +#if !NET [Mac (10,10)] [iOS (8,0)] +#endif [DllImport (Constants.libcLibrary)] unsafe extern static /* dispatch_qos_class_t */ DispatchQualityOfService dispatch_queue_get_qos_class (/* dispatch_queue_t */ IntPtr queue, /* int *_Nullable */ int* relative_priority); @@ -599,24 +615,32 @@ public class Attributes { public bool Concurrent { get; set; } +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif public bool IsInitiallyInactive { get; set; } +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif public AutoreleaseFrequency? AutoreleaseFrequency { get; set; } +#if !NET [Mac (10,10)] [iOS (8,0)] +#endif public int RelativePriority { get; set; } +#if !NET [Mac (10,10)] [iOS (8,0)] +#endif public DispatchQualityOfService? QualityOfService { get; set; } internal IntPtr Create () @@ -638,30 +662,38 @@ internal IntPtr Create () return rv; } +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif [DllImport (Constants.libcLibrary)] static extern /* dispatch_queue_attr_t */ IntPtr dispatch_queue_attr_make_initially_inactive (/* dispatch_queue_attr_t _Nullable */ IntPtr attr); +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif [DllImport (Constants.libcLibrary)] static extern /* dispatch_queue_attr_t */ IntPtr dispatch_queue_attr_make_with_autorelease_frequency (/* dispatch_queue_attr_t _Nullable */ IntPtr attr, /* dispatch_autorelease_frequency_t */ nuint frequency); +#if !NET [Mac (10,10)] [iOS (8,0)] +#endif [DllImport (Constants.libcLibrary)] static extern /* dispatch_queue_attr_t */ IntPtr dispatch_queue_attr_make_with_qos_class (/* dispatch_queue_attr_t _Nullable */ IntPtr attr, /* dispatch_qos_class_t */ DispatchQualityOfService qos_class, int relative_priority); } +#if !NET [Mac (10,12)] [iOS (10,0)] [TV (10,0)] [Watch (3,0)] +#endif [Native] public enum AutoreleaseFrequency : ulong /* unsigned long */ { diff --git a/src/CoreFoundation/OSLog.cs b/src/CoreFoundation/OSLog.cs index fa6d482e46dc..60cfe0b54055 100644 --- a/src/CoreFoundation/OSLog.cs +++ b/src/CoreFoundation/OSLog.cs @@ -26,8 +26,11 @@ using System.Collections.Generic; namespace CoreFoundation { + +#if !NET [Mac (10,12), iOS (10,0), Watch (3,0), TV (10,0)] [Introduced (PlatformName.MacCatalyst, 13, 0)] +#endif public sealed class OSLog : NativeObject { static OSLog _default; diff --git a/src/CoreGraphics/CGColorConversionInfo.cs b/src/CoreGraphics/CGColorConversionInfo.cs index c2ec65a869d1..a07b2000236e 100644 --- a/src/CoreGraphics/CGColorConversionInfo.cs +++ b/src/CoreGraphics/CGColorConversionInfo.cs @@ -16,7 +16,9 @@ namespace CoreGraphics { +#if !NET [iOS (10,0)][TV (10,0)][Watch (3,0)][Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct GColorConversionInfoTriple { public CGColorSpace Space; @@ -25,7 +27,9 @@ public struct GColorConversionInfoTriple { } // CGColorConverter.h +#if !NET [iOS (10,0)][TV (10,0)][Watch (3,0)][Mac (10,12)] +#endif public partial class CGColorConversionInfo : INativeObject, IDisposable { /* invoked by marshallers */ diff --git a/src/CoreGraphics/CGColorConverter.cs b/src/CoreGraphics/CGColorConverter.cs index 2d3627449149..184daa14e838 100644 --- a/src/CoreGraphics/CGColorConverter.cs +++ b/src/CoreGraphics/CGColorConverter.cs @@ -20,8 +20,12 @@ namespace CoreGraphics { - [TV (9,2)][Obsoleted (PlatformName.TvOS, 10,0, message: "Replaced by 'GColorConversionInfoTriple'.")] - [iOS (9,3)][Obsoleted (PlatformName.iOS, 10,0, message: "Replaced by 'GColorConversionInfoTriple'.")] +#if !NET + [TV (9,2)] + [iOS (9,3)] +#endif + [Obsoleted (PlatformName.TvOS, 10,0, message: "Replaced by 'GColorConversionInfoTriple'.")] + [Obsoleted (PlatformName.iOS, 10,0, message: "Replaced by 'GColorConversionInfoTriple'.")] [StructLayout (LayoutKind.Sequential)] public struct CGColorConverterTriple { public CGColorSpace Space; @@ -30,8 +34,12 @@ public struct CGColorConverterTriple { } // CGColorConverter.h - [TV (9,2)][Obsoleted (PlatformName.TvOS, 10,0, message: "Replaced by 'CGColorConversionInfo'.")] - [iOS (9,3)][Obsoleted (PlatformName.iOS, 10,0, message: "Replaced by 'CGColorConversionInfo'.")] +#if !NET + [TV (9,2)] + [iOS (9,3)] +#endif + [Obsoleted (PlatformName.TvOS, 10,0, message: "Replaced by 'CGColorConversionInfo'.")] + [Obsoleted (PlatformName.iOS, 10,0, message: "Replaced by 'CGColorConversionInfo'.")] public class CGColorConverter : INativeObject, IDisposable { /* invoked by marshallers */ diff --git a/src/CoreGraphics/CGColorSpace.cs b/src/CoreGraphics/CGColorSpace.cs index 42c9c5e9faaa..28e5c7f7a61a 100644 --- a/src/CoreGraphics/CGColorSpace.cs +++ b/src/CoreGraphics/CGColorSpace.cs @@ -252,74 +252,98 @@ static CGColorSpace Create (IntPtr handle) var r = CGColorSpaceCreateWithName (handle); return r == IntPtr.Zero ? null : new CGColorSpace (r, true); } - + +#if !NET [iOS (9,0)] +#endif public static CGColorSpace CreateGenericGray () { return Create (CGColorSpaceNames.GenericGray.Handle); } +#if !NET [iOS (9,0)] +#endif public static CGColorSpace CreateGenericRgb () { return Create (CGColorSpaceNames.GenericRgb.Handle); } +#if !NET [iOS (8,0)] +#endif public static CGColorSpace CreateGenericCmyk () { return Create (CGColorSpaceNames.GenericCmyk.Handle); } +#if !NET [iOS (9,0)] +#endif public static CGColorSpace CreateGenericRgbLinear () { return Create (CGColorSpaceNames.GenericRgbLinear.Handle); } +#if !NET [iOS (8,0)] +#endif public static CGColorSpace CreateAdobeRgb1988 () { return Create (CGColorSpaceNames.AdobeRgb1998.Handle); } +#if !NET [iOS (8,0)] +#endif public static CGColorSpace CreateSrgb () { return Create (CGColorSpaceNames.Srgb.Handle); } +#if !NET [iOS (8,0)] +#endif public static CGColorSpace CreateGenericGrayGamma2_2 () { return Create (CGColorSpaceNames.GenericGrayGamma2_2.Handle); } +#if !NET [iOS (9,0)][Mac (10,11)] +#endif public static CGColorSpace CreateGenericXyz () { return Create (CGColorSpaceNames.GenericXyz.Handle); } +#if !NET [iOS (9,0)][Mac (10,11)] +#endif public static CGColorSpace CreateAcesCGLinear () { return Create (CGColorSpaceNames.AcesCGLinear.Handle); } +#if !NET [iOS (9,0)][Mac (10,11)] +#endif public static CGColorSpace CreateItuR_709 () { return Create (CGColorSpaceNames.ItuR_709.Handle); } +#if !NET [iOS (9,0)][Mac (10,11)] +#endif public static CGColorSpace CreateItuR_2020 () { return Create (CGColorSpaceNames.ItuR_2020.Handle); } +#if !NET [iOS (9,0)][Mac (10,11)] +#endif public static CGColorSpace CreateRommRgb () { return Create (CGColorSpaceNames.RommRgb.Handle); @@ -394,14 +418,18 @@ public static CGColorSpace CreateICCProfile (NSData data) return ptr == IntPtr.Zero ? null : new CGColorSpace (ptr, true); } +#if !NET [iOS (10, 0)] [Mac (10, 12)] +#endif public static CGColorSpace CreateIccData (NSData data) { return CreateIccData (data.GetHandle ()); } +#if !NET [iOS (10,0)][Mac (10,12)][Watch (3,0)][TV (10,0)] +#endif public static CGColorSpace CreateIccData (CGDataProvider provider) { return CreateIccData (provider.GetHandle ()); @@ -439,7 +467,9 @@ public static CGColorSpace CreateICCProfile (nfloat[] range, CGDataProvider prof [Deprecated (PlatformName.WatchOS, 4, 0, message: "Use 'GetICCData' instead." )] extern static /* CFDataRef */ IntPtr CGColorSpaceCopyICCProfile (/* CGColorSpaceRef */ IntPtr space); +#if !NET [iOS (7,0)] // note: pre-release docs/headers says iOS6 and later, available on OSX since 10.5 +#endif [Deprecated (PlatformName.MacOSX, 10, 13, message: "Use 'GetICCData' instead." )] [Deprecated (PlatformName.iOS, 11, 0, message: "Use 'GetICCData' instead." )] [Deprecated (PlatformName.TvOS, 11, 0, message: "Use 'GetICCData' instead." )] @@ -454,74 +484,96 @@ public NSData GetICCProfile () return (ptr == IntPtr.Zero) ? null : new NSData (ptr, true); } +#if !NET [iOS (10,0)][Mac (10,12)] [Watch (3,0)] [TV (10,0)] +#endif [DllImport (Constants.CoreGraphicsLibrary)] static extern /* CFDataRef* */ IntPtr CGColorSpaceCopyICCData (/* CGColorSpaceRef */ IntPtr space); +#if !NET [iOS (10,0)][Mac (10,12)] [Watch (3,0)] [TV (10,0)] +#endif public NSData GetIccData () { IntPtr ptr = CGColorSpaceCopyICCData (handle); return (ptr == IntPtr.Zero) ? null : new NSData (ptr, true); } +#if !NET [iOS (10,0)] [TV (10,0)] +#endif [DllImport (Constants.CoreGraphicsLibrary)] static extern unsafe /* CFStringRef* */ IntPtr CGColorSpaceCopyName (/* CGColorSpaceRef */ IntPtr space); +#if !NET [iOS (10,0)] [TV (10,0)] +#endif public string Name { get { return CFString.FetchString (CGColorSpaceCopyName (handle), true); } } +#if !NET [iOS (10,0)][Mac (10,12)] [Watch (3,0)] [TV (10,0)] +#endif [DllImport (Constants.CoreGraphicsLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool CGColorSpaceIsWideGamutRGB (/* CGColorSpaceRef */ IntPtr space); +#if !NET [iOS (10,0)][Mac (10,12)] [Watch (3,0)] [TV (10,0)] +#endif public bool IsWideGamutRgb { get { return CGColorSpaceIsWideGamutRGB (handle); } } +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] +#endif [DllImport (Constants.CoreGraphicsLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool CGColorSpaceSupportsOutput (/* CGColorSpaceRef */ IntPtr space); +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] +#endif public bool SupportsOutput { get { return CGColorSpaceSupportsOutput (handle); } } +#if !NET [iOS(10,0)][Mac(10,12)][TV(10,0)][Watch(5,0)] +#endif [DllImport (Constants.CoreGraphicsLibrary)] static extern IntPtr CGColorSpaceCopyPropertyList (IntPtr space); +#if !NET [iOS(10,0)][Mac(10,12)][TV(10,0)][Watch(5,0)] +#endif [DllImport (Constants.CoreGraphicsLibrary)] static extern IntPtr CGColorSpaceCreateWithPropertyList (IntPtr plist); +#if !NET [iOS(10,0)][Mac(10,12)] [TV(10,0)][Watch(5,0)] +#endif public CFPropertyList ToPropertyList () { var x = CGColorSpaceCopyPropertyList (handle); diff --git a/src/CoreText/CTStringAttributes.cs b/src/CoreText/CTStringAttributes.cs index 2312bba5156a..b44663c1d11c 100644 --- a/src/CoreText/CTStringAttributes.cs +++ b/src/CoreText/CTStringAttributes.cs @@ -192,7 +192,9 @@ public CGColor ForegroundColor { set {Adapter.SetNativeValue (Dictionary, CTStringAttributeKey.ForegroundColor, value);} } +#if !NET [iOS (10,0)][Mac (10,12)] +#endif public CGColor BackgroundColor { get { var h = IntPtr.Zero; @@ -302,7 +304,9 @@ public bool VerticalForms { } } +#if !NET [iOS (10,0)][Mac (10,12)][Watch (3,0)][TV (10,0)] +#endif public int? HorizontalInVerticalForms { get { var x = CTStringAttributeKey.HorizontalInVerticalForms; diff --git a/src/GameController/GCMicroGamepadSnapshot.cs b/src/GameController/GCMicroGamepadSnapshot.cs index 6bbeddfeaefb..05303d18aabd 100644 --- a/src/GameController/GCMicroGamepadSnapshot.cs +++ b/src/GameController/GCMicroGamepadSnapshot.cs @@ -10,7 +10,9 @@ namespace GameController { - [iOS (10,0), TV (9,0), Mac (10,12)] +#if !NET + [iOS (10,0), Mac (10,12)] +#endif // GCMicroGamepadSnapshot.h // float_t are 4 bytes (at least for ARM64) [StructLayout (LayoutKind.Sequential, Pack = 1)] diff --git a/src/GameplayKit/GKObstacleGraph.cs b/src/GameplayKit/GKObstacleGraph.cs index c409aa88701c..c3551c56f61b 100644 --- a/src/GameplayKit/GKObstacleGraph.cs +++ b/src/GameplayKit/GKObstacleGraph.cs @@ -24,7 +24,9 @@ GKGraphNode2D [] GetNodes (GKPolygonObstacle obstacle) } } +#if !NET [iOS (10,0), TV (10,0), Mac (10,12)] +#endif [Register ("GKObstacleGraph", SkipRegistration = true)] public partial class GKObstacleGraph : GKObstacleGraph where NodeType : GKGraphNode2D { diff --git a/src/GameplayKit/GKPath.cs b/src/GameplayKit/GKPath.cs index 99a150a979f4..dc27e493943b 100644 --- a/src/GameplayKit/GKPath.cs +++ b/src/GameplayKit/GKPath.cs @@ -50,7 +50,9 @@ public GKPath (Vector2 [] points, float radius, bool cyclical) } } +#if !NET [iOS (10,0), TV (10,0), Mac (10,12)] +#endif public static GKPath FromPoints (Vector3 [] points, float radius, bool cyclical) { if (points == null) @@ -68,7 +70,9 @@ public static GKPath FromPoints (Vector3 [] points, float radius, bool cyclical) } } +#if !NET [iOS (10,0), TV (10,0), Mac (10,12)] +#endif public GKPath (Vector3 [] points, float radius, bool cyclical) { if (points == null) diff --git a/src/GameplayKit/GKPrimitives.cs b/src/GameplayKit/GKPrimitives.cs index eb2ff73f7097..0a72da6db222 100644 --- a/src/GameplayKit/GKPrimitives.cs +++ b/src/GameplayKit/GKPrimitives.cs @@ -16,21 +16,27 @@ namespace GameplayKit { +#if !NET [iOS (10,0), TV (10,0), Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct GKBox { public Vector3 Min; public Vector3 Max; } +#if !NET [iOS (10,0), TV (10,0), Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct GKQuad { public Vector2 Min; public Vector2 Max; } +#if !NET [iOS (10,0), TV (10,0), Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct GKTriangle { [MarshalAs (UnmanagedType.ByValArray, SizeConst = 3)] diff --git a/src/GameplayKit/NSArray_GameplayKit.cs b/src/GameplayKit/NSArray_GameplayKit.cs index 0033f9aa7529..663074b9f4ff 100644 --- a/src/GameplayKit/NSArray_GameplayKit.cs +++ b/src/GameplayKit/NSArray_GameplayKit.cs @@ -12,7 +12,10 @@ using ObjCRuntime; namespace GameplayKit { + +#if !NET [iOS (10,0), TV (10,0), Mac (10,12)] +#endif public static class NSArray_GameplayKit { [Export ("shuffledArrayWithRandomSource:")] diff --git a/src/HealthKit/EnumsCompat.cs b/src/HealthKit/EnumsCompat.cs index 64e6aad006dc..5549a72b50a3 100644 --- a/src/HealthKit/EnumsCompat.cs +++ b/src/HealthKit/EnumsCompat.cs @@ -6,7 +6,6 @@ namespace HealthKit { [Obsolete ("Use the 'HKQuantityTypeIdentifier' enum instead.")] - [Introduced (PlatformName.WatchOS, 2,0, PlatformArchitecture.All)] [Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)] public unsafe static partial class HKQuantityTypeIdentifierKey { public static NSString ActiveEnergyBurned { @@ -545,7 +544,6 @@ public static NSString WalkingHeartRateAverage { } /* class HKQuantityTypeIdentifierKey */ [Obsolete ("Use the 'HKCategoryTypeIdentifier' enum instead.")] - [Introduced (PlatformName.WatchOS, 2,0, PlatformArchitecture.All)] [Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)] public unsafe static partial class HKCategoryTypeIdentifierKey { [Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)] @@ -614,7 +612,6 @@ public static NSString SleepAnalysis { } /* class HKCategoryTypeIdentifierKey */ [Obsolete ("Use the 'HKCharacteristicTypeIdentifier' enum instead.")] - [Introduced (PlatformName.WatchOS, 2,0, PlatformArchitecture.All)] [Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)] public unsafe static partial class HKCharacteristicTypeIdentifierKey { public static NSString BiologicalSex { @@ -655,7 +652,6 @@ public static NSString WheelchairUse { } /* class HKCharacteristicTypeIdentifierKey */ [Obsolete ("Use the 'HKCorrelationType' enum instead.")] - [Introduced (PlatformName.WatchOS, 2,0, PlatformArchitecture.All)] [Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)] public unsafe static partial class HKCorrelationTypeKey { public static NSString IdentifierBloodPressure { diff --git a/src/HomeKit/HMCharacteristicMetadata.cs b/src/HomeKit/HMCharacteristicMetadata.cs index 4ecf6c4b6ce4..c4b286027e0f 100644 --- a/src/HomeKit/HMCharacteristicMetadata.cs +++ b/src/HomeKit/HMCharacteristicMetadata.cs @@ -4,8 +4,10 @@ namespace HomeKit { +#if !NET [TV (10,0)] [iOS (8,0)] +#endif public partial class HMCharacteristicMetadata { public HMCharacteristicMetadataUnits Units { diff --git a/src/HomeKit/HMCharacteristicProperties.cs b/src/HomeKit/HMCharacteristicProperties.cs index 8c6750e884f7..404f601fa546 100644 --- a/src/HomeKit/HMCharacteristicProperties.cs +++ b/src/HomeKit/HMCharacteristicProperties.cs @@ -4,8 +4,10 @@ namespace HomeKit { +#if !NET [iOS (8,0)] [TV (10,0)] +#endif public class HMCharacteristicProperties { public bool SupportsChangeNumber { get; set; } diff --git a/src/HomeKit/HMHome.cs b/src/HomeKit/HMHome.cs index 89530f3e95b1..aa81371f37ef 100644 --- a/src/HomeKit/HMHome.cs +++ b/src/HomeKit/HMHome.cs @@ -6,8 +6,10 @@ namespace HomeKit { +#if !NET [iOS (8,0)] [TV (10,0)] +#endif public partial class HMHome { public HMService [] GetServices (HMServiceType serviceTypes) diff --git a/src/HomeKit/HMService.cs b/src/HomeKit/HMService.cs index 56899a3909ae..faab74ddd319 100644 --- a/src/HomeKit/HMService.cs +++ b/src/HomeKit/HMService.cs @@ -5,8 +5,10 @@ namespace HomeKit { +#if !NET [TV (10,0)] [iOS (8,0)] +#endif public partial class HMService { #if !WATCH && !TVOS diff --git a/src/Makefile b/src/Makefile index 28c76a925b84..8946bdcaa8f2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1374,21 +1374,21 @@ $(GENERATE_TYPE_FORWARDERS): $(wildcard generate-type-forwarders/*.cs*) Makefile $(Q) $(SYSTEM_MSBUILD) /r generate-type-forwarders/generate-type-forwarders.csproj $(MSBUILD_VERBOSITY) $(MACCATALYST_BUILD_DIR)/reference/Xamarin.iOS.cs: $(MACCATALYST_BUILD_DIR)/reference/Xamarin.MacCatalyst.dll $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll Makefile $(GENERATE_TYPE_FORWARDERS) - $(Q) mono $(GENERATE_TYPE_FORWARDERS) $(abspath $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll) $(abspath $(MACCATALYST_BUILD_DIR)/reference/Xamarin.MacCatalyst.dll) $(abspath $@.tmp) + $(Q) mono $(GENERATE_TYPE_FORWARDERS) $(abspath $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll) $(abspath $(MACCATALYST_BUILD_DIR)/reference/Xamarin.MacCatalyst.dll) $(abspath $@.tmp) $(MIN_MACCATALYST_SDK_VERSION) $(Q) mv $@.tmp $@ $(MACCATALYST_BUILD_DIR)/reference/Xamarin.iOS.dll: $(MACCATALYST_BUILD_DIR)/reference/Xamarin.iOS.cs $(Q) $(MACCATALYST_CSC) $< -out:$@ -r:$(MACCATALYST_BUILD_DIR)/reference/Xamarin.MacCatalyst.dll -target:library -deterministic -publicsign -keyfile:$(PRODUCT_KEY_PATH) -nologo -nowarn:108,114,618 -unsafe $(MACCATALYST_DOTNET_BUILD_DIR)/ref/Xamarin.iOS.cs: $(MACCATALYST_DOTNET_BUILD_DIR)/ref/Xamarin.MacCatalyst.dll $(IOS_DOTNET_BUILD_DIR)/ref/Xamarin.iOS.dll Makefile $(GENERATE_TYPE_FORWARDERS) - $(Q) mono $(GENERATE_TYPE_FORWARDERS) $(IOS_DOTNET_BUILD_DIR)/ref/Xamarin.iOS.dll $(MACCATALYST_DOTNET_BUILD_DIR)/ref/Xamarin.MacCatalyst.dll $@.tmp + $(Q) mono $(GENERATE_TYPE_FORWARDERS) $(IOS_DOTNET_BUILD_DIR)/ref/Xamarin.iOS.dll $(MACCATALYST_DOTNET_BUILD_DIR)/ref/Xamarin.MacCatalyst.dll $@.tmp $(DOTNET_MIN_MACCATALYST_SDK_VERSION) $(Q) mv $@.tmp $@ $(MACCATALYST_DOTNET_BUILD_DIR)/ref/Xamarin.iOS.dll: $(MACCATALYST_DOTNET_BUILD_DIR)/ref/Xamarin.iOS.cs $(Q) $(DOTNET6_CSC) $(DOTNET_FLAGS) $< -out:$@ -r:$(MACCATALYST_DOTNET_BUILD_DIR)/ref/Xamarin.MacCatalyst.dll -target:library -deterministic -publicsign -keyfile:$(PRODUCT_KEY_PATH) -nologo -nowarn:108,114,618 -unsafe $(MACCATALYST_BUILD_DIR)/reference/OpenTK-1.0.cs: $(MACCATALYST_BUILD_DIR)/reference/Xamarin.MacCatalyst.dll $(IOS_BUILD_DIR)/reference/OpenTK-1.0.dll Makefile $(GENERATE_TYPE_FORWARDERS) - $(Q) mono $(GENERATE_TYPE_FORWARDERS) $(IOS_BUILD_DIR)/reference/OpenTK-1.0.dll $(MACCATALYST_BUILD_DIR)/reference/Xamarin.MacCatalyst.dll $@.tmp + $(Q) mono $(GENERATE_TYPE_FORWARDERS) $(IOS_BUILD_DIR)/reference/OpenTK-1.0.dll $(MACCATALYST_BUILD_DIR)/reference/Xamarin.MacCatalyst.dll $@.tmp $(MIN_MACCATALYST_SDK_VERSION) $(Q) mv $@.tmp $@ $(MACCATALYST_BUILD_DIR)/reference/OpenTK-1.0.dll: $(MACCATALYST_BUILD_DIR)/reference/OpenTK-1.0.cs $(MACCATALYST_BUILD_DIR)/reference/Xamarin.iOS.dll diff --git a/src/MapKit/MKOverlayView.cs b/src/MapKit/MKOverlayView.cs index 24d353c1181c..31316e10e7e5 100644 --- a/src/MapKit/MKOverlayView.cs +++ b/src/MapKit/MKOverlayView.cs @@ -15,8 +15,10 @@ namespace MapKit { public partial class MKOverlayView { +#if !NET [TV (9,2)] [Mac (10,9)] +#endif [DllImport (Constants.MapKitLibrary)] public static extern nfloat MKRoadWidthAtZoomScale (/* MKZoomScale */ nfloat zoomScale); } diff --git a/src/MapKit/MapKit.cs b/src/MapKit/MapKit.cs index 85e9e5e337df..bd442955734c 100644 --- a/src/MapKit/MapKit.cs +++ b/src/MapKit/MapKit.cs @@ -142,7 +142,9 @@ public MKMapSize (double width, double height) Height = height; } +#if !NET [TV (9,2)] +#endif public static MKMapSize World { get { return new MKMapSize (0x10000000, 0x10000000); }} // MKMapSizeEqualToSize @@ -180,9 +182,13 @@ public override string ToString () // MKGeometry.h [StructLayout (LayoutKind.Sequential)] +#if !NET [Mac (10,9)] +#endif public struct MKMapRect { +#if !NET [TV (9,2)] +#endif public static readonly MKMapRect Null = new MKMapRect (double.PositiveInfinity, double.PositiveInfinity, 0, 0); public MKMapPoint Origin; @@ -273,7 +279,9 @@ public bool IsEmpty { } } +#if !NET [TV (9,2)] +#endif public MKMapRect World { get { return new MKMapRect (0, 0, 0x10000000, 0x10000000); diff --git a/src/Metal/Defs.cs b/src/Metal/Defs.cs index 650f72d143f3..c7772e67932f 100644 --- a/src/Metal/Defs.cs +++ b/src/Metal/Defs.cs @@ -45,11 +45,15 @@ public MTLSize (nint width, nint height, nint depth){ #if !COREBUILD public static class MTLVertexFormatExtensions { +#if !NET [iOS (9,0)][Mac (10,11)] +#endif [DllImport (Constants.MetalKitLibrary)] static extern /* MDLVertexFormat */ nuint MTKModelIOVertexFormatFromMetal (/* MTLVertexFormat */ nuint modelIODescriptor); +#if !NET [iOS (9,0)][Mac (10,11)] +#endif public static MDLVertexFormat ToModelVertexFormat (this MTLVertexFormat vertexFormat) { nuint mdlVertexFormat = MTKModelIOVertexFormatFromMetal ((nuint)(ulong)vertexFormat); @@ -254,7 +258,9 @@ public struct MTLDrawIndexedPrimitivesIndirectArguments { public uint BaseInstance; } +#if !NET [iOS (10,0), TV (10,0), NoWatch, Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct MTLSizeAndAlign { @@ -269,7 +275,9 @@ public MTLSizeAndAlign (nuint size, nuint align) } +#if !NET [iOS (10,0), TV (10,0), NoWatch, Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct MTLDrawPatchIndirectArguments { @@ -288,7 +296,9 @@ public MTLDrawPatchIndirectArguments (uint pathCount, uint instanceCount, uint p } +#if !NET [iOS (10,0), TV (10,0), NoWatch, Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct MTLQuadTessellationFactorsHalf { @@ -305,7 +315,9 @@ public MTLQuadTessellationFactorsHalf (ushort[] edgeTessellationFactor, ushort[] } +#if !NET [iOS (10,0), TV (10,0), NoWatch, Mac (10,12)] +#endif [StructLayout (LayoutKind.Sequential)] public struct MTLTriangleTessellationFactorsHalf { diff --git a/src/Metal/MTLVertexDescriptor.cs b/src/Metal/MTLVertexDescriptor.cs index 24175d8abb4e..974ca0056715 100644 --- a/src/Metal/MTLVertexDescriptor.cs +++ b/src/Metal/MTLVertexDescriptor.cs @@ -11,11 +11,15 @@ namespace Metal { public partial class MTLVertexDescriptor { +#if !NET [iOS (9,0)] +#endif [DllImport (Constants.MetalKitLibrary)] static extern /* MTLVertexDescriptor __nonnull */ IntPtr MTKMetalVertexDescriptorFromModelIO (/* MDLVertexDescriptor __nonnull */ IntPtr modelIODescriptor); +#if !NET [iOS (9,0)] +#endif public static MTLVertexDescriptor FromModelIO (MDLVertexDescriptor descriptor) { if (descriptor == null) @@ -23,13 +27,17 @@ public static MTLVertexDescriptor FromModelIO (MDLVertexDescriptor descriptor) return Runtime.GetNSObject (MTKMetalVertexDescriptorFromModelIO (descriptor.Handle)); } +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] +#endif [DllImport (Constants.MetalKitLibrary)] static extern /* MTLVertexDescriptor __nonnull */ IntPtr MTKMetalVertexDescriptorFromModelIOWithError (/* MDLVertexDescriptor __nonnull */ IntPtr modelIODescriptor, out IntPtr error); +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] +#endif public static MTLVertexDescriptor FromModelIO (MDLVertexDescriptor descriptor, out NSError error) { if (descriptor == null) diff --git a/src/ModelIO/MDLMesh.cs b/src/ModelIO/MDLMesh.cs index 544f98f27fe6..4a538fcf214e 100644 --- a/src/ModelIO/MDLMesh.cs +++ b/src/ModelIO/MDLMesh.cs @@ -79,13 +79,17 @@ internal MDLMesh (MDLMesh mesh, int submeshIndex, uint subdivisionLevels, IMDLMe // Note: we turn these constructors into static constructors because we don't want to lose the shape name. Also, the signatures of these constructors differ so it would not be possible to use an enum to differentiate the shapes. +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateBox (Vector3 dimensions, Vector3i segments, MDLGeometryType geometryType, bool inwardNormals, IMDLMeshBufferAllocator allocator) { return CreateBox (dimensions, segments, geometryType, inwardNormals, allocator, MDLMeshVectorType.Dimensions); } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateBox (Vector3 vector, Vector3i segments, MDLGeometryType geometryType, bool inwardNormals, IMDLMeshBufferAllocator allocator, MDLMeshVectorType type = MDLMeshVectorType.Dimensions) { switch (type) { @@ -98,43 +102,57 @@ public static MDLMesh CreateBox (Vector3 vector, Vector3i segments, MDLGeometryT } } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateSphere (Vector3 dimensions, Vector2i segments, MDLGeometryType geometryType, bool inwardNormals, IMDLMeshBufferAllocator allocator) { return new MDLMesh (dimensions, segments, inwardNormals, geometryType, allocator, null, null, null); } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateHemisphere (Vector3 dimensions, Vector2i segments, MDLGeometryType geometryType, bool inwardNormals, bool cap, IMDLMeshBufferAllocator allocator) { return new MDLMesh (dimensions, segments, inwardNormals, geometryType, allocator, null, cap, false); } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateCylinder (Vector3 extent, Vector2i segments, bool inwardNormals, bool topCap, bool bottomCap, MDLGeometryType geometryType, IMDLMeshBufferAllocator allocator) { return new MDLMesh (extent, segments, inwardNormals, topCap, bottomCap, geometryType, allocator); } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateCapsule (Vector3 dimensions, Vector2i segments, MDLGeometryType geometryType, bool inwardNormals, int hemisphereSegments, IMDLMeshBufferAllocator allocator) { return new MDLMesh (dimensions, segments, inwardNormals, geometryType, allocator, hemisphereSegments, null, null); } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateCone (Vector3 dimensions, Vector2i segments, MDLGeometryType geometryType, bool inwardNormals, bool cap, IMDLMeshBufferAllocator allocator) { return new MDLMesh (dimensions, segments, inwardNormals, geometryType, allocator, null, cap, true); } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreatePlane (Vector3 extent, Vector2i segments, MDLGeometryType geometryType, IMDLMeshBufferAllocator allocator) { return new MDLMesh (extent, segments, geometryType, allocator); } +#if !NET [iOS (10,0)][TV (10,0)][Mac (10,12)] +#endif public static MDLMesh CreateIcosahedron (Vector3 extent, bool inwardNormals, MDLGeometryType geometryType, IMDLMeshBufferAllocator allocator) { return new MDLMesh (extent, inwardNormals, geometryType, allocator); diff --git a/src/ModelIO/MDLVertexDescriptor.cs b/src/ModelIO/MDLVertexDescriptor.cs index 9538e4f87cf8..e05a804df64b 100644 --- a/src/ModelIO/MDLVertexDescriptor.cs +++ b/src/ModelIO/MDLVertexDescriptor.cs @@ -20,13 +20,17 @@ public static MDLVertexDescriptor FromMetal (MTLVertexDescriptor descriptor) return Runtime.GetNSObject (MTKModelIOVertexDescriptorFromMetal (descriptor.Handle)); } +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] +#endif [DllImport (Constants.MetalKitLibrary)] static extern /* MDLVertexDescriptor __nonnull */ IntPtr MTKModelIOVertexDescriptorFromMetalWithError (/* MTLVertexDescriptor __nonnull */ IntPtr metalDescriptor, out /* NSError */ IntPtr error); +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] +#endif public static MDLVertexDescriptor FromMetal (MTLVertexDescriptor descriptor, out NSError error) { if (descriptor == null) diff --git a/src/ObjCRuntime/PlatformAvailability2.cs b/src/ObjCRuntime/PlatformAvailability2.cs index c5c5390a9263..23cf315453cd 100644 --- a/src/ObjCRuntime/PlatformAvailability2.cs +++ b/src/ObjCRuntime/PlatformAvailability2.cs @@ -93,6 +93,79 @@ internal AvailabilityBaseAttribute ( public override string ToString () { var builder = new StringBuilder (); +#if NET && BGENERATOR + switch (AvailabilityKind) { + case AvailabilityKind.Introduced: + builder.Append ("[SupportedOSPlatform (\""); + break; + case AvailabilityKind.Obsoleted: + switch (Platform) { + case PlatformName.iOS: + builder.AppendLine ("#if __IOS__"); + break; + case PlatformName.TvOS: + builder.AppendLine ("#if __TVOS__"); + break; + case PlatformName.WatchOS: + builder.AppendLine ("#if __WATCHOS__"); + break; + case PlatformName.MacOSX: + builder.AppendLine ("#if __MACOS__"); + break; + case PlatformName.MacCatalyst: + builder.AppendLine ("#if __MACCATALYST__"); + break; + default: + throw new NotSupportedException ($"Unknown platform: {Platform}"); + } + builder.Append ("[Obsolete (\"Starting with "); + break; + case AvailabilityKind.Deprecated: + case AvailabilityKind.Unavailable: + builder.Append ("[UnsupportedOSPlatform (\""); + break; + } + + switch (Platform) { + case PlatformName.iOS: + builder.Append ("ios"); + break; + case PlatformName.TvOS: + builder.Append ("tvos"); + break; + case PlatformName.WatchOS: + builder.Append ("watchos"); + break; + case PlatformName.MacOSX: + builder.Append ("macos"); // no 'x' + break; + case PlatformName.MacCatalyst: + builder.Append ("maccatalyst"); + break; + default: + throw new NotSupportedException ($"Unknown platform: {Platform}"); + } + + if (Version != null) + builder.Append (Version.ToString (Version.Build >= 0 ? 3 : 2)); + + switch (AvailabilityKind) { + case AvailabilityKind.Obsoleted: + 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.Append ("#endif"); + break; + case AvailabilityKind.Introduced: + case AvailabilityKind.Deprecated: + case AvailabilityKind.Unavailable: + builder.Append ("\")]"); + break; + } +#else builder.AppendFormat ("[{0} ({1}.{2}", AvailabilityKind, nameof (PlatformName), Platform); if (Version != null) { @@ -108,6 +181,7 @@ public override string ToString () builder.AppendFormat (", message: \"{0}\"", Message.Replace ("\"", "\"\"")); builder.Append (")]"); +#endif return builder.ToString (); } } diff --git a/src/OpenGLES/EAGLContext.cs b/src/OpenGLES/EAGLContext.cs index 5de019a50000..830a275f75a9 100644 --- a/src/OpenGLES/EAGLContext.cs +++ b/src/OpenGLES/EAGLContext.cs @@ -21,8 +21,10 @@ public EAGLContext () } #endif +#if !NET [iOS (10,0)] [TV (10,0)] +#endif public virtual bool PresentRenderBuffer (nuint target, double presentationTime) { return _PresentRenderbufferAtTime (target, presentationTime); diff --git a/src/Security/Certificate.cs b/src/Security/Certificate.cs index 4aef4770fdfa..6ea9c5ab923b 100644 --- a/src/Security/Certificate.cs +++ b/src/Security/Certificate.cs @@ -769,11 +769,15 @@ public SecStatusCode Decrypt (SecPadding padding, byte [] cipherText, out byte [ return _Decrypt (padding, cipherText, ref plainText); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern IntPtr /* SecKeyRef _Nullable */ SecKeyCreateRandomKey (IntPtr /* CFDictionaryRef* */ parameters, out IntPtr /* CFErrorRef** */ error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif static public SecKey CreateRandomKey (NSDictionary parameters, out NSError error) { if (parameters == null) @@ -785,7 +789,9 @@ static public SecKey CreateRandomKey (NSDictionary parameters, out NSError error return key == IntPtr.Zero ? null : new SecKey (key, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif static public SecKey CreateRandomKey (SecKeyType keyType, int keySizeInBits, NSDictionary parameters, out NSError error) { using (var ks = new NSNumber (keySizeInBits)) @@ -796,7 +802,9 @@ static public SecKey CreateRandomKey (SecKeyType keyType, int keySizeInBits, NSD } } +#if !NET [Watch (3, 0)][TV (10, 0)][Mac (10, 12)][iOS (10, 0)] +#endif static public SecKey CreateRandomKey (SecKeyGenerationParameters parameters, out NSError error) { if (parameters == null) @@ -809,11 +817,15 @@ static public SecKey CreateRandomKey (SecKeyGenerationParameters parameters, out } } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern IntPtr /* SecKeyRef _Nullable */ SecKeyCreateWithData (IntPtr /* CFDataRef* */ keyData, IntPtr /* CFDictionaryRef* */ attributes, out IntPtr /* CFErrorRef** */ error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif static public SecKey Create (NSData keyData, NSDictionary parameters, out NSError error) { if (keyData == null) @@ -827,7 +839,9 @@ static public SecKey Create (NSData keyData, NSDictionary parameters, out NSErro return key == IntPtr.Zero ? null : new SecKey (key, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif static public SecKey Create (NSData keyData, SecKeyType keyType, SecKeyClass keyClass, int keySizeInBits, NSDictionary parameters, out NSError error) { using (var ks = new NSNumber (keySizeInBits)) @@ -839,11 +853,15 @@ static public SecKey Create (NSData keyData, SecKeyType keyType, SecKeyClass key } } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern IntPtr /* CFDataRef _Nullable */ SecKeyCopyExternalRepresentation (IntPtr /* SecKeyRef* */ key, out IntPtr /* CFErrorRef** */ error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSData GetExternalRepresentation (out NSError error) { IntPtr err; @@ -852,7 +870,9 @@ public NSData GetExternalRepresentation (out NSError error) return Runtime.GetNSObject (data, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSData GetExternalRepresentation () { IntPtr err; @@ -860,44 +880,60 @@ public NSData GetExternalRepresentation () return Runtime.GetNSObject (data, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern IntPtr /* CFDictionaryRef _Nullable */ SecKeyCopyAttributes (IntPtr /* SecKeyRef* */ key); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSDictionary GetAttributes () { var dict = SecKeyCopyAttributes (handle); return Runtime.GetNSObject (dict, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern IntPtr /* SecKeyRef* */ SecKeyCopyPublicKey (IntPtr /* SecKeyRef* */ key); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public SecKey GetPublicKey () { var key = SecKeyCopyPublicKey (handle); return key == IntPtr.Zero ? null : new SecKey (key, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] [return: MarshalAs (UnmanagedType.U1)] static extern bool /* Boolean */ SecKeyIsAlgorithmSupported (IntPtr /* SecKeyRef* */ key, /* SecKeyOperationType */ nint operation, IntPtr /* SecKeyAlgorithm* */ algorithm); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public bool IsAlgorithmSupported (SecKeyOperationType operation, SecKeyAlgorithm algorithm) { return SecKeyIsAlgorithmSupported (handle, (int) operation, algorithm.GetConstant ().Handle); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern /* CFDataRef _Nullable */ IntPtr SecKeyCreateSignature (/* SecKeyRef */ IntPtr key, /* SecKeyAlgorithm */ IntPtr algorithm, /* CFDataRef */ IntPtr dataToSign, /* CFErrorRef* */ out IntPtr error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSData CreateSignature (SecKeyAlgorithm algorithm, NSData dataToSign, out NSError error) { if (dataToSign == null) @@ -909,12 +945,16 @@ public NSData CreateSignature (SecKeyAlgorithm algorithm, NSData dataToSign, out return Runtime.GetNSObject (data, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] [return: MarshalAs (UnmanagedType.U1)] static extern /* Boolean */ bool SecKeyVerifySignature (/* SecKeyRef */ IntPtr key, /* SecKeyAlgorithm */ IntPtr algorithm, /* CFDataRef */ IntPtr signedData, /* CFDataRef */ IntPtr signature, /* CFErrorRef* */ out IntPtr error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public bool VerifySignature (SecKeyAlgorithm algorithm, NSData signedData, NSData signature, out NSError error) { if (signedData == null) @@ -928,11 +968,15 @@ public bool VerifySignature (SecKeyAlgorithm algorithm, NSData signedData, NSDat return result; } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern /* CFDataRef _Nullable */ IntPtr SecKeyCreateEncryptedData (/* SecKeyRef */ IntPtr key, /* SecKeyAlgorithm */ IntPtr algorithm, /* CFDataRef */ IntPtr plaintext, /* CFErrorRef* */ out IntPtr error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSData CreateEncryptedData (SecKeyAlgorithm algorithm, NSData plaintext, out NSError error) { if (plaintext == null) @@ -944,11 +988,15 @@ public NSData CreateEncryptedData (SecKeyAlgorithm algorithm, NSData plaintext, return Runtime.GetNSObject (data, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern /* CFDataRef _Nullable */ IntPtr SecKeyCreateDecryptedData (/* SecKeyRef */ IntPtr key, /* SecKeyAlgorithm */ IntPtr algorithm, /* CFDataRef */ IntPtr ciphertext, /* CFErrorRef* */ out IntPtr error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSData CreateDecryptedData (SecKeyAlgorithm algorithm, NSData ciphertext, out NSError error) { if (ciphertext == null) @@ -960,11 +1008,15 @@ public NSData CreateDecryptedData (SecKeyAlgorithm algorithm, NSData ciphertext, return Runtime.GetNSObject (data, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern /* CFDataRef _Nullable */ IntPtr SecKeyCopyKeyExchangeResult (/* SecKeyRef */ IntPtr privateKey, /* SecKeyAlgorithm */ IntPtr algorithm, /* SecKeyRef */ IntPtr publicKey, /* CFDictionaryRef */ IntPtr parameters, /* CFErrorRef* */ out IntPtr error); +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSData GetKeyExchangeResult (SecKeyAlgorithm algorithm, SecKey publicKey, NSDictionary parameters, out NSError error) { if (publicKey == null) @@ -978,7 +1030,9 @@ public NSData GetKeyExchangeResult (SecKeyAlgorithm algorithm, SecKey publicKey, return Runtime.GetNSObject (data, true); } +#if !NET [Watch (3,0)][TV (10,0)][Mac (10,12)][iOS (10,0)] +#endif public NSData GetKeyExchangeResult (SecKeyAlgorithm algorithm, SecKey publicKey, SecKeyKeyExchangeParameter parameters, out NSError error) { return GetKeyExchangeResult (algorithm, publicKey, parameters?.Dictionary, out error); diff --git a/src/Security/SslContext.cs b/src/Security/SslContext.cs index c2580c1a78a3..7617e75055f5 100644 --- a/src/Security/SslContext.cs +++ b/src/Security/SslContext.cs @@ -545,15 +545,19 @@ public SslStatus SetSessionStrengthPolicy (SslSessionStrengthPolicy policyStreng } #endif +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] [Watch (3,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern int SSLSetSessionConfig (IntPtr /* SSLContextRef* */ context, IntPtr /* CFStringRef* */ config); +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] [Watch (3,0)] +#endif [EditorBrowsable (EditorBrowsableState.Advanced)] public int SetSessionConfig (NSString config) { @@ -563,36 +567,48 @@ public int SetSessionConfig (NSString config) return SSLSetSessionConfig (Handle, config.Handle); } +#if !NET [iOS (10,0)][Mac (10,12)] [TV (10,0)] +#endif public int SetSessionConfig (SslSessionConfig config) { return SetSessionConfig (config.GetConstant ()); } +#if !NET [iOS (10,0)][Mac (10,12)] [Watch (3,0)] [TV (10,0)] +#endif [DllImport (Constants.SecurityLibrary)] static extern int SSLReHandshake (IntPtr /* SSLContextRef* */ context); +#if !NET [iOS (10,0)][Mac (10,12)] [Watch (3,0)] [TV (10,0)] +#endif public int ReHandshake () { return SSLReHandshake (Handle); } +#if !NET [iOS (9,0)][Mac (10,11)] +#endif [DllImport (Constants.SecurityLibrary)] static extern /* OSStatus */ SslStatus SSLCopyRequestedPeerName (IntPtr /* SSLContextRef* */ context, byte[] /* char* */ peerName, ref nuint /* size_t */ peerNameLen); +#if !NET [iOS (9,0)][Mac (10,11)] +#endif [DllImport (Constants.SecurityLibrary)] static extern /* OSStatus */ SslStatus SSLCopyRequestedPeerNameLength (IntPtr /* SSLContextRef* */ context, ref nuint /* size_t */ peerNameLen); +#if !NET [iOS (9,0)][Mac (10,11)] +#endif public string GetRequestedPeerName () { var result = String.Empty; diff --git a/src/StoreKit/SKAdNetworkCompat.cs b/src/StoreKit/SKAdNetworkCompat.cs index 030f1c5a80d0..054ba5533573 100644 --- a/src/StoreKit/SKAdNetworkCompat.cs +++ b/src/StoreKit/SKAdNetworkCompat.cs @@ -9,13 +9,19 @@ using System; using System.ComponentModel; +using System.Runtime.Versioning; + using Foundation; using ObjCRuntime; #if TVOS && !XAMCORE_4_0 namespace StoreKit { [Obsolete ("Not usable from tvOS and will be removed in the future.")] +#if NET + [UnsupportedOSPlatform ("tvos")] +#else [Unavailable (PlatformName.TvOS)] +#endif public class SKAdNetwork : NSObject { [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)] diff --git a/src/TVServices/TVContentItemImageShape.cs b/src/TVServices/TVContentItemImageShape.cs new file mode 100644 index 000000000000..c5d337790921 --- /dev/null +++ b/src/TVServices/TVContentItemImageShape.cs @@ -0,0 +1,37 @@ +// Copyright 2015 Xamarin Inc. + +#if !COREBUILD + +using System; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using CoreGraphics; +using Foundation; +using ObjCRuntime; + +namespace TVServices { + + static public class TVContentItemImageShapeExtensions { + +#if NET + [UnsupportedOSPlatform ("tvos13.0")] +#else + [Deprecated (PlatformName.TvOS, 13,0)] +#endif + [DllImport (Constants.TVServicesLibrary)] + static extern CGSize TVTopShelfImageSizeForShape (/* TVContentItemImageShape */ nint shape, + /* TVTopShelfContentStyle */ nint style); + +#if NET + [UnsupportedOSPlatform ("tvos13.0")] +#else + [Deprecated (PlatformName.TvOS, 13,0, message: "Use 'TVTopShelfSectionedContent.GetImageSize' or 'TVTopShelfInsetContent.ImageSize' instead.")] +#endif + static public CGSize GetSize (this TVContentItemImageShape self, TVTopShelfContentStyle style) + { + return TVTopShelfImageSizeForShape ((nint) (int) self, (nint) (int) style); + } + } +} + +#endif diff --git a/src/TVServices/TVEnums.cs b/src/TVServices/TVEnums.cs index 45f90f326b66..34eae836ab45 100644 --- a/src/TVServices/TVEnums.cs +++ b/src/TVServices/TVEnums.cs @@ -2,13 +2,21 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.Versioning; + using CoreGraphics; using Foundation; using ObjCRuntime; +#nullable enable + namespace TVServices { +#if NET + [SupportedOSPlatform ("tvos9.0")] +#else [TV (9,0)] +#endif [Native] public enum TVContentItemImageShape : long { None = 0, @@ -20,14 +28,22 @@ public enum TVContentItemImageShape : long { ExtraWide } +#if NET + [SupportedOSPlatform ("tvos9.0")] +#else [TV (9,0)] +#endif [Native] public enum TVTopShelfContentStyle : long { Inset = 1, Sectioned = 2 } +#if NET + [SupportedOSPlatform ("tvos11.0")] +#else [TV (11,0)] +#endif [Native] [Flags] public enum TVContentItemImageTrait : ulong { @@ -36,18 +52,4 @@ public enum TVContentItemImageTrait : ulong { ScreenScale1x = (1 << 12), ScreenScale2x = (2 << 12), } - - static public class TVContentItemImageShapeExtensions { - - [Deprecated (PlatformName.TvOS, 13,0)] - [DllImport (Constants.TVServicesLibrary)] - static extern CGSize TVTopShelfImageSizeForShape (/* TVContentItemImageShape */ nint shape, - /* TVTopShelfContentStyle */ nint style); - - [Deprecated (PlatformName.TvOS, 13,0, message: "Use 'TVTopShelfSectionedContent.GetImageSize' or 'TVTopShelfInsetContent.ImageSize' instead.")] - static public CGSize GetSize (this TVContentItemImageShape self, TVTopShelfContentStyle style) - { - return TVTopShelfImageSizeForShape ((nint) (int) self, (nint) (int) style); - } - } } diff --git a/src/UIKit/UIAccessibility.cs b/src/UIKit/UIAccessibility.cs index 68ca0290dc42..d6abb68da174 100644 --- a/src/UIKit/UIAccessibility.cs +++ b/src/UIKit/UIAccessibility.cs @@ -60,11 +60,15 @@ static public bool IsMonoAudioEnabled { // UIAccessibility.h +#if !NET [iOS (9,0)] +#endif [DllImport (Constants.UIKitLibrary)] extern static /* NSObject */ IntPtr UIAccessibilityFocusedElement (IntPtr assistiveTechnologyIdentifier); +#if !NET [iOS (9,0)] +#endif public static NSObject FocusedElement (string assistiveTechnologyIdentifier) { using (var s = new NSString (assistiveTechnologyIdentifier)) @@ -72,12 +76,16 @@ public static NSObject FocusedElement (string assistiveTechnologyIdentifier) } // UIAccessibility.h +#if !NET [iOS (9,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] extern static /* BOOL */ bool UIAccessibilityIsShakeToUndoEnabled (); +#if !NET [iOS (9,0)] +#endif public static bool IsShakeToUndoEnabled { get { return UIAccessibilityIsShakeToUndoEnabled (); @@ -163,11 +171,15 @@ public static void ZoomFocusChanged (UIAccessibilityZoomType type, CGRect frame, extern public static void RegisterGestureConflictWithZoom (); // UIAccessibility.h +#if !NET [iOS (7,0)] +#endif [DllImport (Constants.UIKitLibrary)] extern static /* UIBezierPath* */ IntPtr UIAccessibilityConvertPathToScreenCoordinates (/* UIBezierPath* */ IntPtr path, /* UIView* */ IntPtr view); +#if !NET [iOS (7,0)] +#endif public static UIBezierPath ConvertPathToScreenCoordinates (UIBezierPath path, UIView view) { if (path == null) @@ -179,11 +191,15 @@ public static UIBezierPath ConvertPathToScreenCoordinates (UIBezierPath path, UI } // UIAccessibility.h +#if !NET [iOS (7,0)] +#endif [DllImport (Constants.UIKitLibrary)] extern static CGRect UIAccessibilityConvertFrameToScreenCoordinates (CGRect rect, /* UIView* */ IntPtr view); +#if !NET [iOS (7,0)] +#endif public static CGRect ConvertFrameToScreenCoordinates (CGRect rect, UIView view) { if (view == null) @@ -193,11 +209,15 @@ public static CGRect ConvertFrameToScreenCoordinates (CGRect rect, UIView view) } // UIAccessibility.h +#if !NET [iOS (7,0)] +#endif [DllImport (Constants.UIKitLibrary)] extern unsafe static void UIAccessibilityRequestGuidedAccessSession (/* BOOL */ [MarshalAs (UnmanagedType.I1)] bool enable, /* void(^completionHandler)(BOOL didSucceed) */ void * completionHandler); +#if !NET [iOS (7,0)] +#endif [BindingImpl (BindingImplOptions.Optimizable)] public static void RequestGuidedAccessSession (bool enable, Action completionHandler) { @@ -213,7 +233,9 @@ public static void RequestGuidedAccessSession (bool enable, Action complet } } +#if !NET [iOS (7,0)] +#endif public static Task RequestGuidedAccessSessionAsync (bool enable) { var tcs = new TaskCompletionSource (); @@ -235,12 +257,16 @@ static unsafe void TrampolineRequestGuidedAccessSession (IntPtr block, bool enab del (enable); } +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityDarkerSystemColorsEnabled (); +#if !NET [iOS (8,0)] +#endif public static bool DarkerSystemColorsEnabled { get { return UIAccessibilityDarkerSystemColorsEnabled (); @@ -248,7 +274,9 @@ public static bool DarkerSystemColorsEnabled { } #if !XAMCORE_4_0 +#if !NET [iOS (8,0)] +#endif [Obsolete ("Use 'DarkerSystemColorsEnabled' instead.")] public static bool DarkerSystemColosEnabled { get { @@ -257,12 +285,16 @@ public static bool DarkerSystemColosEnabled { } #endif +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsBoldTextEnabled (); +#if !NET [iOS (8,0)] +#endif public static bool IsBoldTextEnabled { get { return UIAccessibilityIsBoldTextEnabled (); @@ -277,24 +309,32 @@ public static bool IsBoldTextEnabled { [TV (14,0), iOS (14,0)] public static bool ButtonShapesEnabled => UIAccessibilityButtonShapesEnabled (); +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsGrayscaleEnabled (); +#if !NET [iOS (8,0)] +#endif static public bool IsGrayscaleEnabled { get { return UIAccessibilityIsGrayscaleEnabled (); } } +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsReduceMotionEnabled (); +#if !NET [iOS (8,0)] +#endif static public bool IsReduceMotionEnabled { get { return UIAccessibilityIsReduceMotionEnabled (); @@ -317,57 +357,80 @@ static public bool IsReduceMotionEnabled { [iOS (13,0), TV (13,0)] static public bool IsVideoAutoplayEnabled => UIAccessibilityIsVideoAutoplayEnabled (); +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsReduceTransparencyEnabled (); +#if !NET [iOS (8,0)] +#endif static public bool IsReduceTransparencyEnabled { get { return UIAccessibilityIsReduceTransparencyEnabled (); } } +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsSwitchControlRunning (); +#if !NET [iOS (8,0)] +#endif static public bool IsSwitchControlRunning { get { return UIAccessibilityIsSwitchControlRunning (); } } +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsSpeakSelectionEnabled (); + +#if !NET [iOS (8,0)] +#endif static public bool IsSpeakSelectionEnabled { get { return UIAccessibilityIsSpeakSelectionEnabled (); } } +#if !NET [iOS (8,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsSpeakScreenEnabled (); + +#if !NET [iOS (8,0)] +#endif static public bool IsSpeakScreenEnabled { get { return UIAccessibilityIsSpeakScreenEnabled (); } } +#if !NET [iOS (10,0), TV (10,0)] +#endif [DllImport (Constants.UIKitLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool UIAccessibilityIsAssistiveTouchRunning (); + +#if !NET [iOS (10,0), TV (10,0)] +#endif public static bool IsAssistiveTouchRunning { get { return UIAccessibilityIsAssistiveTouchRunning (); @@ -391,11 +454,15 @@ public static bool IsAssistiveTouchRunning { public static bool IsOnOffSwitchLabelsEnabled => UIAccessibilityIsOnOffSwitchLabelsEnabled (); #if !TVOS +#if !NET [iOS (10,0)] +#endif [DllImport (Constants.UIKitLibrary)] static extern nuint UIAccessibilityHearingDevicePairedEar (); +#if !NET [iOS (10,0)] +#endif public static UIAccessibilityHearingDeviceEar HearingDevicePairedEar { get { return (UIAccessibilityHearingDeviceEar)(ulong) UIAccessibilityHearingDevicePairedEar (); diff --git a/src/VideoToolbox/VTCompressionSession.cs b/src/VideoToolbox/VTCompressionSession.cs index 7c8b5be46ecf..5d852649a69d 100644 --- a/src/VideoToolbox/VTCompressionSession.cs +++ b/src/VideoToolbox/VTCompressionSession.cs @@ -9,6 +9,7 @@ // using System; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using CoreFoundation; using ObjCRuntime; @@ -17,7 +18,12 @@ using CoreVideo; namespace VideoToolbox { + +#if NET + [SupportedOSPlatform ("tvos10.2")] +#else [iOS (8,0), TV (10,2)] +#endif public class VTCompressionSession : VTSession { GCHandle callbackHandle; diff --git a/src/WatchKit/iOS/WKAccessibility.cs b/src/WatchKit/iOS/WKAccessibility.cs index 62be304e6112..9b82f5f73127 100644 --- a/src/WatchKit/iOS/WKAccessibility.cs +++ b/src/WatchKit/iOS/WKAccessibility.cs @@ -1,12 +1,17 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using ObjCRuntime; namespace WatchKit { +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public static class WKAccessibility { diff --git a/src/WatchKit/iOS/WKAccessibilityImageRegion.cs b/src/WatchKit/iOS/WKAccessibilityImageRegion.cs index 401fb9b6b2ab..1deeae9dae88 100644 --- a/src/WatchKit/iOS/WKAccessibilityImageRegion.cs +++ b/src/WatchKit/iOS/WKAccessibilityImageRegion.cs @@ -1,6 +1,7 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using CoreGraphics; using Foundation; @@ -8,7 +9,11 @@ namespace WatchKit { [Register ("WKAccessibilityImageRegion", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKAccessibilityImageRegion : NSObject { diff --git a/src/WatchKit/iOS/WKErrorCode.cs b/src/WatchKit/iOS/WKErrorCode.cs index cfe4ea26339f..94ddafc2e87d 100644 --- a/src/WatchKit/iOS/WKErrorCode.cs +++ b/src/WatchKit/iOS/WKErrorCode.cs @@ -1,12 +1,17 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public enum WKErrorCode : long { @@ -19,6 +24,11 @@ public enum WKErrorCode : long { RecordingFailedError = 6, } +#if NET + [UnsupportedOSPlatform ("ios")] +#else + [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] static public class WKErrorCodeExtensions { diff --git a/src/WatchKit/iOS/WKImageAnimatable.cs b/src/WatchKit/iOS/WKImageAnimatable.cs index 35071ac4cefd..5d065edec332 100644 --- a/src/WatchKit/iOS/WKImageAnimatable.cs +++ b/src/WatchKit/iOS/WKImageAnimatable.cs @@ -1,22 +1,34 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { +#if !NET [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public interface IWKImageAnimatable : INativeObject, IDisposable { +#if NET + [UnsupportedOSPlatform ("ios")] +#endif [Preserve (Conditional = true)] void StartAnimating (); +#if NET + [UnsupportedOSPlatform ("ios")] +#endif [Preserve (Conditional = true)] void StartAnimating (NSRange imageRange, double duration, nint repeatCount); +#if NET + [UnsupportedOSPlatform ("ios")] +#endif [Preserve (Conditional = true)] void StopAnimating (); } diff --git a/src/WatchKit/iOS/WKInterfaceButton.cs b/src/WatchKit/iOS/WKInterfaceButton.cs index 01aa65ff3e92..6fffa89a5685 100644 --- a/src/WatchKit/iOS/WKInterfaceButton.cs +++ b/src/WatchKit/iOS/WKInterfaceButton.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceButton", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceButton : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceController.cs b/src/WatchKit/iOS/WKInterfaceController.cs index d455c0079319..b47b378d0a63 100644 --- a/src/WatchKit/iOS/WKInterfaceController.cs +++ b/src/WatchKit/iOS/WKInterfaceController.cs @@ -1,6 +1,7 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using System.Threading.Tasks; using CoreGraphics; @@ -10,7 +11,11 @@ namespace WatchKit { [Register ("WKInterfaceController", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public abstract class WKInterfaceController : NSObject { diff --git a/src/WatchKit/iOS/WKInterfaceDate.cs b/src/WatchKit/iOS/WKInterfaceDate.cs index c55dd93ea85a..48d5c5cbbb79 100644 --- a/src/WatchKit/iOS/WKInterfaceDate.cs +++ b/src/WatchKit/iOS/WKInterfaceDate.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceDate", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceDate : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceDevice.cs b/src/WatchKit/iOS/WKInterfaceDevice.cs index 06329fdf4748..9fbac3b48641 100644 --- a/src/WatchKit/iOS/WKInterfaceDevice.cs +++ b/src/WatchKit/iOS/WKInterfaceDevice.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Runtime.Versioning; using CoreGraphics; using Foundation; @@ -10,7 +11,11 @@ namespace WatchKit { [Register ("WKInterfaceDevice", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceDevice : NSObject { diff --git a/src/WatchKit/iOS/WKInterfaceGroup.cs b/src/WatchKit/iOS/WKInterfaceGroup.cs index d741520c6096..ab8c39e6d467 100644 --- a/src/WatchKit/iOS/WKInterfaceGroup.cs +++ b/src/WatchKit/iOS/WKInterfaceGroup.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceGroup", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceGroup : WKInterfaceObject, IWKImageAnimatable { diff --git a/src/WatchKit/iOS/WKInterfaceImage.cs b/src/WatchKit/iOS/WKInterfaceImage.cs index f21958714d70..4c2d4c994bcc 100644 --- a/src/WatchKit/iOS/WKInterfaceImage.cs +++ b/src/WatchKit/iOS/WKInterfaceImage.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceImage", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceImage : WKInterfaceObject, IWKImageAnimatable { diff --git a/src/WatchKit/iOS/WKInterfaceLabel.cs b/src/WatchKit/iOS/WKInterfaceLabel.cs index 8a208a61cf00..dcc9eddf62dd 100644 --- a/src/WatchKit/iOS/WKInterfaceLabel.cs +++ b/src/WatchKit/iOS/WKInterfaceLabel.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceLabel", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceLabel : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceMap.cs b/src/WatchKit/iOS/WKInterfaceMap.cs index 1c64f33a5980..2cc62cb6bba4 100644 --- a/src/WatchKit/iOS/WKInterfaceMap.cs +++ b/src/WatchKit/iOS/WKInterfaceMap.cs @@ -1,6 +1,7 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using CoreGraphics; using Foundation; @@ -8,7 +9,11 @@ namespace WatchKit { [Register ("WKInterfaceMap", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceMap : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceMapPinColor.cs b/src/WatchKit/iOS/WKInterfaceMapPinColor.cs index 252447f966ed..471200b6d5af 100644 --- a/src/WatchKit/iOS/WKInterfaceMapPinColor.cs +++ b/src/WatchKit/iOS/WKInterfaceMapPinColor.cs @@ -1,11 +1,16 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using ObjCRuntime; namespace WatchKit { +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public enum WKInterfaceMapPinColor : long { diff --git a/src/WatchKit/iOS/WKInterfaceObject.cs b/src/WatchKit/iOS/WKInterfaceObject.cs index faed3fc5e20d..998b6591dcb5 100644 --- a/src/WatchKit/iOS/WKInterfaceObject.cs +++ b/src/WatchKit/iOS/WKInterfaceObject.cs @@ -1,6 +1,7 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using CoreGraphics; using Foundation; @@ -9,7 +10,11 @@ namespace WatchKit { [Register ("WKInterfaceObject", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceObject : NSObject { diff --git a/src/WatchKit/iOS/WKInterfaceSeparator.cs b/src/WatchKit/iOS/WKInterfaceSeparator.cs index e7074cbe864b..2d77cc87d2ab 100644 --- a/src/WatchKit/iOS/WKInterfaceSeparator.cs +++ b/src/WatchKit/iOS/WKInterfaceSeparator.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceSeparator", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceSeparator : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceSlider.cs b/src/WatchKit/iOS/WKInterfaceSlider.cs index 885524cba6bb..9acc25b3e323 100644 --- a/src/WatchKit/iOS/WKInterfaceSlider.cs +++ b/src/WatchKit/iOS/WKInterfaceSlider.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceSlider", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceSlider : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceSwitch.cs b/src/WatchKit/iOS/WKInterfaceSwitch.cs index 8f0b4a8c4ce0..d048fe4aac20 100644 --- a/src/WatchKit/iOS/WKInterfaceSwitch.cs +++ b/src/WatchKit/iOS/WKInterfaceSwitch.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceSwitch", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceSwitch : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceTable.cs b/src/WatchKit/iOS/WKInterfaceTable.cs index 8633ce0bfb86..c64e98fb5041 100644 --- a/src/WatchKit/iOS/WKInterfaceTable.cs +++ b/src/WatchKit/iOS/WKInterfaceTable.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceTable", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceTable : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKInterfaceTimer.cs b/src/WatchKit/iOS/WKInterfaceTimer.cs index cc1288d2ce96..1a87a4f1c754 100644 --- a/src/WatchKit/iOS/WKInterfaceTimer.cs +++ b/src/WatchKit/iOS/WKInterfaceTimer.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKInterfaceTimer", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKInterfaceTimer : WKInterfaceObject { diff --git a/src/WatchKit/iOS/WKMenuItemIcon.cs b/src/WatchKit/iOS/WKMenuItemIcon.cs index 50f811827c49..3388a4d658f4 100644 --- a/src/WatchKit/iOS/WKMenuItemIcon.cs +++ b/src/WatchKit/iOS/WKMenuItemIcon.cs @@ -1,11 +1,16 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using ObjCRuntime; namespace WatchKit { +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public enum WKMenuItemIcon : long { diff --git a/src/WatchKit/iOS/WKTextInputMode.cs b/src/WatchKit/iOS/WKTextInputMode.cs index 37d9b166b73c..f76ccd8c924a 100644 --- a/src/WatchKit/iOS/WKTextInputMode.cs +++ b/src/WatchKit/iOS/WKTextInputMode.cs @@ -1,11 +1,16 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using ObjCRuntime; namespace WatchKit { +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public enum WKTextInputMode : long { diff --git a/src/WatchKit/iOS/WKUserNotificationInterfaceController.cs b/src/WatchKit/iOS/WKUserNotificationInterfaceController.cs index 9b1c88540571..577177a4da01 100644 --- a/src/WatchKit/iOS/WKUserNotificationInterfaceController.cs +++ b/src/WatchKit/iOS/WKUserNotificationInterfaceController.cs @@ -1,13 +1,18 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using Foundation; using ObjCRuntime; namespace WatchKit { [Register ("WKUserNotificationInterfaceController", SkipRegistration = true)] +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public class WKUserNotificationInterfaceController : WKInterfaceController { diff --git a/src/WatchKit/iOS/WKUserNotificationInterfaceType.cs b/src/WatchKit/iOS/WKUserNotificationInterfaceType.cs index 502b6f7c4dad..46efad5b3a0e 100644 --- a/src/WatchKit/iOS/WKUserNotificationInterfaceType.cs +++ b/src/WatchKit/iOS/WKUserNotificationInterfaceType.cs @@ -1,12 +1,17 @@ #if __IOS__ using System; using System.ComponentModel; +using System.Runtime.Versioning; using ObjCRuntime; namespace WatchKit { +#if NET + [UnsupportedOSPlatform ("ios")] +#else [Unavailable (PlatformName.iOS, PlatformArchitecture.All)] +#endif [Obsolete (Constants.WatchKitRemoved)] [EditorBrowsable (EditorBrowsableState.Never)] public enum WKUserNotificationInterfaceType : long { diff --git a/src/appkit.cs b/src/appkit.cs index dee118452e48..6b4ab8a705a7 100644 --- a/src/appkit.cs +++ b/src/appkit.cs @@ -8343,6 +8343,7 @@ interface NSMenuItemCell { } [Mac (10, 0, 0, PlatformArchitecture.Arch32)] // kept for the arch limitation + [Deprecated (PlatformName.MacOSX, 10, 15, message: "API only available on 32bits platforms.")] [BaseType (typeof (NSView))] interface NSMenuView { [Static] diff --git a/src/avfoundation.cs b/src/avfoundation.cs index e870f32eb56c..f755e66137e8 100644 --- a/src/avfoundation.cs +++ b/src/avfoundation.cs @@ -196,6 +196,7 @@ interface AVMediaType { [NoTV][NoWatch] [Field ("AVMediaTypeTimedMetadata")] // last header where I can find this: iOS 5.1 SDK, 10.7 only on Mac [Availability (Obsoleted = Platform.iOS_6_0)] + [Deprecated (PlatformName.iOS, 12,0, message: "Always 'null'.")] [Availability (Obsoleted = Platform.Mac_10_8)] [NoMacCatalyst] NSString TimedMetadata { get; } diff --git a/src/bgen/bgen.csproj b/src/bgen/bgen.csproj index 069aaaf9d7e6..a943896e979c 100644 --- a/src/bgen/bgen.csproj +++ b/src/bgen/bgen.csproj @@ -332,6 +332,9 @@ Driver.execution.cs + + SdkVersions.cs + diff --git a/src/corebluetooth.cs b/src/corebluetooth.cs index 8e76abc4e118..4d809c5f51d6 100644 --- a/src/corebluetooth.cs +++ b/src/corebluetooth.cs @@ -698,7 +698,6 @@ interface CBUUID : NSCopying { [Export ("UUIDWithData:")] CBUUID FromData (NSData theData); - [Availability (Deprecated = Platform.iOS_9_0)] [Deprecated (PlatformName.MacOSX, 10, 13)] [Deprecated (PlatformName.iOS, 9, 0)] [NoWatch] diff --git a/src/frameworks.sources b/src/frameworks.sources index f5a6af145395..ef61cc74a216 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1575,9 +1575,12 @@ TVMLKIT_CORE_SOURCES = \ # TVServices -TVSERVICES_CORE_SOURCES = \ +TVSERVICES_API_SOURCES = \ TVServices/TVEnums.cs \ +TVSERVICES_CORE_SOURCES = \ + TVServices/TVContentItemImageShape.cs \ + # Twitter TWITTER_CORE_SOURCES = \ diff --git a/src/generate-type-forwarders/Program.cs b/src/generate-type-forwarders/Program.cs index 57358049d603..3fe5cf5696a2 100644 --- a/src/generate-type-forwarders/Program.cs +++ b/src/generate-type-forwarders/Program.cs @@ -24,7 +24,8 @@ public static int Main (string [] args) var forwardFrom = args [0]; var forwardTo = args [1]; var output = args [2]; - return Fix (forwardFrom, forwardTo, output); + var min_version = Version.Parse (args [3]); + return Fix (forwardFrom, forwardTo, output, min_version); } static bool IsVisible (this TypeDefinition type) @@ -535,9 +536,13 @@ static void EmitPNSE (StringBuilder sb, TypeDefinition type, int indent) if (!type.IsNested) sb.Append ("namespace ").Append (type.Namespace).AppendLine (" {"); - sb.Append ('\t', indent); if (type.BaseType?.FullName == "System.MulticastDelegate") { - sb.Append ("public delegate "); + // [Uns|S]upportedOSPlatformAttribute is not supported on delegates + // we generate it in legacy so the behaviour remains consistant with older tooling + sb.AppendLine ("#if !NET"); + sb.Append ('\t', indent).AppendLine ("[Unavailable (PlatformName.MacCatalyst)]"); + sb.AppendLine ("#endif"); + sb.Append ('\t', indent).Append ("public delegate "); var invoke = type.Methods.First (v => v.Name == "Invoke"); EmitTypeName (sb, invoke.ReturnType); sb.Append (' '); @@ -547,6 +552,12 @@ static void EmitPNSE (StringBuilder sb, TypeDefinition type, int indent) EmitParameters (sb, invoke); sb.AppendLine (");"); } else { + sb.AppendLine ("#if NET"); + sb.Append ('\t', indent).AppendLine ("[UnsupportedOSPlatform (\"maccatalyst\")]"); + sb.AppendLine ("#else"); + sb.Append ('\t', indent).AppendLine ("[Unavailable (PlatformName.MacCatalyst)]"); + sb.AppendLine ("#endif"); + sb.Append ('\t', indent); // other are filtered not to generate stubs if (type.IsNestedFamily) sb.Append ("protected "); @@ -686,7 +697,7 @@ static void PrintGenericParameters (StringBuilder sb, IList ge sb.Append ('>'); } - static int Fix (string forwardFrom, string forwardTo, string output) + static int Fix (string forwardFrom, string forwardTo, string output, Version minVersion) { var rp = new ReaderParameters (ReadingMode.Deferred); var resolver = new DefaultAssemblyResolver (); @@ -697,6 +708,14 @@ static int Fix (string forwardFrom, string forwardTo, string output) var sb = new StringBuilder (); sb.AppendLine ("using System.Runtime.CompilerServices;"); + sb.AppendLine ("#if NET"); + sb.AppendLine ("using System.Runtime.Versioning;"); + sb.AppendLine ("[assembly: TargetPlatform (\"maccatalyst\")]"); + sb.AppendLine ($"[assembly: SupportedOSPlatform (\"maccatalyst{minVersion.Major}.{minVersion.Minor}\")]"); + sb.AppendLine ("#else"); + sb.AppendLine ("using ObjCRuntime;"); + sb.AppendLine ($"[assembly: Introduced (PlatformName.MacCatalyst, {minVersion.Major},{minVersion.Minor})]"); + sb.AppendLine ("#endif"); foreach (var exportedType in from.MainModule.ExportedTypes) { sb.Append ("[assembly: TypeForwardedToAttribute (typeof ("); diff --git a/src/generator.cs b/src/generator.cs index 7e47fad67978..93a15190028f 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -728,6 +728,9 @@ public NamespaceManager (BindingTouch binding_touch, string customObjCRuntimeNS, ImplicitNamespaces.Add ("System.Diagnostics"); ImplicitNamespaces.Add ("System.Diagnostics.CodeAnalysis"); ImplicitNamespaces.Add ("System.ComponentModel"); +#if NET + ImplicitNamespaces.Add ("System.Runtime.Versioning"); +#endif ImplicitNamespaces.Add ("System.Threading.Tasks"); ImplicitNamespaces.Add ("CoreFoundation"); ImplicitNamespaces.Add ("Foundation"); @@ -3230,6 +3233,36 @@ bool Duplicated (AvailabilityBaseAttribute candidate, AvailabilityBaseAttribute[ return false; } + // do not generate introduced/supported attributes for versions earlier than the minimum supported + // more important since dotnet and legacy have different minimums (so this can't be done in binding files) + bool FilterMinimumVersion (AvailabilityBaseAttribute aa) + { + if (aa.AvailabilityKind != AvailabilityKind.Introduced) + return true; + + Version min; + switch (aa.Platform) { + case PlatformName.iOS: + min = Xamarin.SdkVersions.MiniOSVersion; + break; + case PlatformName.TvOS: + min = Xamarin.SdkVersions.MinTVOSVersion; + break; + case PlatformName.WatchOS: + min = Xamarin.SdkVersions.MinWatchOSVersion; + break; + case PlatformName.MacOSX: + min = Xamarin.SdkVersions.MinOSXVersion; + break; + case PlatformName.MacCatalyst: + min = Xamarin.SdkVersions.MinMacCatalystVersion; + break; + default: + throw new BindingException (1047, aa.Platform.ToString ()); + } + return aa.Version > min; + } + public bool PrintPlatformAttributes (MemberInfo mi, Type type = null) { bool printed = false; @@ -3259,7 +3292,8 @@ public bool PrintPlatformAttributes (MemberInfo mi, Type type = null) // can't introduce or deprecate/obsolete a member on a type that is not available if (IsUnavailable (type_ca, availability.Platform)) continue; - print (availability.ToString ()); + if (FilterMinimumVersion (availability)) + print (availability.ToString ()); printed = true; break; } @@ -3320,6 +3354,8 @@ public void PrintPlatformAttributesNoDuplicates (MemberInfo generatedType, Membe // the type, in which we are inlining the current method, might already have the same availability attribute // which we would duplicate if generated foreach (var availability in inlined_ca) { + if (!FilterMinimumVersion (availability)) + continue; var s = availability.ToString (); if (!generated_type_ca.Contains (s)) print (s); diff --git a/src/generator.csproj b/src/generator.csproj index 4f722eed4d5c..045bcbc3bddd 100644 --- a/src/generator.csproj +++ b/src/generator.csproj @@ -401,6 +401,9 @@ Driver.execution.cs + + SdkVersions.cs + diff --git a/tests/common/PlatformInfo.cs b/tests/common/PlatformInfo.cs index eb499cf8f4c3..f1a3b32095a8 100644 --- a/tests/common/PlatformInfo.cs +++ b/tests/common/PlatformInfo.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; +using System.Runtime.Versioning; using ObjCRuntime; using Foundation; @@ -90,6 +91,54 @@ static PlatformInfo GetHostPlatformInfo () public static class AvailabilityExtensions { +#if NET + public static AvailabilityBaseAttribute Convert (this OSPlatformAttribute a) + { + if (a == null) + return null; + + PlatformName p; + int n = 0; + switch (a.PlatformName) { + case string dummy when a.PlatformName.StartsWith ("ios"): + p = PlatformName.iOS; + n = "ios".Length; + break; + case string dummy when a.PlatformName.StartsWith ("tvos"): + p = PlatformName.TvOS; + n = "tvos".Length; + break; + case string dummy when a.PlatformName.StartsWith ("watchos"): + p = PlatformName.WatchOS; + n = "watchos".Length; + break; + case string dummy when a.PlatformName.StartsWith ("macos"): + p = PlatformName.MacOSX; + n = "macos".Length; + break; + case string dummy when a.PlatformName.StartsWith ("maccatalyst"): + p = PlatformName.MacCatalyst; + n = "maccatalyst".Length; + break; + default: + return null; + } + bool versioned = Version.TryParse (a.PlatformName [n..], out var v); + + if (a is SupportedOSPlatformAttribute) + return new IntroducedAttribute (p, v.Major, v.Minor); + if (a is UnsupportedOSPlatformAttribute) { + // if a version is provided then it means it was deprecated + // if no version is provided then it means it's unavailable + if (versioned) + return new DeprecatedAttribute (p, v.Major, v.Minor); + else + return new UnavailableAttribute (p); + } + return null; + } +#endif + public static bool IsAvailableOnHostPlatform (this ICustomAttributeProvider attributeProvider) { return attributeProvider.IsAvailable (PlatformInfo.Host); @@ -97,10 +146,22 @@ public static bool IsAvailableOnHostPlatform (this ICustomAttributeProvider attr public static bool IsAvailable (this ICustomAttributeProvider attributeProvider, PlatformInfo targetPlatform) { +#if NET + var list = new List (); + foreach (var ca in attributeProvider.GetCustomAttributes (true)) { + if (ca is OSPlatformAttribute aa) + list.Add (aa.Convert ()); + // FIXME - temporary, while older attributes co-exists (in manual bindings) + if (ca is AvailabilityBaseAttribute old) + list.Add (old); + } + return list.IsAvailable (targetPlatform); +#else return attributeProvider .GetCustomAttributes (true) .OfType () .IsAvailable (targetPlatform); +#endif } public static bool IsAvailableOnHostPlatform (this IEnumerable attributes) diff --git a/tests/generator/BGenTests.cs b/tests/generator/BGenTests.cs index 9c0c3666999a..36a53f3d5938 100644 --- a/tests/generator/BGenTests.cs +++ b/tests/generator/BGenTests.cs @@ -101,11 +101,14 @@ public void Bug15307 () BuildFile (Profile.iOS, "bug15307.cs"); } +#if !NET + // error BI1055: bgen: Internal error: failed to convert type 'System.Runtime.Versioning.SupportedOSPlatformAttribute, System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case. [Test] public void Bug15799 () { BuildFile (Profile.iOS, "bug15799.cs"); } +#endif [Test] public void Bug16036 () @@ -119,11 +122,14 @@ public void Bug17232 () BuildFile (Profile.iOS, "bug17232.cs"); } +#if !NET + // error BI1055: bgen: Internal error: failed to convert type 'System.Runtime.Versioning.SupportedOSPlatformAttribute, System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case. [Test] public void Bug23041 () { BuildFile (Profile.iOS, "bug23041.cs"); } +#endif [Test] public void Bug24078 () @@ -218,8 +224,12 @@ public void Bug35176 () .Union (allTypes.SelectMany ((type) => type.Methods)) .Union (allTypes.SelectMany ((type) => type.Fields)) .Union (allTypes.SelectMany ((type) => type.Properties)); - - var preserves = allMembers.Sum ((v) => v.CustomAttributes.Count ((ca) => ca.AttributeType.Name == "IntroducedAttribute")); +#if NET + const string attrib = "SupportedOSPlatformAttribute"; +#else + const string attrib = "IntroducedAttribute"; +#endif + var preserves = allMembers.Sum ((v) => v.CustomAttributes.Count ((ca) => ca.AttributeType.Name == attrib)); Assert.AreEqual (10, preserves, "Introduced attribute count"); // If you modified code that generates IntroducedAttributes please update the attribute count } @@ -313,11 +323,14 @@ public void Bug53076WithModel () Assert.AreEqual (10, methodCount, "Async method count"); } +#if !NET + // error BI1055: bgen: Internal error: failed to convert type 'System.Runtime.Versioning.SupportedOSPlatformAttribute, System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case. [Test] public void StackOverflow20696157 () { BuildFile (Profile.iOS, "sof20696157.cs"); } +#endif [Test] public void HyphenInName () diff --git a/tests/generator/bug35176.cs b/tests/generator/bug35176.cs index a06b049abfd7..0c5730f56e8e 100644 --- a/tests/generator/bug35176.cs +++ b/tests/generator/bug35176.cs @@ -5,8 +5,8 @@ namespace Bug35176 { - [Introduced (PlatformName.iOS, 8,0)] - [Introduced (PlatformName.MacOSX, 10,10)] + [Introduced (PlatformName.iOS, 14,3)] + [Introduced (PlatformName.MacOSX, 11,2)] [Protocol] interface FooInterface { @@ -15,7 +15,7 @@ interface FooInterface { UIView FooView { get; set; } [Export ("BarView")] - UIView BarView { [Introduced (PlatformName.iOS, 9,0)] get; } + UIView BarView { [Introduced (PlatformName.iOS, 14,4)] get; } [Export ("barMember:")] UIView GetBarMember (int x); diff --git a/tests/introspection/ApiAvailabilityTest.cs b/tests/introspection/ApiAvailabilityTest.cs index 5837696a28b1..7759b98ce793 100644 --- a/tests/introspection/ApiAvailabilityTest.cs +++ b/tests/introspection/ApiAvailabilityTest.cs @@ -22,8 +22,11 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Runtime.Versioning; +using System.Text; using NUnit.Framework; using ObjCRuntime; +using Xamarin.Tests; namespace Introspection { @@ -52,6 +55,7 @@ public ApiAvailabilityTest () #else #error No Platform Defined #endif + Filter = (AvailabilityBaseAttribute arg) => { return (arg.AvailabilityKind != AvailabilityKind.Introduced) || (arg.Platform != Platform); }; @@ -198,18 +202,36 @@ public void Deprecated () } #endif + string ToString (ICustomAttributeProvider cap) + { + var s = cap.ToString (); + if (cap is MemberInfo mi) { + var i = s.IndexOf (' '); + if (i != -1) { + // a method/property without the declaring type is hard to track down + s = s.Insert (i + 1, mi.DeclaringType + "::"); + } + } + return s; + } + protected AvailabilityBaseAttribute CheckAvailability (ICustomAttributeProvider cap) { var attrs = cap.GetCustomAttributes (false); - foreach (var a in attrs) { + foreach (var ca in attrs) { + var a = ca; +#if NET + a = (a as OSPlatformAttribute)?.Convert (); +#endif if (a is AvailabilityBaseAttribute aa) { if (Filter (aa)) continue; - if (aa.Version < Minimum) { + // FIXME should be `<=` but that another large change best done in a different PR + if ((aa.AvailabilityKind == AvailabilityKind.Introduced) && (aa.Version < Minimum)) { switch (aa.Architecture) { case PlatformArchitecture.All: case PlatformArchitecture.None: - AddErrorLine ($"[FAIL] {aa.Version} < {Minimum} (Min) on '{cap}'."); + AddErrorLine ($"[FAIL] {aa.Version} <= {Minimum} (Min) on '{ToString (cap)}'."); break; default: // An old API still needs the annotations when not available on all architectures @@ -218,7 +240,7 @@ protected AvailabilityBaseAttribute CheckAvailability (ICustomAttributeProvider } } if (aa.Version > Maximum) - AddErrorLine ($"[FAIL] {aa.Version} > {Maximum} (Max) on '{cap}'."); + AddErrorLine ($"[FAIL] {aa.Version} > {Maximum} (Max) on '{ToString (cap)}'."); return aa; } } @@ -227,7 +249,11 @@ protected AvailabilityBaseAttribute CheckAvailability (ICustomAttributeProvider bool IsUnavailable (ICustomAttributeProvider cap) { - foreach (var ca in cap.GetCustomAttributes (false)) { + foreach (var a in cap.GetCustomAttributes (false)) { + var ca = a; +#if NET + ca = (a as OSPlatformAttribute)?.Convert (); +#endif if (ca is UnavailableAttribute ua) { if (ua.Platform == Platform) return true; @@ -238,7 +264,11 @@ bool IsUnavailable (ICustomAttributeProvider cap) AvailabilityBaseAttribute GetAvailable (ICustomAttributeProvider cap) { - foreach (var ca in cap.GetCustomAttributes (false)) { + foreach (var a in cap.GetCustomAttributes (false)) { + var ca = a; +#if NET + ca = (a as OSPlatformAttribute)?.Convert (); +#endif if (ca is AvailabilityBaseAttribute aa) { if ((aa.AvailabilityKind != AvailabilityKind.Unavailable) && (aa.Platform == Platform)) return aa; @@ -293,8 +323,13 @@ void CheckDupes (MemberInfo m, Type t, ISet type_level) member_level.Clear (); foreach (var a in m.GetCustomAttributes (false)) { var s = String.Empty; +#if NET + if (a is OSPlatformAttribute aa) + s = $"[{a.GetType().Name} (\"{aa.PlatformName}\")]"; +#else if (a is AvailabilityBaseAttribute aa) s = aa.ToString (); +#endif if (s.Length > 0) { if (type_level.Contains (s)) AddErrorLine ($"[FAIL] Both '{t}' and '{m}' are marked with `{s}`."); @@ -318,8 +353,13 @@ public void Duplicates () type_level.Clear (); foreach (var a in t.GetCustomAttributes (false)) { +#if NET + if (a is OSPlatformAttribute aa) + type_level.Add ($"[{a.GetType().Name} (\"{aa.PlatformName}\")]"); +#else if (a is AvailabilityBaseAttribute aa) type_level.Add (aa.ToString ()); +#endif } foreach (var p in t.GetProperties (BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { @@ -336,5 +376,54 @@ public void Duplicates () } AssertIfErrors ("{0} API with members duplicating type-level attributes", Errors); } + +#if NET + string CheckLegacyAttributes (ICustomAttributeProvider cap) + { + var sb = new StringBuilder (); + foreach (var a in cap.GetCustomAttributes (false)) { + if (a is AvailabilityBaseAttribute aa) { + sb.AppendLine (aa.ToString ()); + } + } + return sb.ToString (); + } + + [Test] +#if IOS || TVOS + [Ignore ("work in progress")] +#endif + public void LegacyAttributes () + { + //LogProgress = true; + Errors = 0; + foreach (Type t in Assembly.GetTypes ()) { + if (LogProgress) + Console.WriteLine ($"T: {t}"); + var type_level = CheckLegacyAttributes (t); + if (type_level.Length > 0) + AddErrorLine ($"[FAIL] '{t.FullName}' has legacy attribute(s): {type_level}"); + + foreach (var p in t.GetProperties (BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { + if (LogProgress) + Console.WriteLine ($"P: {p}"); + + var member_level = CheckLegacyAttributes (p); + if (member_level.Length > 0) + AddErrorLine ($"[FAIL] '{t.FullName}::{p.Name}' has legacy attribute(s): {member_level}"); + } + + foreach (var m in t.GetMembers (BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { + if (LogProgress) + Console.WriteLine ($"M: {m}"); + + var member_level = CheckLegacyAttributes (m); + if (member_level.Length > 0) + AddErrorLine ($"[FAIL] '{t.FullName}::{m.Name}' has legacy attribute(s): {member_level}"); + } + } + AssertIfErrors ("{0} API with mixed legacy availability attributes", Errors); + } +#endif } } diff --git a/tests/introspection/ApiSignatureTest.cs b/tests/introspection/ApiSignatureTest.cs index 66e97ff49758..2d9acfdbd7d1 100644 --- a/tests/introspection/ApiSignatureTest.cs +++ b/tests/introspection/ApiSignatureTest.cs @@ -857,6 +857,7 @@ static bool IsDiscouraged (MemberInfo mi) case "AdviceAttribute": case "ObsoletedAttribute": case "DeprecatedAttribute": + case "UnsupportedOSPlatformAttribute": return true; } } diff --git a/tests/xharness/Jenkins/NUnitTestTasksEnumerable.cs b/tests/xharness/Jenkins/NUnitTestTasksEnumerable.cs index 5961f4d6edf8..6ab0fe196498 100644 --- a/tests/xharness/Jenkins/NUnitTestTasksEnumerable.cs +++ b/tests/xharness/Jenkins/NUnitTestTasksEnumerable.cs @@ -57,7 +57,7 @@ public IEnumerator GetEnumerator () Platform = TestPlatform.iOS, TestName = "MSBuild tests", Mode = "Integration", - Timeout = TimeSpan.FromMinutes (90), + Timeout = TimeSpan.FromMinutes (120), Ignored = !jenkins.IncludeMSBuild, SupportsParallelExecution = false, }; diff --git a/tests/xharness/MonoNativeInfo.cs b/tests/xharness/MonoNativeInfo.cs index c63520d6a446..78d9250cfc2c 100644 --- a/tests/xharness/MonoNativeInfo.cs +++ b/tests/xharness/MonoNativeInfo.cs @@ -71,13 +71,13 @@ public static string GetMinimumOSVersion (DevicePlatform platform, MonoNativeFla case MonoNativeFlavor.Compat: switch (platform) { case DevicePlatform.iOS: - return "8.0"; + return Xamarin.SdkVersions.MiniOS; case DevicePlatform.tvOS: - return "9.0"; + return Xamarin.SdkVersions.MinTVOS; case DevicePlatform.watchOS: - return "2.0"; + return Xamarin.SdkVersions.MinWatchOS; case DevicePlatform.macOS: - return "10.9"; + return Xamarin.SdkVersions.MinOSX; default: throw new Exception ($"Unknown DevicePlatform: {platform}"); } diff --git a/tests/xharness/Targets/TVOSTarget.cs b/tests/xharness/Targets/TVOSTarget.cs index 388dd03fb313..a20e00bd6f41 100644 --- a/tests/xharness/Targets/TVOSTarget.cs +++ b/tests/xharness/Targets/TVOSTarget.cs @@ -65,7 +65,7 @@ public override string DeviceArchitectures { protected override string GetMinimumOSVersion (string templateMinimumOSVersion) { if (MonoNativeInfo == null) - return "9.0"; + return Xamarin.SdkVersions.MinTVOS; return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.tvOS, MonoNativeInfo.Flavor); } From 605bc43e4453ca6fe6d86bb278a47c4d9a1465c9 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 10 Apr 2021 19:02:55 +0200 Subject: [PATCH 2/2] [dotnet] Handle `lib` prefix for P/Invokes for runtime native libraries (#11158) * Workaround dotnet/runtime#47533 and avoid listing required symbols when native libraries are dynamically linked * Don't call LibMonoNativeLinkMode on macOS builds * Apply iOS workarounds also for tvOS and Mac Catalyst --- tools/common/Target.cs | 6 +++ .../MonoTouch.Tuner/ListExportedSymbols.cs | 43 +++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/tools/common/Target.cs b/tools/common/Target.cs index 7b729215b6fb..b2656d768040 100644 --- a/tools/common/Target.cs +++ b/tools/common/Target.cs @@ -786,9 +786,15 @@ void GenerateIOSMain (StringWriter sw, Abi abi) else mono_native_lib = app.GetLibNativeName () + ".dylib"; sw.WriteLine (); +#if NET + sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"libSystem.Native\", NULL, \"{mono_native_lib}\", NULL);"); + sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"libSystem.Security.Cryptography.Native.Apple\", NULL, \"{mono_native_lib}\", NULL);"); + sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"libSystem.Net.Security.Native\", NULL, \"{mono_native_lib}\", NULL);"); +#else sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Native\", NULL, \"{mono_native_lib}\", NULL);"); sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Security.Cryptography.Native.Apple\", NULL, \"{mono_native_lib}\", NULL);"); sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Net.Security.Native\", NULL, \"{mono_native_lib}\", NULL);"); +#endif sw.WriteLine (); } } diff --git a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs index 3763002e085e..2a8fb6dbe0f9 100644 --- a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs +++ b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs @@ -104,6 +104,7 @@ void ProcessMethod (MethodDefinition method) { if (method.IsPInvokeImpl && method.HasPInvokeInfo && method.PInvokeInfo != null) { var pinfo = method.PInvokeInfo; + bool addPInvokeSymbol = false; if (state != null) { switch (pinfo.EntryPoint) { @@ -125,37 +126,55 @@ void ProcessMethod (MethodDefinition method) DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method); break; + case "libSystem.Net.Security.Native": case "System.Net.Security.Native": #if NET + // tvOS does not ship with System.Net.Security.Native due to https://github.com/dotnet/runtime/issues/45535 if (DerivedLinkContext.App.Platform == ApplePlatform.TVOS) { Driver.Log (4, "Did not add native reference to {0} in {1} referenced by {2} in {3}.", pinfo.EntryPoint, pinfo.Module.Name, method.FullName, method.Module.Name); - break; // tvOS does not ship with System.Net.Security.Native due to https://github.com/dotnet/runtime/issues/45535 + break; } +#endif + addPInvokeSymbol = true; + break; - if (DerivedLinkContext.App.Platform == ApplePlatform.MacOSX) { + case "libSystem.Security.Cryptography.Native.Apple": + case "System.Security.Cryptography.Native.Apple": +#if NET + // https://github.com/dotnet/runtime/issues/47533 + if (DerivedLinkContext.App.Platform != ApplePlatform.MacOSX) { Driver.Log (4, "Did not add native reference to {0} in {1} referenced by {2} in {3}.", pinfo.EntryPoint, pinfo.Module.Name, method.FullName, method.Module.Name); - break; // The macOS version of the BCL has several references to native methods supposedly in libSystem.Net.Security.Native that aren't there, so skip it. + break; } - - goto case "System.Native"; #endif + addPInvokeSymbol = true; + break; + + case "libSystem.Native": case "System.Native": #if NET - if (DerivedLinkContext.App.Platform == ApplePlatform.MacOSX) { + // https://github.com/dotnet/runtime/issues/47533 + if (DerivedLinkContext.App.Platform != ApplePlatform.MacOSX && pinfo.EntryPoint == "SystemNative_ConfigureTerminalForChildProcess") { Driver.Log (4, "Did not add native reference to {0} in {1} referenced by {2} in {3}.", pinfo.EntryPoint, pinfo.Module.Name, method.FullName, method.Module.Name); - break; // The macOS version of the BCL has several references to native methods supposedly in libSystem.Native that aren't there, so skip it. + break; } - goto case "System.Security.Cryptography.Native.Apple"; #endif - case "System.Security.Cryptography.Native.Apple": - Driver.Log (4, "Adding native reference to {0} in {1} because it's referenced by {2} in {3}.", pinfo.EntryPoint, pinfo.Module.Name, method.FullName, method.Module.Name); - DerivedLinkContext.RequireMonoNative = true; - DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method); + addPInvokeSymbol = true; break; + default: Driver.Log (4, "Did not add native reference to {0} in {1} referenced by {2} in {3}.", pinfo.EntryPoint, pinfo.Module.Name, method.FullName, method.Module.Name); break; } + + if (addPInvokeSymbol) { + Driver.Log (4, "Adding native reference to {0} in {1} because it's referenced by {2} in {3}.", pinfo.EntryPoint, pinfo.Module.Name, method.FullName, method.Module.Name); + DerivedLinkContext.RequireMonoNative = true; + if (DerivedLinkContext.App.Platform != ApplePlatform.MacOSX && + DerivedLinkContext.App.LibMonoNativeLinkMode == AssemblyBuildTarget.StaticObject) { + DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method); + } + } } if (method.IsPropertyMethod ()) {