diff --git a/src/CoreFoundation/CFAllocator.cs b/src/CoreFoundation/CFAllocator.cs
index bc53bb8fd77b..4437f68d82c7 100644
--- a/src/CoreFoundation/CFAllocator.cs
+++ b/src/CoreFoundation/CFAllocator.cs
@@ -34,10 +34,6 @@
using Foundation;
using ObjCRuntime;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
// CFBase.h
@@ -50,20 +46,8 @@ public partial class CFAllocator : NativeObject {
static CFAllocator? Null_cf;
#endif
-#if !NET
- [Obsolete ("Use the overload that takes a 'bool owns' parameter instead.")]
- public CFAllocator (NativeHandle handle)
- : base (handle, true /* backwards compatibility means we have to pass true here as opposed to the general pattern */)
- {
- }
-#endif
-
[Preserve (Conditional = true)]
-#if NET
internal CFAllocator (NativeHandle handle, bool owns)
-#else
- public CFAllocator (NativeHandle handle, bool owns)
-#endif
: base (handle, owns)
{
}
diff --git a/src/CoreFoundation/CFArray.cs b/src/CoreFoundation/CFArray.cs
index 3f0ec3c5bf08..cb9088575bb2 100644
--- a/src/CoreFoundation/CFArray.cs
+++ b/src/CoreFoundation/CFArray.cs
@@ -34,20 +34,12 @@
using Foundation;
using ObjCRuntime;
-#if NET
using CFIndex = System.IntPtr;
-#else
-using CFIndex = System.nint;
-#endif
using CFArrayRef = System.IntPtr;
using CFAllocatorRef = System.IntPtr;
#nullable enable
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
// interesting bits: https://github.com/opensource-apple/CF/blob/master/CFArray.c
@@ -56,13 +48,6 @@ public partial class CFArray : NativeObject {
// this cache the handle instead of issuing a native call
internal static NativeHandle CFNullHandle = _CFNullHandle;
-#if !NET
- internal CFArray (NativeHandle handle)
- : base (handle, false)
- {
- }
-#endif
-
[Preserve (Conditional = true)]
internal CFArray (NativeHandle handle, bool owns)
: base (handle, owns)
diff --git a/src/CoreFoundation/CFBoolean.cs b/src/CoreFoundation/CFBoolean.cs
index 33c7ba30037c..508be6d3387f 100644
--- a/src/CoreFoundation/CFBoolean.cs
+++ b/src/CoreFoundation/CFBoolean.cs
@@ -35,19 +35,13 @@
using ObjCRuntime;
using Foundation;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
// CFNumber.h
partial class CFBoolean : NativeObject {
[Preserve (Conditional = true)]
diff --git a/src/CoreFoundation/CFBundle.cs b/src/CoreFoundation/CFBundle.cs
index e5c24d992e45..61029f529c88 100644
--- a/src/CoreFoundation/CFBundle.cs
+++ b/src/CoreFoundation/CFBundle.cs
@@ -11,10 +11,6 @@
using CoreFoundation;
using Foundation;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
public partial class CFBundle : NativeObject {
@@ -28,12 +24,10 @@ public enum PackageType {
Bundle
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public struct PackageInfo {
public PackageInfo (CFBundle.PackageType type, string creator)
{
@@ -650,21 +644,13 @@ public CFBundle.Architecture []? Architectures {
}
#if MONOMAC
-#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
-#else
- [NoMacCatalyst]
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static byte CFBundleIsExecutableLoadable (IntPtr bundle);
-#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
-#else
- [NoMacCatalyst]
-#endif
public static bool IsExecutableLoadable (CFBundle bundle)
{
if (bundle is null)
@@ -673,21 +659,13 @@ public static bool IsExecutableLoadable (CFBundle bundle)
return CFBundleIsExecutableLoadable (bundle.GetCheckedHandle ()) != 0;
}
-#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
-#else
- [NoMacCatalyst]
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static byte CFBundleIsExecutableLoadableForURL (IntPtr bundle);
-#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
-#else
- [NoMacCatalyst]
-#endif
public static bool IsExecutableLoadable (NSUrl url)
{
if (url is null)
@@ -696,21 +674,13 @@ public static bool IsExecutableLoadable (NSUrl url)
return CFBundleIsExecutableLoadableForURL (url.Handle) != 0;
}
-#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
-#else
- [NoMacCatalyst]
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static byte CFBundleIsArchitectureLoadable (/*cpu_type_t => integer_t => int*/ Architecture architecture);
-#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
-#else
- [NoMacCatalyst]
-#endif
public static bool IsArchitectureLoadable (Architecture architecture) => CFBundleIsArchitectureLoadable (architecture) != 0;
#endif
diff --git a/src/CoreFoundation/CFData.cs b/src/CoreFoundation/CFData.cs
index bb704faeced3..9526118b7229 100644
--- a/src/CoreFoundation/CFData.cs
+++ b/src/CoreFoundation/CFData.cs
@@ -33,10 +33,6 @@
using Foundation;
using ObjCRuntime;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
class CFData : NativeObject {
diff --git a/src/CoreFoundation/CFDictionary.cs b/src/CoreFoundation/CFDictionary.cs
index 029aa634b124..5fba903d734e 100644
--- a/src/CoreFoundation/CFDictionary.cs
+++ b/src/CoreFoundation/CFDictionary.cs
@@ -35,10 +35,6 @@
using Foundation;
using ObjCRuntime;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
class CFDictionary : NativeObject {
diff --git a/src/CoreFoundation/CFException.cs b/src/CoreFoundation/CFException.cs
index 5ad5767cbd47..4e770a0ac707 100644
--- a/src/CoreFoundation/CFException.cs
+++ b/src/CoreFoundation/CFException.cs
@@ -37,12 +37,10 @@
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public static class CFErrorDomain {
/// To be added.
@@ -68,12 +66,10 @@ static CFErrorDomain ()
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public static class CFExceptionDataKey {
/// To be added.
@@ -103,12 +99,10 @@ static CFExceptionDataKey ()
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFException : Exception {
public CFException (string? description, NSString? domain, nint code, string? failureReason, string? recoverySuggestion)
diff --git a/src/CoreFoundation/CFMachPort.cs b/src/CoreFoundation/CFMachPort.cs
index d9beadad102f..333126f30113 100644
--- a/src/CoreFoundation/CFMachPort.cs
+++ b/src/CoreFoundation/CFMachPort.cs
@@ -16,10 +16,6 @@
using Foundation;
using ObjCRuntime;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
#if false
@@ -42,18 +38,8 @@ internal public struct CFMachPortContext {
public class CFMachPort : NativeObject {
delegate void CFMachPortCallBack (IntPtr cfmachport, IntPtr msg, nint len, IntPtr context);
-#if !NET
- public CFMachPort (NativeHandle handle) : base (handle, false)
- {
- }
-#endif
-
[Preserve (Conditional = true)]
-#if NET
internal CFMachPort (NativeHandle handle, bool owns)
-#else
- public CFMachPort (NativeHandle handle, bool owns)
-#endif
: base (handle, owns)
{
}
diff --git a/src/CoreFoundation/CFMessagePort.cs b/src/CoreFoundation/CFMessagePort.cs
index 1e435ac403b8..b1a57fffae2c 100644
--- a/src/CoreFoundation/CFMessagePort.cs
+++ b/src/CoreFoundation/CFMessagePort.cs
@@ -19,10 +19,6 @@
using dispatch_queue_t = System.IntPtr;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
// untyped enum from CFMessagePort.h
@@ -51,54 +47,31 @@ internal class CFMessagePortContext {
public Func? CopyDescription { get; set; }
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFMessagePort : NativeObject {
// CFMessagePortContext
[StructLayout (LayoutKind.Sequential)]
-#if NET
- unsafe
-#endif
- struct ContextProxy {
+ unsafe struct ContextProxy {
/* CFIndex */
nint version; // must be 0
public /* void * */ IntPtr info;
-#if NET
public delegate* unmanaged retain;
public delegate* unmanaged release;
public delegate* unmanaged copyDescription;
-#else
- public /* CFAllocatorRetainCallBack*/ IntPtr retain;
- public /* CFAllocatorReleaseCallBack*/ IntPtr release;
- public /* CFAllocatorCopyDescriptionCallBack*/ IntPtr copyDescription;
-#endif
}
public delegate NSData CFMessagePortCallBack (int type, NSData data);
-#if !NET
- delegate /* CFDataRef */ IntPtr CFMessagePortCallBackProxy (/* CFMessagePortRef */ IntPtr messagePort, /* SInt32 */ int type, /* CFDataRef */ IntPtr data, /* void* */ IntPtr info);
-
- delegate void CFMessagePortInvalidationCallBackProxy (/* CFMessagePortRef */ IntPtr messagePort, /* void * */ IntPtr info);
-#endif
-
static Dictionary outputHandles = new Dictionary (Runtime.IntPtrEqualityComparer);
static Dictionary invalidationHandles = new Dictionary (Runtime.IntPtrEqualityComparer);
static Dictionary messagePortContexts = new Dictionary (Runtime.IntPtrEqualityComparer);
-#if !NET
- static CFMessagePortCallBackProxy messageOutputCallback = new CFMessagePortCallBackProxy (MessagePortCallback);
-
- static CFMessagePortInvalidationCallBackProxy messageInvalidationCallback = new CFMessagePortInvalidationCallBackProxy (MessagePortInvalidationCallback);
-#endif
-
IntPtr contextHandle;
/// Returns a Boolean value that indicates whether a current instance of CFMessagePort object represents a remote port.
@@ -172,13 +145,9 @@ public Action? InvalidationCallback {
invalidationHandles.Add (GetCheckedHandle (), value);
}
-#if NET
unsafe {
CFMessagePortSetInvalidationCallBack (Handle, &MessagePortInvalidationCallback);
}
-#else
- CFMessagePortSetInvalidationCallBack (Handle, messageInvalidationCallback);
-#endif
}
}
@@ -211,13 +180,8 @@ protected override void Dispose (bool disposing)
base.Dispose (disposing);
}
-#if NET
[DllImport (Constants.CoreFoundationLibrary)]
static unsafe extern /* CFMessagePortRef */ IntPtr CFMessagePortCreateLocal (/* CFAllocatorRef */ IntPtr allocator, /* CFStringRef */ IntPtr name, delegate* unmanaged callout, /* CFMessagePortContext */ ContextProxy* context, byte* shouldFreeInfo);
-#else
- [DllImport (Constants.CoreFoundationLibrary)]
- static unsafe extern /* CFMessagePortRef */ IntPtr CFMessagePortCreateLocal (/* CFAllocatorRef */ IntPtr allocator, /* CFStringRef */ IntPtr name, CFMessagePortCallBackProxy callout, /* CFMessagePortContext */ ContextProxy* context, byte* shouldFreeInfo);
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
static extern /* CFMessagePortRef */ IntPtr CFMessagePortCreateRemote (/* CFAllocatorRef */ IntPtr allocator, /* CFStringRef */ IntPtr name);
@@ -249,13 +213,8 @@ protected override void Dispose (bool disposing)
[DllImport (Constants.CoreFoundationLibrary)]
static extern void CFMessagePortSetDispatchQueue (/* CFMessagePortRef */ IntPtr ms, dispatch_queue_t queue);
-#if NET
[DllImport (Constants.CoreFoundationLibrary)]
static unsafe extern void CFMessagePortSetInvalidationCallBack (/* CFMessagePortRef */ IntPtr ms, delegate* unmanaged callout);
-#else
- [DllImport (Constants.CoreFoundationLibrary)]
- static extern void CFMessagePortSetInvalidationCallBack (/* CFMessagePortRef */ IntPtr ms, CFMessagePortInvalidationCallBackProxy callout);
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
static extern IntPtr CFMessagePortGetInvalidationCallBack (/* CFMessagePortRef */ IntPtr ms);
@@ -280,7 +239,6 @@ protected override void Dispose (bool disposing)
var shortHandle = GCHandle.Alloc (contextProxy);
if (context is not null) {
-#if NET
unsafe {
if (context.Retain is not null)
contextProxy.retain = &RetainProxy;
@@ -289,14 +247,6 @@ protected override void Dispose (bool disposing)
if (context.CopyDescription is not null)
contextProxy.copyDescription = &CopyDescriptionProxy;
}
-#else
- if (context.Retain is not null)
- contextProxy.retain = Marshal.GetFunctionPointerForDelegate (RetainProxyDelegate);
- if (context.Release is not null)
- contextProxy.release = Marshal.GetFunctionPointerForDelegate (ReleaseProxyDelegate);
- if (context.CopyDescription is not null)
- contextProxy.copyDescription = Marshal.GetFunctionPointerForDelegate (CopyDescriptionProxyDelegate);
-#endif
contextProxy.info = (IntPtr) shortHandle;
lock (messagePortContexts)
messagePortContexts.Add (contextProxy.info, context);
@@ -305,11 +255,7 @@ protected override void Dispose (bool disposing)
try {
IntPtr portHandle;
unsafe {
-#if NET
portHandle = CFMessagePortCreateLocal (allocator.GetHandle (), n, &MessagePortCallback, &contextProxy, &shouldFreeInfo);
-#else
- portHandle = CFMessagePortCreateLocal (allocator.GetHandle (), n, messageOutputCallback, &contextProxy, &shouldFreeInfo);
-#endif
}
// TODO handle should free info
@@ -345,12 +291,7 @@ protected override void Dispose (bool disposing)
//
// Proxy callbacks
//
-#if NET
[UnmanagedCallersOnly]
-#else
- static Func RetainProxyDelegate = RetainProxy;
- [MonoPInvokeCallback (typeof (Func))]
-#endif
static IntPtr RetainProxy (IntPtr info)
{
INativeObject? result = null;
@@ -366,12 +307,7 @@ static IntPtr RetainProxy (IntPtr info)
return result.GetHandle ();
}
-#if NET
[UnmanagedCallersOnly]
-#else
- static Action ReleaseProxyDelegate = ReleaseProxy;
- [MonoPInvokeCallback (typeof (Action))]
-#endif
static void ReleaseProxy (IntPtr info)
{
CFMessagePortContext? context;
@@ -383,12 +319,7 @@ static void ReleaseProxy (IntPtr info)
context.Release ();
}
-#if NET
[UnmanagedCallersOnly]
-#else
- static Func CopyDescriptionProxyDelegate = CopyDescriptionProxy;
- [MonoPInvokeCallback (typeof (Func))]
-#endif
static IntPtr CopyDescriptionProxy (IntPtr info)
{
NSString? result = null;
@@ -403,11 +334,7 @@ static IntPtr CopyDescriptionProxy (IntPtr info)
return result.GetHandle ();
}
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (CFMessagePortCallBackProxy))]
-#endif
static IntPtr MessagePortCallback (IntPtr local, int msgid, IntPtr data, IntPtr info)
{
CFMessagePortCallBack callback;
@@ -426,11 +353,7 @@ static IntPtr MessagePortCallback (IntPtr local, int msgid, IntPtr data, IntPtr
}
}
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (CFMessagePortInvalidationCallBackProxy))]
-#endif
static void MessagePortInvalidationCallback (IntPtr messagePort, IntPtr info)
{
Action? callback;
diff --git a/src/CoreFoundation/CFMutableString.cs b/src/CoreFoundation/CFMutableString.cs
index 6eab6eef46ad..6414bf1d9274 100644
--- a/src/CoreFoundation/CFMutableString.cs
+++ b/src/CoreFoundation/CFMutableString.cs
@@ -12,33 +12,15 @@
using Foundation;
using ObjCRuntime;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFMutableString : CFString {
-
-#if !NET
- protected CFMutableString (NativeHandle handle)
- : this (handle, false)
- {
- }
-#endif
-
[Preserve (Conditional = true)]
-#if NET
internal CFMutableString (NativeHandle handle, bool owns)
-#else
- protected CFMutableString (NativeHandle handle, bool owns)
-#endif
: base (handle, owns)
{
}
diff --git a/src/CoreFoundation/CFNotificationCenter.cs b/src/CoreFoundation/CFNotificationCenter.cs
index 24c1664ddb5b..047c5c7c8e42 100644
--- a/src/CoreFoundation/CFNotificationCenter.cs
+++ b/src/CoreFoundation/CFNotificationCenter.cs
@@ -21,10 +21,6 @@
using CoreFoundation;
using System.Collections.Generic;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
[Native] // CFIndex
@@ -157,7 +153,6 @@ public CFNotificationObserverToken AddObserver (string name, INativeObject objec
lock (listeners) {
if (!listeners.TryGetValue (name, out listenersForName)) {
listenersForName = new List (1);
-#if NET
unsafe {
CFNotificationCenterAddObserver (center: Handle,
observer: Handle,
@@ -166,14 +161,6 @@ public CFNotificationObserverToken AddObserver (string name, INativeObject objec
obj: token.observedObject,
suspensionBehavior: (IntPtr) suspensionBehavior);
}
-#else
- CFNotificationCenterAddObserver (center: Handle,
- observer: Handle,
- callback: NotificationCallback,
- name: strHandle,
- obj: token.observedObject,
- suspensionBehavior: (IntPtr) suspensionBehavior);
-#endif
} else
listenersForName = new List (listenersForName);
listenersForName.Add (token);
@@ -205,15 +192,7 @@ void notification (string? name, NSDictionary? userInfo)
}
}
-#if !NET
- delegate void CFNotificationCallback (CFNotificationCenterRef center, IntPtr observer, IntPtr name, IntPtr obj, IntPtr userInfo);
-#endif
-
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (CFNotificationCallback))]
-#endif
static void NotificationCallback (CFNotificationCenterRef centerPtr, IntPtr observer, IntPtr name, IntPtr obj, IntPtr userInfo)
{
CFNotificationCenter center;
@@ -293,17 +272,10 @@ public void RemoveEveryObserver ()
}
-#if NET
[DllImport (Constants.CoreFoundationLibrary)]
static extern unsafe void CFNotificationCenterAddObserver (CFNotificationCenterRef center, IntPtr observer,
delegate* unmanaged callback, IntPtr name, IntPtr obj,
/* CFNotificationSuspensionBehavior */ IntPtr suspensionBehavior);
-#else
- [DllImport (Constants.CoreFoundationLibrary)]
- static extern unsafe void CFNotificationCenterAddObserver (CFNotificationCenterRef center, IntPtr observer,
- CFNotificationCallback callback, IntPtr name, IntPtr obj,
- /* CFNotificationSuspensionBehavior */ IntPtr suspensionBehavior);
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
static extern unsafe void CFNotificationCenterPostNotificationWithOptions (CFNotificationCenterRef center, IntPtr name, IntPtr obj, IntPtr userInfo, int options);
diff --git a/src/CoreFoundation/CFPreferences.cs b/src/CoreFoundation/CFPreferences.cs
index 8d4cf0b925e3..853eed3d030a 100644
--- a/src/CoreFoundation/CFPreferences.cs
+++ b/src/CoreFoundation/CFPreferences.cs
@@ -20,12 +20,10 @@
using System.Runtime.Versioning;
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public static class CFPreferences {
[DllImport (Constants.CoreFoundationLibrary)]
static extern IntPtr CFPreferencesCopyAppValue (IntPtr key, IntPtr applicationId);
diff --git a/src/CoreFoundation/CFPropertyList.cs b/src/CoreFoundation/CFPropertyList.cs
index 9546166a7671..bc8f83bec9ad 100644
--- a/src/CoreFoundation/CFPropertyList.cs
+++ b/src/CoreFoundation/CFPropertyList.cs
@@ -15,17 +15,11 @@
using ObjCRuntime;
using Foundation;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFPropertyList : NativeObject {
static nint CFDataTypeID = CFData.GetTypeID ();
static nint CFStringTypeID = CFString.GetTypeID ();
@@ -44,21 +38,11 @@ public class CFPropertyList : NativeObject {
static nint CFNumberTypeID = CFNumberGetTypeID ();
[Preserve (Conditional = true)]
-#if NET
internal CFPropertyList (NativeHandle handle, bool owns)
-#else
- public CFPropertyList (NativeHandle handle, bool owns)
-#endif
: base (handle, owns)
{
}
-#if !NET
- public CFPropertyList (NativeHandle handle) : this (handle, false)
- {
- }
-#endif
-
[DllImport (Constants.CoreFoundationLibrary)]
unsafe static extern IntPtr CFPropertyListCreateWithData (IntPtr allocator, IntPtr dataRef, nuint options, nint* format, /* CFError * */ IntPtr* error);
diff --git a/src/CoreFoundation/CFReadStream.cs b/src/CoreFoundation/CFReadStream.cs
index d3da6ad17c73..bbb135f288f0 100644
--- a/src/CoreFoundation/CFReadStream.cs
+++ b/src/CoreFoundation/CFReadStream.cs
@@ -37,34 +37,17 @@
using Foundation;
using ObjCRuntime;
-#if NET
using CFIndex = System.IntPtr;
-#else
-using CFIndex = System.nint;
-#endif
-
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
// CFStream.h
public class CFReadStream : CFStream {
-#if !NET
- public CFReadStream (NativeHandle handle)
- : base (handle, true)
- {
- }
-#endif
-
[Preserve (Conditional = true)]
internal CFReadStream (NativeHandle handle, bool owns)
: base (handle, owns)
@@ -139,37 +122,23 @@ protected override void UnscheduleFromRunLoop (CFRunLoop loop, NSString? mode)
}
[DllImport (Constants.CoreFoundationLibrary)]
-#if NET8_0_OR_GREATER
unsafe static extern byte CFReadStreamSetClient (/* CFReadStreamRef */ IntPtr stream, /* CFOptionFlags */ nint streamEvents,
/* CFReadStreamClientCallBack */ delegate* unmanaged clientCB, /* CFStreamClientContext* */ IntPtr clientContext);
-#else
- [return: MarshalAs (UnmanagedType.I1)]
- static extern bool CFReadStreamSetClient (/* CFReadStreamRef */ IntPtr stream, /* CFOptionFlags */ nint streamEvents,
- /* CFReadStreamClientCallBack */ CFStreamCallback? clientCB, /* CFStreamClientContext* */ IntPtr clientContext);
-#endif
#if !XAMCORE_5_0
-#if NET8_0_OR_GREATER
[Obsolete ("Use the other overload.")]
[EditorBrowsable (EditorBrowsableState.Never)]
-#endif
protected override bool DoSetClient (CFStreamCallback? callback, CFIndex eventTypes,
IntPtr context)
{
-#if NET8_0_OR_GREATER
throw new InvalidOperationException ($"Use the other overload.");
-#else
- return CFReadStreamSetClient (Handle, (nint) eventTypes, callback, context);
-#endif
}
#endif // !XAMCORE_5_0
-#if NET8_0_OR_GREATER
unsafe protected override byte DoSetClient (delegate* unmanaged callback, CFIndex eventTypes, IntPtr context)
{
return CFReadStreamSetClient (Handle, (nint) eventTypes, callback, context);
}
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static /* CFIndex */ nint CFReadStreamRead (/* CFReadStreamRef */ IntPtr handle, /* UInt8* */ IntPtr buffer, /* CFIndex */ nint count);
diff --git a/src/CoreFoundation/CFRunLoop.cs b/src/CoreFoundation/CFRunLoop.cs
index a27e03bd433e..54b41fc3b3e9 100644
--- a/src/CoreFoundation/CFRunLoop.cs
+++ b/src/CoreFoundation/CFRunLoop.cs
@@ -37,15 +37,7 @@
using Foundation;
using System.Runtime.Versioning;
-#if NET
using CFIndex = System.IntPtr;
-#else
-using CFIndex = System.nint;
-#endif
-
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
#nullable enable
@@ -65,11 +57,7 @@ public enum CFRunLoopExitReason : int {
// CFRunLoop.h
[StructLayout (LayoutKind.Sequential)]
-#if NET
internal unsafe struct CFRunLoopSourceContext {
-#else
- internal struct CFRunLoopSourceContext {
-#endif
public CFIndex Version;
public IntPtr Info;
public IntPtr Retain;
@@ -77,37 +65,18 @@ internal struct CFRunLoopSourceContext {
public IntPtr CopyDescription;
public IntPtr Equal;
public IntPtr Hash;
-#if NET
public delegate* unmanaged Schedule;
public delegate* unmanaged Cancel;
public delegate* unmanaged Perform;
-#else
- public IntPtr Schedule;
- public IntPtr Cancel;
- public IntPtr Perform;
-#endif
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFRunLoopSource : NativeObject {
-#if !NET
- public CFRunLoopSource (NativeHandle handle)
- : base (handle, false)
- {
- }
-#endif
-
[Preserve (Conditional = true)]
-#if NET
internal CFRunLoopSource (NativeHandle handle, bool owns)
-#else
- public CFRunLoopSource (NativeHandle handle, bool owns)
-#endif
: base (handle, owns)
{
}
@@ -154,41 +123,27 @@ public void Signal ()
}
#if !COREBUILD
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public abstract class CFRunLoopSourceCustom : CFRunLoopSource {
GCHandle gch;
[DllImport (Constants.CoreFoundationLibrary)]
unsafe extern static /* CFRunLoopSourceRef */ IntPtr CFRunLoopSourceCreate (/* CFAllocatorRef */ IntPtr allocator, /* CFIndex */ nint order, /* CFRunLoopSourceContext* */ CFRunLoopSourceContext* context);
-#if !NET
- static ScheduleCallback ScheduleDelegate = (ScheduleCallback) Schedule;
- static CancelCallback CancelDelegate = (CancelCallback) Cancel;
- static PerformCallback PerformDelegate = (PerformCallback) Perform;
-#endif
-
protected CFRunLoopSourceCustom ()
: base (IntPtr.Zero, true)
{
gch = GCHandle.Alloc (this);
var ctx = new CFRunLoopSourceContext ();
ctx.Info = GCHandle.ToIntPtr (gch);
-#if NET
unsafe {
ctx.Schedule = &Schedule;
ctx.Cancel = &Cancel;
ctx.Perform = &Perform;
}
-#else
- ctx.Schedule = Marshal.GetFunctionPointerForDelegate (ScheduleDelegate);
- ctx.Cancel = Marshal.GetFunctionPointerForDelegate (CancelDelegate);
- ctx.Perform = Marshal.GetFunctionPointerForDelegate (PerformDelegate);
-#endif
IntPtr handle;
unsafe {
@@ -197,15 +152,7 @@ protected CFRunLoopSourceCustom ()
InitializeHandle (handle);
}
-#if !NET
- delegate void ScheduleCallback (IntPtr info, IntPtr runLoop, IntPtr mode);
-#endif
-
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (ScheduleCallback))]
-#endif
static void Schedule (IntPtr info, IntPtr runLoop, IntPtr mode)
{
var source = GCHandle.FromIntPtr (info).Target as CFRunLoopSourceCustom;
@@ -220,15 +167,7 @@ static void Schedule (IntPtr info, IntPtr runLoop, IntPtr mode)
protected abstract void OnSchedule (CFRunLoop loop, NSString mode);
-#if !NET
- delegate void CancelCallback (IntPtr info, IntPtr runLoop, IntPtr mode);
-#endif
-
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (CancelCallback))]
-#endif
static void Cancel (IntPtr info, IntPtr runLoop, IntPtr mode)
{
var source = GCHandle.FromIntPtr (info).Target as CFRunLoopSourceCustom;
@@ -243,15 +182,7 @@ static void Cancel (IntPtr info, IntPtr runLoop, IntPtr mode)
protected abstract void OnCancel (CFRunLoop loop, NSString mode);
-#if !NET
- delegate void PerformCallback (IntPtr info);
-#endif
-
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (PerformCallback))]
-#endif
static void Perform (IntPtr info)
{
var source = GCHandle.FromIntPtr (info).Target as CFRunLoopSourceCustom;
@@ -429,43 +360,6 @@ public string? CurrentMode {
return CFString.FromHandle (CFRunLoopCopyCurrentMode (GetCheckedHandle ()), releaseHandle: true);
}
}
-
-#if !NET
- public static bool operator == (CFRunLoop? a, CFRunLoop? b)
- {
- if (a is null)
- return b is null;
- else if (b is null)
- return false;
-
- return a.Handle == b.Handle;
- }
-
- public static bool operator != (CFRunLoop? a, CFRunLoop? b)
- {
- if (a is null)
- return b is not null;
- else if (b is null)
- return true;
- return a.Handle != b.Handle;
- }
-
- // For the .net profile `DisposableObject` implements both
- // `Equals` and `GetHashCode` based on the Handle property.
- public override int GetHashCode ()
- {
- return Handle.GetHashCode ();
- }
-
- public override bool Equals (object? other)
- {
- var cfother = other as CFRunLoop;
- if (cfother is null)
- return false;
-
- return cfother.Handle == Handle;
- }
-#endif
#endif // !COREBUILD
}
}
diff --git a/src/CoreFoundation/CFSocket.cs b/src/CoreFoundation/CFSocket.cs
index 0e971fe81be7..e7df9375c2e1 100644
--- a/src/CoreFoundation/CFSocket.cs
+++ b/src/CoreFoundation/CFSocket.cs
@@ -40,10 +40,6 @@
using Foundation;
using ObjCRuntime;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
[Flags]
@@ -92,12 +88,10 @@ public enum CFSocketFlags {
CloseOnInvalidate = 128
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public struct CFSocketNativeHandle {
// typedef int CFSocketNativeHandle
internal readonly int handle;
@@ -113,12 +107,10 @@ public override string ToString ()
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFSocketException : Exception {
/// To be added.
/// To be added.
@@ -256,39 +248,20 @@ static byte [] CreateData (IPEndPoint endpoint)
struct CFSocketContext {
nint Version; // CFIndex
public /* void*/ IntPtr Info;
-#if NET
unsafe delegate* unmanaged Retain;
unsafe delegate* unmanaged Release;
-#else
- IntPtr Retain;
- IntPtr Release;
-#endif
IntPtr CopyDescription;
public CFSocketContext (IntPtr info) : this ()
{
Info = info;
-#if NET
unsafe {
Retain = &OnContextRetain;
Release = &OnContextRelease;
}
-#else
- Retain = Marshal.GetFunctionPointerForDelegate (retainCallback);
- Release = Marshal.GetFunctionPointerForDelegate (releaseCallback);
-#endif
}
-#if !NET
- delegate IntPtr RetainCallback (IntPtr ptr);
- static readonly RetainCallback retainCallback = OnContextRetain;
-#endif
-
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (RetainCallback))]
-#endif
static IntPtr OnContextRetain (IntPtr ptr)
{
var gch = GCHandle.FromIntPtr (ptr);
@@ -297,16 +270,7 @@ static IntPtr OnContextRetain (IntPtr ptr)
return ptr;
}
-#if !NET
- delegate void ReleaseCallback (IntPtr ptr);
- static readonly ReleaseCallback releaseCallback = OnContextRelease;
-#endif
-
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (ReleaseCallback))]
-#endif
static void OnContextRelease (IntPtr ptr)
{
var gch = GCHandle.FromIntPtr (ptr);
@@ -315,12 +279,10 @@ static void OnContextRelease (IntPtr ptr)
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFSocket : CFType {
int contextRetainCount;
@@ -344,15 +306,7 @@ protected override void Dispose (bool disposing)
base.Dispose (disposing);
}
-#if !NET
- delegate void CFSocketCallBack (IntPtr s, nuint type, IntPtr address, IntPtr data, IntPtr info);
-#endif
-
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (CFSocketCallBack))]
-#endif
static void OnCallback (IntPtr s, nuint type, IntPtr address, IntPtr data, IntPtr info)
{
var socket = GCHandle.FromIntPtr (info).Target as CFSocket;
@@ -390,29 +344,15 @@ static void OnCallback (IntPtr s, nuint type, IntPtr address, IntPtr data, IntPt
}
}
-#if NET
[DllImport (Constants.CoreFoundationLibrary)]
unsafe extern static IntPtr CFSocketCreate (IntPtr allocator, int /*SInt32*/ family, int /*SInt32*/ type, int /*SInt32*/ proto,
nuint /*CFOptionFlags*/ callBackTypes,
delegate* unmanaged callout, CFSocketContext* ctx);
-#else
- [DllImport (Constants.CoreFoundationLibrary)]
- unsafe extern static IntPtr CFSocketCreate (IntPtr allocator, int /*SInt32*/ family, int /*SInt32*/ type, int /*SInt32*/ proto,
- nuint /*CFOptionFlags*/ callBackTypes,
- CFSocketCallBack callout, CFSocketContext* ctx);
-#endif
-#if NET
[DllImport (Constants.CoreFoundationLibrary)]
unsafe extern static IntPtr CFSocketCreateWithNative (IntPtr allocator, CFSocketNativeHandle sock,
nuint /*CFOptionFlags*/ callBackTypes,
delegate* unmanaged callout, CFSocketContext* ctx);
-#else
- [DllImport (Constants.CoreFoundationLibrary)]
- unsafe extern static IntPtr CFSocketCreateWithNative (IntPtr allocator, CFSocketNativeHandle sock,
- nuint /*CFOptionFlags*/ callBackTypes,
- CFSocketCallBack callout, CFSocketContext* ctx);
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static IntPtr CFSocketCreateRunLoopSource (IntPtr allocator, IntPtr socket, nint order);
@@ -440,34 +380,20 @@ public CFSocket (AddressFamily family, SocketType type, ProtocolType proto, CFRu
CFSocket (int family, int type, int proto, CFRunLoop loop)
{
unsafe {
-#if NET
Initialize (
loop,
(CFSocketContext* ctx) => CFSocketCreate (IntPtr.Zero, family, type, proto, (nuint) (ulong) defaultCallbackTypes, &OnCallback, ctx)
);
-#else
- Initialize (
- loop,
- (CFSocketContext* ctx) => CFSocketCreate (IntPtr.Zero, family, type, proto, (nuint) (ulong) defaultCallbackTypes, OnCallback, ctx)
- );
-#endif
}
}
CFSocket (CFSocketNativeHandle sock)
{
unsafe {
-#if NET
Initialize (
CFRunLoop.Current,
(CFSocketContext* ctx) => CFSocketCreateWithNative (IntPtr.Zero, sock, (nuint) (ulong) defaultCallbackTypes, &OnCallback, ctx)
);
-#else
- Initialize (
- CFRunLoop.Current,
- (CFSocketContext* ctx) => CFSocketCreateWithNative (IntPtr.Zero, sock, (nuint) (ulong) defaultCallbackTypes, OnCallback, ctx)
- );
-#endif
}
}
@@ -478,11 +404,7 @@ internal CFSocket (CFSocketSignature sig, double timeout)
CFRunLoop.Current,
(CFSocketContext* ctx) => {
CFSocketSignature localSig = sig;
-#if NET
return CFSocketCreateConnectedToSocketSignature (IntPtr.Zero, &localSig, (nuint) (ulong) defaultCallbackTypes, &OnCallback, ctx, timeout);
-#else
- return CFSocketCreateConnectedToSocketSignature (IntPtr.Zero, &localSig, (nuint) (ulong) defaultCallbackTypes, OnCallback, ctx, timeout);
-#endif
}
);
}
@@ -512,19 +434,11 @@ void Initialize (CFRunLoop runLoop, CreateSocket createSocket)
}
}
-#if NET
[DllImport (Constants.CoreFoundationLibrary)]
unsafe extern static IntPtr CFSocketCreateConnectedToSocketSignature (IntPtr allocator, CFSocketSignature* signature,
nuint /*CFOptionFlags*/ callBackTypes,
delegate* unmanaged callout,
CFSocketContext* context, double timeout);
-#else
- [DllImport (Constants.CoreFoundationLibrary)]
- unsafe extern static IntPtr CFSocketCreateConnectedToSocketSignature (IntPtr allocator, CFSocketSignature* signature,
- nuint /*CFOptionFlags*/ callBackTypes,
- CFSocketCallBack callout,
- CFSocketContext* context, double timeout);
-#endif
public static CFSocket CreateConnectedToSocketSignature (AddressFamily family, SocketType type,
ProtocolType proto, IPEndPoint endpoint,
@@ -630,12 +544,10 @@ public void SendData (byte [] data, double timeout)
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFSocketAcceptEventArgs : EventArgs {
internal CFSocketNativeHandle SocketHandle {
get;
@@ -664,12 +576,10 @@ public override string ToString ()
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFSocketConnectEventArgs : EventArgs {
public CFSocketError Result {
get;
@@ -687,12 +597,10 @@ public override string ToString ()
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFSocketDataEventArgs : EventArgs {
public IPEndPoint RemoteEndPoint {
get;
@@ -711,22 +619,18 @@ public CFSocketDataEventArgs (IPEndPoint remote, byte [] data)
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFSocketReadEventArgs : EventArgs {
public CFSocketReadEventArgs () { }
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFSocketWriteEventArgs : EventArgs {
public CFSocketWriteEventArgs () { }
}
diff --git a/src/CoreFoundation/CFStream.cs b/src/CoreFoundation/CFStream.cs
index 9c4327bc5aa8..27210c54502e 100644
--- a/src/CoreFoundation/CFStream.cs
+++ b/src/CoreFoundation/CFStream.cs
@@ -37,23 +37,11 @@
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
-#if NET
using CFNetwork;
-#else
-using CoreServices;
-#endif
using ObjCRuntime;
using Foundation;
-#if NET
using CFIndex = System.IntPtr;
-#else
-using CFIndex = System.nint;
-#endif
-
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
namespace CoreFoundation {
@@ -74,12 +62,10 @@ public enum CFStreamEventType : ulong {
}
// NSStream.h
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
[StructLayout (LayoutKind.Sequential)]
public struct CFStreamClientContext {
/// The version of this structure. Currently the only valid value is 0.
@@ -183,12 +169,10 @@ public enum CFStreamStatus : long {
Error
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public abstract class CFStream : CFType {
GCHandle gch;
CFRunLoop? loop;
@@ -197,7 +181,6 @@ public abstract class CFStream : CFType {
#region Stream Constructors
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -206,17 +189,10 @@ public abstract class CFStream : CFType {
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
internal unsafe extern static void CFStreamCreatePairWithSocket (/* CFAllocatorRef */ IntPtr allocator, CFSocketNativeHandle sock,
/* CFReadStreamRef* */ IntPtr* readStream, /* CFWriteStreamRef* */ IntPtr* writeStream);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -225,12 +201,6 @@ internal unsafe extern static void CFStreamCreatePairWithSocket (/* CFAllocatorR
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
public static void CreatePairWithSocket (CFSocket socket, out CFReadStream readStream,
out CFWriteStream writeStream)
{
@@ -245,7 +215,6 @@ public static void CreatePairWithSocket (CFSocket socket, out CFReadStream readS
writeStream = new CFWriteStream (write, true);
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -254,18 +223,11 @@ public static void CreatePairWithSocket (CFSocket socket, out CFReadStream readS
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
internal unsafe extern static void CFStreamCreatePairWithPeerSocketSignature (/* CFAllocatorRef */ IntPtr allocator,
/* CFSocketSignature* */ CFSocketSignature* sig,
/* CFReadStreamRef* */ IntPtr* readStream, /* CFWriteStreamRef* */ IntPtr* writeStream);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -274,12 +236,6 @@ internal unsafe extern static void CFStreamCreatePairWithPeerSocketSignature (/*
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
public static void CreatePairWithPeerSocketSignature (AddressFamily family, SocketType type,
ProtocolType proto, IPEndPoint endpoint,
out CFReadStream readStream,
@@ -297,7 +253,6 @@ public static void CreatePairWithPeerSocketSignature (AddressFamily family, Sock
}
// CFSocketStream.h in CFNetwork.framework (not CoreFoundation)
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -306,12 +261,6 @@ public static void CreatePairWithPeerSocketSignature (AddressFamily family, Sock
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
[DllImport (Constants.CFNetworkLibrary)]
internal unsafe extern static void CFStreamCreatePairWithSocketToCFHost (
/* CFAllocatorRef __nullable */ IntPtr allocator,
@@ -319,7 +268,6 @@ internal unsafe extern static void CFStreamCreatePairWithSocketToCFHost (
/* CFReadStreamRef __nullable * __nullable */ IntPtr* readStream,
/* CFWriteStreamRef __nullable * __nullable */ IntPtr* writeStream);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -328,12 +276,6 @@ internal unsafe extern static void CFStreamCreatePairWithSocketToCFHost (
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
public static void CreatePairWithSocketToHost (IPEndPoint endpoint,
out CFReadStream? readStream,
out CFWriteStream? writeStream)
@@ -349,7 +291,6 @@ public static void CreatePairWithSocketToHost (IPEndPoint endpoint,
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -358,18 +299,11 @@ public static void CreatePairWithSocketToHost (IPEndPoint endpoint,
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
unsafe extern static void CFStreamCreatePairWithSocketToHost (/* CFAllocatorRef */ IntPtr allocator,
/* CFStringRef */ IntPtr host, /* UInt32 */ int port,
/* CFReadStreamRef* */ IntPtr* readStream, /* CFWriteStreamRef* */ IntPtr* writeStream);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -378,12 +312,6 @@ unsafe extern static void CFStreamCreatePairWithSocketToHost (/* CFAllocatorRef
[ObsoletedOSPlatform ("maccatalyst15.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("macos12.0", Constants.UseNetworkInstead)]
[ObsoletedOSPlatform ("ios15.0", Constants.UseNetworkInstead)]
-#else
- [Deprecated (PlatformName.TvOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.iOS, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacCatalyst, 15, 0, message: Constants.UseNetworkInstead)]
- [Deprecated (PlatformName.MacOSX, 12, 0, message: Constants.UseNetworkInstead)]
-#endif
public static void CreatePairWithSocketToHost (string host, int port,
out CFReadStream? readStream,
out CFWriteStream? writeStream)
@@ -399,7 +327,6 @@ public static void CreatePairWithSocketToHost (string host, int port,
}
}
// CFHTTPStream.h in CFNetwork.framework (not CoreFoundation)
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -408,15 +335,10 @@ public static void CreatePairWithSocketToHost (string host, int port,
[ObsoletedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
-#else
- [Deprecated (PlatformName.iOS, 9, 0)]
- [Deprecated (PlatformName.MacOSX, 10, 11)]
-#endif
[DllImport (Constants.CFNetworkLibrary)]
internal extern static /* CFReadStreamRef __nonnull */ IntPtr CFReadStreamCreateForHTTPRequest (
/* CFAllocatorRef __nullable */ IntPtr alloc, /* CFHTTPMessageRef __nonnull */ IntPtr request);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -425,10 +347,6 @@ public static void CreatePairWithSocketToHost (string host, int port,
[ObsoletedOSPlatform ("ios9.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'NSUrlSession' instead.")]
-#else
- [Deprecated (PlatformName.iOS, 9, 0, message: "Use 'NSUrlSession' instead.")]
- [Deprecated (PlatformName.MacOSX, 10, 11, message: "Use 'NSUrlSession' instead.")]
-#endif
public static CFHTTPStream CreateForHTTPRequest (CFHTTPMessage request)
{
if (request is null)
@@ -439,7 +357,6 @@ public static CFHTTPStream CreateForHTTPRequest (CFHTTPMessage request)
}
// CFHTTPStream.h in CFNetwork.framework (not CoreFoundation)
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -448,16 +365,11 @@ public static CFHTTPStream CreateForHTTPRequest (CFHTTPMessage request)
[ObsoletedOSPlatform ("ios9.0")]
[ObsoletedOSPlatform ("maccatalyst13.0")]
[ObsoletedOSPlatform ("tvos9.0")]
-#else
- [Deprecated (PlatformName.iOS, 9, 0)]
- [Deprecated (PlatformName.MacOSX, 10, 11)]
-#endif
[DllImport (Constants.CFNetworkLibrary)]
internal extern static /* CFReadStreamRef __nonnull */ IntPtr CFReadStreamCreateForStreamedHTTPRequest (
/* CFAllocatorRef __nullable */ IntPtr alloc, /* CFHTTPMessageRef __nonnull */ IntPtr requestHeaders,
/* CFReadStreamRef __nonnull */ IntPtr requestBody);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
@@ -466,10 +378,6 @@ public static CFHTTPStream CreateForHTTPRequest (CFHTTPMessage request)
[ObsoletedOSPlatform ("ios9.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("maccatalyst13.0", "Use 'NSUrlSession' instead.")]
[ObsoletedOSPlatform ("tvos9.0", "Use 'NSUrlSession' instead.")]
-#else
- [Deprecated (PlatformName.iOS, 9, 0, message: "Use 'NSUrlSession' instead.")]
- [Deprecated (PlatformName.MacOSX, 10, 11, message: "Use 'NSUrlSession' instead.")]
-#endif
public static CFHTTPStream CreateForStreamedHTTPRequest (CFHTTPMessage request, CFReadStream body)
{
if (request is null)
@@ -540,13 +448,9 @@ public void Close ()
return;
GetCheckedHandle ();
if (loop is not null) {
-#if NET8_0_OR_GREATER
unsafe {
DoSetClient ((delegate* unmanaged) null, (CFIndex) 0, IntPtr.Zero);
}
-#else
- DoSetClient (null, (CFIndex) 0, IntPtr.Zero);
-#endif
UnscheduleFromRunLoop (loop, loopMode);
loop = null;
loopMode = null;
@@ -593,12 +497,10 @@ internal void SetProperty (NSString name, INativeObject? value)
#region Events
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class StreamEventArgs : EventArgs {
public CFStreamEventType EventType {
get;
@@ -665,21 +567,13 @@ protected virtual void OnClosedEvent (StreamEventArgs args)
protected delegate void CFStreamCallback (IntPtr s, nint type, IntPtr info);
-#if NET8_0_OR_GREATER
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (CFStreamCallback))]
-#endif
static void NativeCallback (IntPtr s, nint type, IntPtr info)
{
var stream = GCHandle.FromIntPtr (info).Target as CFStream;
stream?.OnCallback ((CFStreamEventType) (long) type);
}
-#if !NET8_0_OR_GREATER
- static CFStreamCallback OnCallbackDelegate = NativeCallback;
-#endif
-
protected virtual void OnCallback (CFStreamEventType type)
{
var args = new StreamEventArgs (type);
@@ -726,13 +620,9 @@ public void EnableEvents (CFRunLoop runLoop, NSString runLoopMode)
try {
Marshal.StructureToPtr (ctx, ptr, false);
bool clientSet;
-#if NET8_0_OR_GREATER
unsafe {
clientSet = DoSetClient (&NativeCallback, (CFIndex) (long) args, ptr) != 0;
}
-#else
- clientSet = DoSetClient (OnCallbackDelegate, (CFIndex) (long) args, ptr);
-#endif
if (!clientSet)
throw new InvalidOperationException ("Stream does not support async events.");
} finally {
@@ -743,15 +633,12 @@ public void EnableEvents (CFRunLoop runLoop, NSString runLoopMode)
}
#if !XAMCORE_5_0
-#if NET8_0_OR_GREATER
[Obsolete ("Use the other overload.")]
[EditorBrowsable (EditorBrowsableState.Never)]
-#endif
protected abstract bool DoSetClient (CFStreamCallback? callback, CFIndex eventTypes,
IntPtr context);
#endif
-#if NET8_0_OR_GREATER
#if XAMCORE_5_0
unsafe protected abstract byte DoSetClient (delegate* unmanaged callback, CFIndex eventTypes, IntPtr context);
#else
@@ -760,16 +647,6 @@ unsafe protected virtual byte DoSetClient (delegate* unmanaged CFIndex -> CFURL.h
@@ -50,12 +46,10 @@ public enum CFUrlPathStyle : long {
};
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
// CFURL.h
public class CFUrl : NativeObject {
#if !COREBUILD
@@ -134,21 +128,17 @@ public string? FileSystemPath {
return CFString.FromHandle (CFURLCopyFileSystemPath (hcfurl, 0), true);
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static /* Boolean */ byte CFURLIsFileReferenceURL (/* CFURLRef */IntPtr url);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
-#endif
public bool IsFileReference {
get {
return CFURLIsFileReferenceURL (Handle) != 0;
diff --git a/src/CoreFoundation/CFWriteStream.cs b/src/CoreFoundation/CFWriteStream.cs
index 86d5bd155e7d..292550e2fa0d 100644
--- a/src/CoreFoundation/CFWriteStream.cs
+++ b/src/CoreFoundation/CFWriteStream.cs
@@ -37,24 +37,14 @@
using ObjCRuntime;
using System.Runtime.Versioning;
-#if NET
using CFIndex = System.IntPtr;
-#else
-using CFIndex = System.nint;
-#endif
-
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class CFWriteStream : CFStream {
[Preserve (Conditional = true)]
internal CFWriteStream (NativeHandle handle, bool owns)
@@ -131,37 +121,23 @@ public unsafe int Write (byte [] buffer, nint offset, nint count)
}
[DllImport (Constants.CoreFoundationLibrary)]
-#if NET8_0_OR_GREATER
unsafe static extern /* Boolean */ byte CFWriteStreamSetClient (/* CFWriteStreamRef */ IntPtr stream, /* CFOptionFlags */ nint streamEvents,
/* CFWriteStreamClientCallBack */ delegate* unmanaged clientCB, /* CFStreamClientContext* */ IntPtr clientContext);
-#else
- [return: MarshalAs (UnmanagedType.I1)]
- static extern /* Boolean */ bool CFWriteStreamSetClient (/* CFWriteStreamRef */ IntPtr stream, /* CFOptionFlags */ nint streamEvents,
- /* CFWriteStreamClientCallBack */ CFStreamCallback? clientCB, /* CFStreamClientContext* */ IntPtr clientContext);
-#endif
#if !XAMCORE_5_0
-#if NET8_0_OR_GREATER
[Obsolete ("Use the other overload.")]
[EditorBrowsable (EditorBrowsableState.Never)]
-#endif
protected override bool DoSetClient (CFStreamCallback? callback, CFIndex eventTypes,
IntPtr context)
{
-#if NET8_0_OR_GREATER
throw new InvalidOperationException ($"Use the other overload.");
-#else
- return CFWriteStreamSetClient (Handle, (nint) eventTypes, callback, context);
-#endif
}
#endif // !XAMCORE_5_0
-#if NET8_0_OR_GREATER
unsafe protected override byte DoSetClient (delegate* unmanaged callback, CFIndex eventTypes, IntPtr context)
{
return CFWriteStreamSetClient (Handle, (nint) eventTypes, callback, context);
}
-#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static void CFWriteStreamScheduleWithRunLoop (/* CFWriteStreamRef */ IntPtr stream, /* CFRunLoopRef */ IntPtr runLoop, /* CFStringRef */ IntPtr runLoopMode);
diff --git a/src/CoreFoundation/CGAffineTransformComponents.cs b/src/CoreFoundation/CGAffineTransformComponents.cs
index 46d42b182b83..6a5ff280a23c 100644
--- a/src/CoreFoundation/CGAffineTransformComponents.cs
+++ b/src/CoreFoundation/CGAffineTransformComponents.cs
@@ -9,12 +9,10 @@
using CoreGraphics;
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
[StructLayout (LayoutKind.Sequential)]
// The name prefix suggests CoreGraphics and based on CF_DEFINES_CGAFFINETRANSFORMCOMPONENTS
// it could be defined in CoreGraphics but documented as CoreFoundation type
diff --git a/src/CoreFoundation/Dispatch.cs b/src/CoreFoundation/Dispatch.cs
index 10900d57ba52..9ba4dfbe0ebc 100644
--- a/src/CoreFoundation/Dispatch.cs
+++ b/src/CoreFoundation/Dispatch.cs
@@ -40,10 +40,6 @@
using ObjCRuntime;
using Foundation;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
// The native constants are defined in usr/include/dispatch/queue.h, but since they're
@@ -66,12 +62,10 @@ public enum DispatchQualityOfService : uint {
Unspecified = 0x00,
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public abstract class DispatchObject : NativeObject {
#if !COREBUILD
//
@@ -103,51 +97,6 @@ protected internal override void Release ()
dispatch_release (Handle);
}
-#if !NET
- public static bool operator == (DispatchObject a, DispatchObject b)
- {
- if (a is null)
- return b is null;
- else if (b is null)
- return false;
-
- return a.Handle == b.Handle;
- }
-
- public static bool operator != (DispatchObject a, DispatchObject b)
- {
- if (a is null)
- return b is not null;
- else if (b is null)
- return true;
- return a.Handle != b.Handle;
- }
-
- // For the .net profile `DisposableObject` implements both
- // `Equals` and `GetHashCode` based on the Handle property.
- public override bool Equals (object other)
- {
- var od = other as DispatchQueue;
- if (od is null)
- return false;
- return od.Handle == Handle;
- }
-
- public override int GetHashCode ()
- {
- return ((IntPtr) Handle).ToInt32 ();
- }
-#endif
-
-#if !NET
- [EditorBrowsable (EditorBrowsableState.Never)]
- [Obsolete ("Use 'GetCheckedHandle' instead.")]
- protected void Check ()
- {
- GetCheckedHandle ();
- }
-#endif
-
[DllImport (Constants.libcLibrary)]
extern static void dispatch_set_target_queue (/* dispatch_object_t */ IntPtr queue, /* dispatch_queue_t */ IntPtr target);
@@ -164,34 +113,28 @@ public void SetTargetQueue (DispatchQueue queue)
[DllImport (Constants.libcLibrary)]
internal extern static void dispatch_suspend (IntPtr o);
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
public void Activate ()
{
dispatch_activate (GetCheckedHandle ());
}
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
[DllImport (Constants.libcLibrary)]
extern static void dispatch_activate (/* dispatch_object_t */ IntPtr @object);
#endif // !COREBUILD
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public sealed class DispatchQueue : DispatchObject {
#if !COREBUILD
[Preserve (Conditional = true)]
@@ -199,12 +142,6 @@ internal DispatchQueue (NativeHandle handle, bool owns) : base (handle, owns)
{
}
-#if !NET
- public DispatchQueue (NativeHandle handle) : base (handle, false)
- {
- }
-#endif
-
public DispatchQueue (string label)
: base (dispatch_queue_create (label, IntPtr.Zero), true)
{
@@ -228,12 +165,10 @@ public DispatchQueue (string label, bool concurrent)
throw new Exception ("Error creating dispatch queue");
}
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
public DispatchQueue (string label, Attributes attributes, DispatchQueue? target = null)
: base (dispatch_queue_create_with_target (label, attributes?.Create () ?? IntPtr.Zero, target.GetHandle ()), true)
{
@@ -249,12 +184,10 @@ public string? Label {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public static string? CurrentQueueLabel {
get {
return Marshal.PtrToStringAnsi (dispatch_queue_get_label (IntPtr.Zero));
@@ -277,13 +210,8 @@ public void Resume ()
[DllImport (Constants.libcLibrary)]
extern static void dispatch_set_context (IntPtr o, IntPtr ctx);
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_apply_f (IntPtr iterations, IntPtr queue, IntPtr ctx, delegate* unmanaged dispatch);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_apply_f (IntPtr iterations, IntPtr queue, IntPtr ctx, dispatch_callback_iterations_t dispatch);
-#endif
public IntPtr Context {
get {
@@ -294,17 +222,12 @@ public IntPtr Context {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[ObsoletedOSPlatform ("macos10.9")]
[ObsoletedOSPlatform ("ios6.0")]
-#else
- [Deprecated (PlatformName.iOS, 6, 0)]
- [Deprecated (PlatformName.MacOSX, 10, 9)]
-#endif
public static DispatchQueue CurrentQueue {
get {
return new DispatchQueue (dispatch_get_current_queue (), false);
@@ -344,21 +267,8 @@ public static DispatchQueue MainQueue {
//
// Dispatching
//
-#if !NET
- internal delegate void dispatch_callback_t (IntPtr context);
- internal static readonly dispatch_callback_t static_dispatch = static_dispatcher_to_managed;
-
- internal delegate void dispatch_callback_iterations_t (IntPtr context, IntPtr count);
- internal static readonly dispatch_callback_iterations_t static_dispatch_iterations = static_dispatcher_iterations_to_managed;
-#endif
-
-#if NET
[UnmanagedCallersOnly]
internal static void static_dispatcher_to_managed (IntPtr context)
-#else
- [MonoPInvokeCallback (typeof (dispatch_callback_t))]
- static void static_dispatcher_to_managed (IntPtr context)
-#endif
{
GCHandle gch = GCHandle.FromIntPtr (context);
var obj = gch.Target as Tuple;
@@ -385,11 +295,7 @@ static void static_dispatcher_to_managed (IntPtr context)
}
-#if NET
[UnmanagedCallersOnly]
-#else
- [MonoPInvokeCallback (typeof (dispatch_callback_iterations_t))]
-#endif
static void static_dispatcher_iterations_to_managed (IntPtr context, IntPtr count)
{
GCHandle gch = GCHandle.FromIntPtr (context);
@@ -416,13 +322,8 @@ static void static_dispatcher_iterations_to_managed (IntPtr context, IntPtr coun
}
}
-#if !NET
- internal static readonly dispatch_callback_t free_gchandle = static_free_gchandle;
- [MonoPInvokeCallback (typeof (dispatch_callback_t))]
-#else
[UnmanagedCallersOnly]
-#endif
static void static_free_gchandle (IntPtr context)
{
GCHandle.FromIntPtr (context).Free ();
@@ -432,13 +333,9 @@ public void DispatchAsync (Action action)
{
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_async_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), &static_dispatcher_to_managed);
}
-#else
- dispatch_async_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), static_dispatch);
-#endif
}
public void DispatchAsync (DispatchBlock block)
@@ -454,13 +351,9 @@ public void DispatchSync (Action action)
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_sync_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), &static_dispatcher_to_managed);
}
-#else
- dispatch_sync_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), static_dispatch);
-#endif
}
public void DispatchSync (DispatchBlock block)
@@ -476,13 +369,9 @@ public void DispatchBarrierAsync (Action action)
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_barrier_async_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), &static_dispatcher_to_managed);
}
-#else
- dispatch_barrier_async_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), static_dispatch);
-#endif
}
public void DispatchBarrierAsync (DispatchBlock block)
@@ -498,13 +387,9 @@ public void DispatchBarrierSync (Action action)
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_barrier_sync_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), &static_dispatcher_to_managed);
}
-#else
- dispatch_barrier_sync_f (Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), static_dispatch);
-#endif
}
public void DispatchBarrierSync (DispatchBlock block)
@@ -519,13 +404,9 @@ public void DispatchAfter (DispatchTime when, Action action)
{
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_after_f (when.Nanoseconds, Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), &static_dispatcher_to_managed);
}
-#else
- dispatch_after_f (when.Nanoseconds, Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), static_dispatch);
-#endif
}
public void DispatchAfter (DispatchTime when, DispatchBlock block)
@@ -540,24 +421,16 @@ public void Submit (Action action, long times)
{
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_apply_f ((IntPtr) times, Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), &static_dispatcher_iterations_to_managed);
}
-#else
- dispatch_apply_f ((IntPtr) times, Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, this)), static_dispatch_iterations);
-#endif
}
public void SetSpecific (IntPtr key, object context)
{
-#if NET
unsafe {
dispatch_queue_set_specific (GetCheckedHandle (), key, (IntPtr) GCHandle.Alloc (context), &static_free_gchandle);
}
-#else
- dispatch_queue_set_specific (GetCheckedHandle (), key, (IntPtr) GCHandle.Alloc (context), free_gchandle);
-#endif
}
public object? GetSpecific (IntPtr key)
@@ -566,12 +439,10 @@ public void SetSpecific (IntPtr key, object context)
return gchandle.Target;
}
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
-#endif
public DispatchQualityOfService GetQualityOfService (out int relative_priority)
{
unsafe {
@@ -580,12 +451,10 @@ public DispatchQualityOfService GetQualityOfService (out int relative_priority)
}
}
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
-#endif
public DispatchQualityOfService QualityOfService {
get {
unsafe {
@@ -605,12 +474,10 @@ static IntPtr dispatch_queue_create (string label, IntPtr attr)
[DllImport (Constants.libcLibrary)]
extern static IntPtr dispatch_queue_create (IntPtr label, IntPtr attr);
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
static IntPtr dispatch_queue_create_with_target (string label, IntPtr attr, IntPtr target)
{
using var labelPtr = new TransientString (label);
@@ -620,72 +487,42 @@ static IntPtr dispatch_queue_create_with_target (string label, IntPtr attr, IntP
[DllImport (Constants.libcLibrary, EntryPoint = "dispatch_queue_create_with_target$V2")]
extern static IntPtr dispatch_queue_create_with_target (IntPtr label, IntPtr attr, IntPtr target);
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_async_f (IntPtr queue, IntPtr context, delegate* unmanaged dispatch);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_async_f (IntPtr queue, IntPtr context, dispatch_callback_t dispatch);
-#endif
[DllImport (Constants.libcLibrary)]
extern static void dispatch_async (IntPtr queue, IntPtr block);
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_sync_f (IntPtr queue, IntPtr context, delegate* unmanaged dispatch);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_sync_f (IntPtr queue, IntPtr context, dispatch_callback_t dispatch);
-#endif
[DllImport (Constants.libcLibrary)]
extern static void dispatch_sync (IntPtr queue, IntPtr block);
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_barrier_async_f (IntPtr queue, IntPtr context, delegate* unmanaged dispatch);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_barrier_async_f (IntPtr queue, IntPtr context, dispatch_callback_t dispatch);
-#endif
[DllImport (Constants.libcLibrary)]
extern static void dispatch_barrier_async (IntPtr queue, IntPtr block);
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_barrier_sync_f (IntPtr queue, IntPtr context, delegate* unmanaged dispatch);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_barrier_sync_f (IntPtr queue, IntPtr context, dispatch_callback_t dispatch);
-#endif
[DllImport (Constants.libcLibrary)]
extern static void dispatch_barrier_sync (IntPtr queue, IntPtr block);
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_after_f (/* dispath_time_t */ ulong time, IntPtr queue, IntPtr context, delegate* unmanaged dispatch);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_after_f (/* dispath_time_t */ ulong time, IntPtr queue, IntPtr context, dispatch_callback_t dispatch);
-#endif
[DllImport (Constants.libcLibrary)]
extern static void dispatch_after (/* dispath_time_t */ ulong time, IntPtr queue, IntPtr block);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[ObsoletedOSPlatform ("macos10.9")]
[ObsoletedOSPlatform ("ios6.0")]
-#else
- [Deprecated (PlatformName.iOS, 6, 0)]
- [Deprecated (PlatformName.MacOSX, 10, 9)]
-#endif
[DllImport (Constants.libcLibrary)]
extern static IntPtr dispatch_get_current_queue ();
@@ -697,58 +534,19 @@ static IntPtr dispatch_queue_create_with_target (string label, IntPtr attr, IntP
// this returns a "const char*" so we cannot make a string out of it since it will be freed (and crash)
extern static IntPtr dispatch_queue_get_label (IntPtr queue);
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_queue_set_specific (IntPtr queue, /* const void* */ IntPtr key, /* void *_Nullable */ IntPtr context, delegate* unmanaged /* _Nullable */ destructor);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_queue_set_specific (IntPtr queue, /* const void* */ IntPtr key, /* void *_Nullable */ IntPtr context, dispatch_callback_t /* _Nullable */ destructor);
-#endif
[DllImport (Constants.libcLibrary)]
extern static IntPtr dispatch_queue_get_specific (IntPtr queue, /* const void* */ IntPtr key);
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
-#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);
-#if !NET
- // For the .net profile `DisposableObject` implements both
- // `Equals` and `GetHashCode` based on the Handle property.
- public override bool Equals (object other)
- {
- if (other is DispatchQueue o)
- return (o.Handle == Handle);
- return false;
- }
-#endif
-
-#if !NET
- public static bool operator == (DispatchQueue left, DispatchQueue right)
- {
- if (left is null)
- return right is null;
- return left.Equals (right);
- }
-
- public static bool operator != (DispatchQueue left, DispatchQueue right)
- {
- if (left is null)
- return right is not null;
- return !left.Equals (right);
- }
-
- public override int GetHashCode ()
- {
- return ((IntPtr) Handle).ToInt32 ();
- }
-#endif
-
#if MONOMAC
//
// Not to be used by apps that use UIApplicationMain, NSApplicationMain or CFRunLoopRun,
@@ -766,36 +564,28 @@ public static void MainIteration ()
public class Attributes {
public bool Concurrent { get; set; }
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
-#endif
public bool IsInitiallyInactive { get; set; }
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
-#endif
public AutoreleaseFrequency? AutoreleaseFrequency { get; set; }
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
public int RelativePriority { get; set; }
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
public DispatchQualityOfService? QualityOfService { get; set; }
internal IntPtr Create ()
@@ -817,36 +607,28 @@ internal IntPtr Create ()
return rv;
}
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
-#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
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
-#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
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
-#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
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
[Native]
public enum AutoreleaseFrequency : ulong /* unsigned long */
{
@@ -859,12 +641,10 @@ public enum AutoreleaseFrequency : ulong /* unsigned long */
// Some insights from: https://opensource.apple.com/source/libdispatch/libdispatch-442.1.4/src/time.c
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public struct DispatchTime {
#if !COREBUILD
public static readonly DispatchTime Now = new DispatchTime ();
@@ -906,12 +686,10 @@ public DispatchTime WallTime {
#endif // !COREBUILD
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class DispatchGroup : DispatchObject {
#if !COREBUILD
[Preserve (Conditional = true)]
@@ -941,13 +719,9 @@ public void DispatchAsync (DispatchQueue queue, Action action)
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_group_async_f (GetCheckedHandle (), queue.Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, queue)), &DispatchQueue.static_dispatcher_to_managed);
}
-#else
- dispatch_group_async_f (GetCheckedHandle (), queue.Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, queue)), DispatchQueue.static_dispatch);
-#endif
}
public void Notify (DispatchQueue queue, DispatchBlock block)
@@ -965,13 +739,9 @@ public void Notify (DispatchQueue queue, Action action)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (queue));
if (action is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (action));
-#if NET
unsafe {
dispatch_group_notify_f (GetCheckedHandle (), queue.Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, queue)), &DispatchQueue.static_dispatcher_to_managed);
}
-#else
- dispatch_group_notify_f (GetCheckedHandle (), queue.Handle, (IntPtr) GCHandle.Alloc (Tuple.Create (action, queue)), DispatchQueue.static_dispatch);
-#endif
}
public void Enter ()
@@ -997,21 +767,11 @@ public bool Wait (TimeSpan timeout)
[DllImport (Constants.libcLibrary)]
extern static IntPtr dispatch_group_create ();
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_group_async_f (IntPtr group, IntPtr queue, IntPtr context, delegate* unmanaged block);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_group_async_f (IntPtr group, IntPtr queue, IntPtr context, DispatchQueue.dispatch_callback_t block);
-#endif
-#if NET
[DllImport (Constants.libcLibrary)]
extern unsafe static void dispatch_group_notify_f (IntPtr group, IntPtr queue, IntPtr context, delegate* unmanaged block);
-#else
- [DllImport (Constants.libcLibrary)]
- extern static void dispatch_group_notify_f (IntPtr group, IntPtr queue, IntPtr context, DispatchQueue.dispatch_callback_t block);
-#endif
[DllImport (Constants.libcLibrary)]
extern static void dispatch_group_notify (IntPtr group, IntPtr queue, IntPtr block);
diff --git a/src/CoreFoundation/DispatchBlock.cs b/src/CoreFoundation/DispatchBlock.cs
index 2f7d34995f7a..2929187bf3d0 100644
--- a/src/CoreFoundation/DispatchBlock.cs
+++ b/src/CoreFoundation/DispatchBlock.cs
@@ -16,19 +16,13 @@
using ObjCRuntime;
using Foundation;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
#if !COREBUILD
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
-#endif
public sealed class DispatchBlock : NativeObject {
[Preserve (Conditional = true)]
internal DispatchBlock (NativeHandle handle, bool owns)
diff --git a/src/CoreFoundation/DispatchData.cs b/src/CoreFoundation/DispatchData.cs
index 330e1f7a6b17..098ad35f7c3c 100644
--- a/src/CoreFoundation/DispatchData.cs
+++ b/src/CoreFoundation/DispatchData.cs
@@ -35,29 +35,15 @@
using ObjCRuntime;
using Foundation;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
public partial class DispatchData : DispatchObject {
#if !COREBUILD
[Preserve (Conditional = true)]
-#if NET
internal DispatchData (NativeHandle handle, bool owns) : base (handle, owns)
-#else
- public DispatchData (NativeHandle handle, bool owns) : base (handle, owns)
-#endif
{
}
-#if !NET
- public DispatchData (NativeHandle handle) : base (handle, false)
- {
- }
-#endif
-
[DllImport (Constants.libcLibrary)]
extern static IntPtr dispatch_data_create (IntPtr buffer, nuint size, IntPtr dispatchQueue, IntPtr destructor);
diff --git a/src/CoreFoundation/DispatchIO.cs b/src/CoreFoundation/DispatchIO.cs
index ec3c3b5ebc7e..3d1269d0c91e 100644
--- a/src/CoreFoundation/DispatchIO.cs
+++ b/src/CoreFoundation/DispatchIO.cs
@@ -40,41 +40,21 @@
using ObjCRuntime;
using Foundation;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
public delegate void DispatchIOHandler (DispatchData? data, int error);
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class DispatchIO : DispatchObject {
[Preserve (Conditional = true)]
internal DispatchIO (NativeHandle handle, bool owns) : base (handle, owns)
{
}
-#if !NET
- [Preserve (Conditional = true)]
- internal DispatchIO (NativeHandle handle) : this (handle, false)
- {
- }
-#endif
-
-#if !NET
- delegate void DispatchReadWrite (IntPtr block, IntPtr dispatchData, int error);
- static DispatchReadWrite static_DispatchReadWriteHandler = Trampoline_DispatchReadWriteHandler;
-
- [MonoPInvokeCallback (typeof (DispatchReadWrite))]
-#else
[UnmanagedCallersOnly]
-#endif
static void Trampoline_DispatchReadWriteHandler (IntPtr block, IntPtr dispatchData, int error)
{
var del = BlockLiteral.GetTarget (block);
@@ -99,13 +79,8 @@ public static void Read (int fd, nuint size, DispatchQueue dispatchQueue, Dispat
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (dispatchQueue));
unsafe {
-#if NET
delegate* unmanaged trampoline = &Trampoline_DispatchReadWriteHandler;
using var block = new BlockLiteral (trampoline, handler, typeof (DispatchIO), nameof (Trampoline_DispatchReadWriteHandler));
-#else
- using var block = new BlockLiteral ();
- block.SetupBlockUnsafe (static_DispatchReadWriteHandler, handler);
-#endif
dispatch_read (fd, size, dispatchQueue.Handle, &block);
}
}
@@ -124,13 +99,8 @@ public static void Write (int fd, DispatchData dispatchData, DispatchQueue dispa
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (dispatchQueue));
unsafe {
-#if NET
delegate* unmanaged trampoline = &Trampoline_DispatchReadWriteHandler;
using var block = new BlockLiteral (trampoline, handler, typeof (DispatchIO), nameof (Trampoline_DispatchReadWriteHandler));
-#else
- using var block = new BlockLiteral ();
- block.SetupBlockUnsafe (static_DispatchReadWriteHandler, handler);
-#endif
dispatch_write (fd, dispatchData.Handle, dispatchQueue.Handle, &block);
}
}
diff --git a/src/CoreFoundation/DispatchSource.cs b/src/CoreFoundation/DispatchSource.cs
index 5962bd1813b6..25bc548368a3 100644
--- a/src/CoreFoundation/DispatchSource.cs
+++ b/src/CoreFoundation/DispatchSource.cs
@@ -21,10 +21,6 @@
using dispatch_source_t = System.IntPtr;
using dispatch_queue_t = System.IntPtr;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
[Flags]
@@ -53,12 +49,10 @@ public enum VnodeMonitorKind : uint {
Revoke = 0x40,
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class DispatchSource : DispatchObject {
DispatchQueue? queue;
@@ -68,13 +62,6 @@ internal DispatchSource (NativeHandle handle, bool owns) : base (handle, owns)
{
}
-#if !NET
- // constructors for use in bindings
- internal DispatchSource (NativeHandle handle) : base (handle, false)
- {
- }
-#endif
-
// Invoked by subclasses in this file that fully initialize both
// queue and handle
internal DispatchSource () { }
@@ -225,12 +212,10 @@ public bool IsCanceled {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class Data : DispatchSource {
internal Data () { }
internal Data (IntPtr handle, bool owns) : base (handle, owns) { }
@@ -247,12 +232,10 @@ public IntPtr PendingData {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class DataAdd : Data {
static IntPtr type_data_add;
@@ -274,12 +257,10 @@ public DataAdd (DispatchQueue? queue = null)
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class DataOr : Data {
static IntPtr type_data_or;
@@ -300,12 +281,10 @@ public DataOr (DispatchQueue? queue = null)
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class Mach : DispatchSource {
internal Mach (IntPtr handle, bool owns) : base (handle, owns) { }
internal Mach (IntPtr handle) : base (handle, false) { }
@@ -319,12 +298,10 @@ public int MachPort {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class MachSend : Mach {
static IntPtr type_mach_send;
@@ -350,12 +327,11 @@ public bool SendRightsDestroyed {
}
}
}
-#if NET
+
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class MachReceive : DispatchSource {
static IntPtr type_mach_recv;
@@ -377,12 +353,10 @@ public MachReceive (int machPort, DispatchQueue? queue = null)
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class MemoryPressure : DispatchSource {
static IntPtr type_memorypressure;
public MemoryPressure (IntPtr handle, bool owns) : base (handle, owns) { }
@@ -408,12 +382,10 @@ public MemoryPressureFlags PressureFlags {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class ProcessMonitor : DispatchSource {
static IntPtr type_proc;
@@ -446,12 +418,10 @@ public ProcessMonitorFlags MonitorFlags {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class ReadMonitor : DispatchSource {
static IntPtr type_read;
public ReadMonitor (IntPtr handle, bool owns) : base (handle, owns) { }
@@ -483,12 +453,10 @@ public int BytesAvailable {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class SignalMonitor : DispatchSource {
static IntPtr type_signal;
public SignalMonitor (IntPtr handle, bool owns) : base (handle, owns) { }
@@ -519,12 +487,10 @@ public int SignalsDelivered {
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class Timer : DispatchSource {
static IntPtr type_timer;
public Timer (IntPtr handle, bool owns) : base (handle, owns) { }
@@ -558,12 +524,10 @@ public void SetTimer (DispatchTime time, long nanosecondInterval, long nanosecon
}
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class VnodeMonitor : DispatchSource {
static IntPtr type_vnode;
@@ -638,12 +602,10 @@ public VnodeMonitorKind ObservedEvents {
}
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public class WriteMonitor : DispatchSource {
static IntPtr type_write;
public WriteMonitor (IntPtr handle, bool owns) : base (handle, owns) { }
diff --git a/src/CoreFoundation/NativeObject.cs b/src/CoreFoundation/NativeObject.cs
index 433f47b2a1d0..f0131b5c5d3a 100644
--- a/src/CoreFoundation/NativeObject.cs
+++ b/src/CoreFoundation/NativeObject.cs
@@ -16,10 +16,6 @@
#nullable enable
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
//
// The NativeObject class is intended to be a base class for many CoreFoundation
@@ -33,12 +29,10 @@ namespace CoreFoundation {
// base class to be reused for other patterns that use other retain/release
// systems.
//
-#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
-#endif
public abstract class NativeObject : DisposableObject {
protected NativeObject ()
{
diff --git a/src/CoreFoundation/OSLog.cs b/src/CoreFoundation/OSLog.cs
index 1fb5f2663ac0..1c597c18e07d 100644
--- a/src/CoreFoundation/OSLog.cs
+++ b/src/CoreFoundation/OSLog.cs
@@ -29,18 +29,12 @@
using System.Runtime.InteropServices;
using System.Collections.Generic;
-#if !NET
-using NativeHandle = System.IntPtr;
-#endif
-
namespace CoreFoundation {
-#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
-#endif
public sealed class OSLog : NativeObject {
static OSLog? _default;
@@ -69,13 +63,8 @@ protected internal override void Release ()
os_release (Handle);
}
-#if NET
[DllImport (Constants.libSystemLibrary)]
extern static IntPtr os_log_create (IntPtr subsystem, IntPtr category);
-#else
- [DllImport (Constants.libSystemLibrary)]
- extern static IntPtr os_log_create (string subsystem, string category);
-#endif
[DllImport (Constants.libSystemLibrary)]
extern static IntPtr os_retain (IntPtr handle);
@@ -98,13 +87,9 @@ public OSLog (string subsystem, string category)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (subsystem));
if (category is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (category));
-#if NET
using var subsystemPtr = new TransientString (subsystem);
using var categoryPtr = new TransientString (category);
Handle = os_log_create (subsystemPtr, categoryPtr);
-#else
- Handle = os_log_create (subsystem, category);
-#endif
}
public void Log (string message)