[CoreFoundation] Add Support for DotNet Attributes (#12652)

This commit is contained in:
TJ Lambert 2021-09-09 22:58:11 -05:00 коммит произвёл GitHub
Родитель 4e0151657f
Коммит 3aa7dd810f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 184 добавлений и 0 удалений

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

@ -34,6 +34,7 @@ using System;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
#if XAMCORE_4_0
using CFNetwork;
#elif !WATCH
@ -159,20 +160,52 @@ namespace CoreFoundation {
#region Stream Constructors
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.CoreFoundationLibrary)]
internal extern static void CFStreamCreatePairWithSocket (/* CFAllocatorRef */ IntPtr allocator, CFSocketNativeHandle sock,
/* CFReadStreamRef* */ out IntPtr readStream, /* CFWriteStreamRef* */ out IntPtr writeStream);
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public static void CreatePairWithSocket (CFSocket socket, out CFReadStream readStream,
out CFWriteStream writeStream)
{
@ -185,21 +218,53 @@ namespace CoreFoundation {
writeStream = new CFWriteStream (write);
}
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.CFNetworkLibrary)]
internal extern static void CFStreamCreatePairWithPeerSocketSignature (/* CFAllocatorRef */ IntPtr allocator,
/* CFSocketSignature* */ ref CFSocketSignature sig,
/* CFReadStreamRef* */ out IntPtr readStream, /* CFWriteStreamRef* */ out IntPtr writeStream);
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public static void CreatePairWithPeerSocketSignature (AddressFamily family, SocketType type,
ProtocolType proto, IPEndPoint endpoint,
out CFReadStream readStream,
@ -216,11 +281,27 @@ namespace CoreFoundation {
#if !WATCH
// CFSocketStream.h in CFNetwork.framework (not CoreFoundation)
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.CFNetworkLibrary)]
internal extern static void CFStreamCreatePairWithSocketToCFHost (
/* CFAllocatorRef __nullable */ IntPtr allocator,
@ -228,11 +309,27 @@ namespace CoreFoundation {
/* CFReadStreamRef __nullable * __nullable */ out IntPtr readStream,
/* CFWriteStreamRef __nullable * __nullable */ out IntPtr writeStream);
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public static void CreatePairWithSocketToHost (IPEndPoint endpoint,
out CFReadStream readStream,
out CFWriteStream writeStream)
@ -247,21 +344,53 @@ namespace CoreFoundation {
}
#endif
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
[DllImport (Constants.CFNetworkLibrary)]
internal extern static void CFStreamCreatePairWithSocketToHost (/* CFAllocatorRef */ IntPtr allocator,
/* CFStringRef */ IntPtr host, /* UInt32 */ int port,
/* CFReadStreamRef* */ out IntPtr readStream, /* CFWriteStreamRef* */ out IntPtr writeStream);
#if !NET
[Deprecated (PlatformName.WatchOS, 8, 0, message: Constants.UseNetworkInstead)]
[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)]
#else
[UnsupportedOSPlatform ("ios15.0")]
[UnsupportedOSPlatform ("tvos15.0")]
[UnsupportedOSPlatform ("maccatalyst15.0")]
[UnsupportedOSPlatform ("macos12.0")]
#if __MACCATALYST__
[Obsolete ("Starting with maccatalyst15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
[Obsolete ("Starting with ios15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos15.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos12.0 use 'Network.framework' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public static void CreatePairWithSocketToHost (string host, int port,
out CFReadStream readStream,
out CFWriteStream writeStream)
@ -277,14 +406,29 @@ namespace CoreFoundation {
}
#if !WATCH
// CFHTTPStream.h in CFNetwork.framework (not CoreFoundation)
#if !NET
[Deprecated (PlatformName.iOS, 9, 0)]
[Deprecated (PlatformName.MacOSX, 10, 11)]
#else
[UnsupportedOSPlatform ("ios9.0")]
[UnsupportedOSPlatform ("macos10.11")]
#endif
[DllImport (Constants.CFNetworkLibrary)]
internal extern static /* CFReadStreamRef __nonnull */ IntPtr CFReadStreamCreateForHTTPRequest (
/* CFAllocatorRef __nullable */ IntPtr alloc, /* CFHTTPMessageRef __nonnull */ IntPtr request);
#if !NET
[Deprecated (PlatformName.iOS, 9, 0, message : "Use 'NSUrlSession' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 11, message : "Use 'NSUrlSession' instead.")]
#else
[UnsupportedOSPlatform ("ios9.0")]
[UnsupportedOSPlatform ("macos10.11")]
#if IOS
[Obsolete ("Starting with ios9.0 use 'NSUrlSession' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.11 use 'NSUrlSession' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public static CFHTTPStream CreateForHTTPRequest (CFHTTPMessage request)
{
if (request == null)
@ -295,15 +439,30 @@ namespace CoreFoundation {
}
// CFHTTPStream.h in CFNetwork.framework (not CoreFoundation)
#if !NET
[Deprecated (PlatformName.iOS, 9,0)]
[Deprecated (PlatformName.MacOSX, 10,11)]
#else
[UnsupportedOSPlatform ("ios9.0")]
[UnsupportedOSPlatform ("macos10.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
[Deprecated (PlatformName.iOS, 9,0, message : "Use 'NSUrlSession' instead.")]
[Deprecated (PlatformName.MacOSX, 10,11, message : "Use 'NSUrlSession' instead.")]
#else
[UnsupportedOSPlatform ("ios9.0")]
[UnsupportedOSPlatform ("macos10.11")]
#if IOS
[Obsolete ("Starting with ios9.0 use 'NSUrlSession' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
[Obsolete ("Starting with macos10.11 use 'NSUrlSession' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public static CFHTTPStream CreateForStreamedHTTPRequest (CFHTTPMessage request, CFReadStream body)
{
if (request == null)
@ -589,23 +748,33 @@ namespace CoreFoundation {
}
}
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static void CFReadStreamSetDispatchQueue (/* CFReadStreamRef */ IntPtr stream, /* dispatch_queue_t */ IntPtr queue);
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static void CFWriteStreamSetDispatchQueue (/* CFWriteStreamRef */ IntPtr stream, /* dispatch_queue_t */ IntPtr queue);
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static /* dispatch_queue_t */ IntPtr CFReadStreamCopyDispatchQueue (/* CFReadStreamRef */ IntPtr stream);
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static /* dispatch_queue_t */ IntPtr CFWriteStreamCopyDispatchQueue (/* CFWriteStreamRef */ IntPtr stream);
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
public DispatchQueue ReadDispatchQueue {
get {
return new DispatchQueue (CFReadStreamCopyDispatchQueue (handle));
@ -615,7 +784,9 @@ namespace CoreFoundation {
}
}
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
public DispatchQueue WriteDispatchQueue {
get {
return new DispatchQueue (CFWriteStreamCopyDispatchQueue (handle));

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

@ -30,6 +30,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Foundation;
using ObjCRuntime;
@ -150,12 +151,16 @@ namespace CoreFoundation {
return str.ToString ();
}
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
[return: MarshalAs (UnmanagedType.I1)]
extern static /* Boolean */ bool CFURLIsFileReferenceURL (/* CFURLRef */IntPtr url);
#if !NET
[iOS (7,0)][Mac (10,9)]
#endif
public bool IsFileReference {
get {
return CFURLIsFileReferenceURL (handle);

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

@ -33,6 +33,7 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using ObjCRuntime;
using Foundation;
@ -266,8 +267,10 @@ namespace CoreFoundation {
}
}
#if !NET
[Deprecated (PlatformName.iOS, 6, 0)]
[Deprecated (PlatformName.MacOSX, 10, 9)]
#endif
public static DispatchQueue CurrentQueue {
get {
return new DispatchQueue (dispatch_get_current_queue (), false);
@ -544,8 +547,10 @@ namespace CoreFoundation {
[DllImport (Constants.libcLibrary)]
extern static void dispatch_after (/* dispath_time_t */ ulong time, IntPtr queue, IntPtr block);
#if !NET
[Deprecated (PlatformName.iOS, 6,0)]
[Deprecated (PlatformName.MacOSX, 10,9)]
#endif
[DllImport (Constants.libcLibrary)]
extern static IntPtr dispatch_get_current_queue ();

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

@ -9,6 +9,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using ObjCRuntime;
using Foundation;
@ -16,8 +17,10 @@ using Foundation;
namespace CoreFoundation {
#if !COREBUILD
#if !NET
[iOS (8, 0)]
[Mac (10, 10)]
#endif
public sealed class DispatchBlock : NativeObject {
internal DispatchBlock (IntPtr handle, bool owns)
: base (handle, owns)