diff --git a/src/Network/NWAdvertiseDescriptor.cs b/src/Network/NWAdvertiseDescriptor.cs index b251b1536dd0..9146db39b63a 100644 --- a/src/Network/NWAdvertiseDescriptor.cs +++ b/src/Network/NWAdvertiseDescriptor.cs @@ -14,9 +14,9 @@ using Foundation; using CoreFoundation; -using nw_advertise_descriptor_t=System.IntPtr; -using OS_nw_advertise_descriptor=System.IntPtr; -using OS_nw_txt_record=System.IntPtr; +using nw_advertise_descriptor_t = System.IntPtr; +using OS_nw_advertise_descriptor = System.IntPtr; +using OS_nw_txt_record = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -29,10 +29,10 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWAdvertiseDescriptor : NativeObject { [Preserve (Conditional = true)] @@ -49,10 +49,10 @@ public NWAdvertiseDescriptor (NativeHandle handle, bool owns) : base (handle, ow [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_advertise_descriptor nw_advertise_descriptor_create_application_service (string application_service_name); @@ -63,12 +63,12 @@ public NWAdvertiseDescriptor (NativeHandle handle, bool owns) : base (handle, ow [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif - public NWAdvertiseDescriptor (string applicationServiceName) : base (nw_advertise_descriptor_create_application_service (applicationServiceName), true) {} + public NWAdvertiseDescriptor (string applicationServiceName) : base (nw_advertise_descriptor_create_application_service (applicationServiceName), true) { } #if NET [SupportedOSPlatform ("tvos16.0")] @@ -76,10 +76,10 @@ public NWAdvertiseDescriptor (string applicationServiceName) : base (nw_advertis [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern IntPtr nw_advertise_descriptor_get_application_service_name (OS_nw_advertise_descriptor advertise_descriptor); @@ -90,10 +90,10 @@ public NWAdvertiseDescriptor (string applicationServiceName) : base (nw_advertis [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public string? ApplicationServiceName { get { @@ -148,9 +148,9 @@ public bool NoAutoRename { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_txt_record nw_advertise_descriptor_copy_txt_record_object (OS_nw_advertise_descriptor advertise_descriptor); @@ -161,9 +161,9 @@ public bool NoAutoRename { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_advertise_descriptor_set_txt_record_object (OS_nw_advertise_descriptor advertise_descriptor, OS_nw_txt_record txt_record); @@ -174,13 +174,13 @@ public bool NoAutoRename { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public NWTxtRecord TxtRecord { - get => new NWTxtRecord (nw_advertise_descriptor_copy_txt_record_object (GetCheckedHandle ()), owns: true); - set => nw_advertise_descriptor_set_txt_record_object (GetCheckedHandle (), value.GetHandle ()); + get => new NWTxtRecord (nw_advertise_descriptor_copy_txt_record_object (GetCheckedHandle ()), owns: true); + set => nw_advertise_descriptor_set_txt_record_object (GetCheckedHandle (), value.GetHandle ()); } } } diff --git a/src/Network/NWBrowseResult.cs b/src/Network/NWBrowseResult.cs index b75735dcc18f..3738a9020448 100644 --- a/src/Network/NWBrowseResult.cs +++ b/src/Network/NWBrowseResult.cs @@ -15,9 +15,9 @@ using Foundation; using CoreFoundation; -using OS_nw_browse_result=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; -using OS_nw_txt_record=System.IntPtr; +using OS_nw_browse_result = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; +using OS_nw_txt_record = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -31,15 +31,15 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWBrowseResult : NativeObject { [Preserve (Conditional = true)] - internal NWBrowseResult (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWBrowseResult (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern OS_nw_endpoint nw_browse_result_copy_endpoint (OS_nw_browse_result result); @@ -54,7 +54,7 @@ internal NWBrowseResult (NativeHandle handle, bool owns) : base (handle, owns) { [DllImport (Constants.NetworkLibrary)] static extern OS_nw_txt_record nw_browse_result_copy_txt_record_object (OS_nw_browse_result result); - public NWTxtRecord TxtRecord => new NWTxtRecord (nw_browse_result_copy_txt_record_object (GetCheckedHandle ()), owns: true); + public NWTxtRecord TxtRecord => new NWTxtRecord (nw_browse_result_copy_txt_record_object (GetCheckedHandle ()), owns: true); [DllImport (Constants.NetworkLibrary)] static extern NWBrowseResultChange nw_browse_result_get_changes (OS_nw_browse_result old_result, OS_nw_browse_result new_result); diff --git a/src/Network/NWBrowser.cs b/src/Network/NWBrowser.cs index 4cc89823e535..dc11da0b56ae 100644 --- a/src/Network/NWBrowser.cs +++ b/src/Network/NWBrowser.cs @@ -16,10 +16,10 @@ using Foundation; using CoreFoundation; -using OS_nw_browser=System.IntPtr; -using OS_nw_browse_descriptor=System.IntPtr; -using OS_nw_parameters=System.IntPtr; -using dispatch_queue_t =System.IntPtr; +using OS_nw_browser = System.IntPtr; +using OS_nw_browse_descriptor = System.IntPtr; +using OS_nw_parameters = System.IntPtr; +using dispatch_queue_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -37,10 +37,10 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWBrowser : NativeObject { @@ -66,7 +66,7 @@ public NWBrowser (NWBrowserDescriptor descriptor, NWParameters? parameters) SetChangesHandler (InternalChangesHandler); } - public NWBrowser (NWBrowserDescriptor descriptor) : this (descriptor, null) {} + public NWBrowser (NWBrowserDescriptor descriptor) : this (descriptor, null) { } [DllImport (Constants.NetworkLibrary)] static extern void nw_browser_set_queue (OS_nw_browser browser, dispatch_queue_t queue); @@ -111,7 +111,7 @@ public void Cancel () public bool IsActive { get { - lock (startLock) + lock (startLock) return started; } } @@ -129,7 +129,7 @@ public NWParameters Parameters => new NWParameters (nw_browser_copy_parameters (GetCheckedHandle ()), owns: true); [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_browser_set_browse_results_changed_handler (OS_nw_browser browser, void *handler); + unsafe static extern void nw_browser_set_browse_results_changed_handler (OS_nw_browser browser, void* handler); delegate void nw_browser_browse_results_changed_handler_t (IntPtr block, IntPtr oldResult, IntPtr newResult, bool completed); static nw_browser_browse_results_changed_handler_t static_ChangesHandler = TrampolineChangesHandler; @@ -165,7 +165,7 @@ void InternalChangesHandler (NWBrowseResult? oldResult, NWBrowseResult? newResul // results can be null, since we could have a not old one oldResult?.Dispose (); newResult?.Dispose (); - return; + return; } // get the change, add it to the list var change = NWBrowseResult.GetChanges (oldResult, newResult); @@ -177,7 +177,7 @@ void InternalChangesHandler (NWBrowseResult? oldResult, NWBrowseResult? newResul lock (changesLock) { changes.Add (result); // only call when we know we are done - if (completed) { + if (completed) { tmp_changes = changes; changes = new List<(NWBrowseResult? result, NWBrowseResultChange change)> (); } @@ -199,7 +199,7 @@ void SetChangesHandler (NWBrowserChangesDelegate? handler) return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_ChangesHandler, handler); try { nw_browser_set_browse_results_changed_handler (GetCheckedHandle (), (void*) block_ptr_handler); @@ -207,7 +207,7 @@ void SetChangesHandler (NWBrowserChangesDelegate? handler) block_handler.CleanupBlock (); } } - } + } // let to not change the API, but would be nice to remove it in the following releases. #if !NET @@ -216,7 +216,7 @@ void SetChangesHandler (NWBrowserChangesDelegate? handler) #endif [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_browser_set_state_changed_handler (OS_nw_browser browser, void *state_changed_handler); + unsafe static extern void nw_browser_set_state_changed_handler (OS_nw_browser browser, void* state_changed_handler); delegate void nw_browser_set_state_changed_handler_t (IntPtr block, NWBrowserState state, IntPtr error); static nw_browser_set_state_changed_handler_t static_StateChangesHandler = TrampolineStateChangesHandler; @@ -226,7 +226,7 @@ static void TrampolineStateChangesHandler (IntPtr block, NWBrowserState state, I { var del = BlockLiteral.GetTarget> (block); if (del is not null) { - var nwError = (error == IntPtr.Zero)? null : new NWError (error, owns: false); + var nwError = (error == IntPtr.Zero) ? null : new NWError (error, owns: false); del (state, nwError); } } @@ -240,7 +240,7 @@ public void SetStateChangesHandler (Action handler) return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_StateChangesHandler, handler); try { nw_browser_set_state_changed_handler (GetCheckedHandle (), (void*) block_ptr_handler); @@ -248,6 +248,6 @@ public void SetStateChangesHandler (Action handler) block_handler.CleanupBlock (); } } - } + } } } diff --git a/src/Network/NWBrowserDescriptor.cs b/src/Network/NWBrowserDescriptor.cs index 1a59362c7c7a..4ca80304cf98 100644 --- a/src/Network/NWBrowserDescriptor.cs +++ b/src/Network/NWBrowserDescriptor.cs @@ -15,7 +15,7 @@ using Foundation; using CoreFoundation; -using OS_nw_browse_descriptor=System.IntPtr; +using OS_nw_browse_descriptor = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -29,15 +29,15 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif - public class NWBrowserDescriptor: NativeObject { + public class NWBrowserDescriptor : NativeObject { [Preserve (Conditional = true)] - internal NWBrowserDescriptor (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWBrowserDescriptor (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern OS_nw_browse_descriptor nw_browse_descriptor_create_bonjour_service (string type, string? domain); @@ -48,10 +48,10 @@ internal NWBrowserDescriptor (NativeHandle handle, bool owns) : base (handle, ow [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_browse_descriptor nw_browse_descriptor_create_application_service (string application_service_name); @@ -62,10 +62,10 @@ internal NWBrowserDescriptor (NativeHandle handle, bool owns) : base (handle, ow [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public static NWBrowserDescriptor CreateApplicationServiceName (string applicationServiceName) { @@ -81,10 +81,10 @@ public static NWBrowserDescriptor CreateApplicationServiceName (string applicati [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern IntPtr nw_browse_descriptor_get_application_service_name (OS_nw_browse_descriptor descriptor); @@ -95,10 +95,10 @@ public static NWBrowserDescriptor CreateApplicationServiceName (string applicati [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public string? ApplicationServiceName { get { @@ -126,20 +126,20 @@ public static NWBrowserDescriptor CreateBonjourService (string type, string? dom static extern void nw_browse_descriptor_set_include_txt_record (OS_nw_browse_descriptor descriptor, [MarshalAs (UnmanagedType.I1)] bool include_txt_record); public bool IncludeTxtRecord { - get => nw_browse_descriptor_get_include_txt_record (GetCheckedHandle ()); - set => nw_browse_descriptor_set_include_txt_record (GetCheckedHandle (), value); + get => nw_browse_descriptor_get_include_txt_record (GetCheckedHandle ()); + set => nw_browse_descriptor_set_include_txt_record (GetCheckedHandle (), value); } [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr nw_browse_descriptor_get_bonjour_service_type (OS_nw_browse_descriptor descriptor); public string? BonjourType - => Marshal.PtrToStringAnsi (nw_browse_descriptor_get_bonjour_service_type (GetCheckedHandle ())); + => Marshal.PtrToStringAnsi (nw_browse_descriptor_get_bonjour_service_type (GetCheckedHandle ())); [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr nw_browse_descriptor_get_bonjour_service_domain (OS_nw_browse_descriptor descriptor); public string? BonjourDomain - => Marshal.PtrToStringAnsi (nw_browse_descriptor_get_bonjour_service_domain (GetCheckedHandle ())); + => Marshal.PtrToStringAnsi (nw_browse_descriptor_get_bonjour_service_domain (GetCheckedHandle ())); } } diff --git a/src/Network/NWConnection.cs b/src/Network/NWConnection.cs index 39315e04e2a8..8a7b527cd4bc 100644 --- a/src/Network/NWConnection.cs +++ b/src/Network/NWConnection.cs @@ -13,10 +13,10 @@ using ObjCRuntime; using Foundation; using CoreFoundation; -using nw_connection_t=System.IntPtr; -using nw_endpoint_t=System.IntPtr; -using nw_parameters_t=System.IntPtr; -using nw_establishment_report_t=System.IntPtr; +using nw_connection_t = System.IntPtr; +using nw_endpoint_t = System.IntPtr; +using nw_parameters_t = System.IntPtr; +using nw_establishment_report_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -51,17 +51,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWConnection : NativeObject { [Preserve (Conditional = true)] #if NET internal NWConnection (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWConnection (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWConnection (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -106,7 +106,7 @@ public NWParameters? Parameters { [MonoPInvokeCallback (typeof (StateChangeCallback))] static void Trampoline_StateChangeCallback (IntPtr block, NWConnectionState state, IntPtr error) { - var del = BlockLiteral.GetTarget> (block); + var del = BlockLiteral.GetTarget> (block); if (del is not null) { NWError? err = error != IntPtr.Zero ? new NWError (error, owns: false) : null; del (state, err); @@ -114,10 +114,10 @@ static void Trampoline_StateChangeCallback (IntPtr block, NWConnectionState stat } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_connection_set_state_changed_handler (nw_connection_t connection, void *handler); + unsafe static extern void nw_connection_set_state_changed_handler (nw_connection_t connection, void* handler); [BindingImpl (BindingImplOptions.Optimizable)] - public unsafe void SetStateChangeHandler (Action stateHandler) + public unsafe void SetStateChangeHandler (Action stateHandler) { if (stateHandler is null) { nw_connection_set_state_changed_handler (GetCheckedHandle (), null); @@ -126,7 +126,7 @@ public unsafe void SetStateChangeHandler (Action sta unsafe { BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_stateChangeHandler, stateHandler); try { @@ -137,7 +137,7 @@ public unsafe void SetStateChangeHandler (Action sta } } - delegate void nw_connection_boolean_event_handler_t (IntPtr block, [MarshalAs(UnmanagedType.U1)] bool value); + delegate void nw_connection_boolean_event_handler_t (IntPtr block, [MarshalAs (UnmanagedType.U1)] bool value); static nw_connection_boolean_event_handler_t static_BooleanChangeHandler = TrampolineBooleanChangeHandler; [MonoPInvokeCallback (typeof (nw_connection_boolean_event_handler_t))] @@ -145,11 +145,11 @@ static void TrampolineBooleanChangeHandler (IntPtr block, bool value) { var del = BlockLiteral.GetTarget> (block); if (del is not null) - del (value); + del (value); } [DllImport (Constants.NetworkLibrary)] - static extern unsafe void nw_connection_set_viability_changed_handler (IntPtr handle, void *callback); + static extern unsafe void nw_connection_set_viability_changed_handler (IntPtr handle, void* callback); [BindingImpl (BindingImplOptions.Optimizable)] public unsafe void SetBooleanChangeHandler (Action callback) @@ -161,7 +161,7 @@ public unsafe void SetBooleanChangeHandler (Action callback) unsafe { BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_BooleanChangeHandler, callback); try { @@ -173,7 +173,7 @@ public unsafe void SetBooleanChangeHandler (Action callback) } [DllImport (Constants.NetworkLibrary)] - static extern unsafe void nw_connection_set_better_path_available_handler (IntPtr handle, void *callback); + static extern unsafe void nw_connection_set_better_path_available_handler (IntPtr handle, void* callback); [BindingImpl (BindingImplOptions.Optimizable)] public unsafe void SetBetterPathAvailableHandler (Action callback) @@ -185,7 +185,7 @@ public unsafe void SetBetterPathAvailableHandler (Action callback) unsafe { BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_BooleanChangeHandler, callback); try { @@ -285,10 +285,10 @@ static void TrampolineReceiveCompletion (IntPtr block, IntPtr dispatchDataPtr, I } del (bufferAddress, - bufferSize, - contentContext == IntPtr.Zero ? null : new NWContentContext (contentContext, owns: false), - isComplete, - error == IntPtr.Zero ? null : new NWError (error, owns: false)); + bufferSize, + contentContext == IntPtr.Zero ? null : new NWContentContext (contentContext, owns: false), + isComplete, + error == IntPtr.Zero ? null : new NWError (error, owns: false)); if (dispatchData is not null) { dataCopy?.Dispose (); @@ -309,9 +309,9 @@ static void TrampolineReceiveCompletionData (IntPtr block, IntPtr dispatchDataPt dispatchData = new DispatchData (dispatchDataPtr, owns: false); del (dispatchData, - contentContext == IntPtr.Zero ? null : new NWContentContext (contentContext, owns: false), - isComplete, - error == IntPtr.Zero ? null : new NWError (error, owns: false)); + contentContext == IntPtr.Zero ? null : new NWContentContext (contentContext, owns: false), + isComplete, + error == IntPtr.Zero ? null : new NWError (error, owns: false)); if (dispatchData is not null) dispatchData.Dispose (); @@ -325,7 +325,7 @@ static void TrampolineReceiveCompletionReadOnlyData (IntPtr block, IntPtr dispat if (del is not null) { var dispatchData = (dispatchDataPtr != IntPtr.Zero) ? new DispatchData (dispatchDataPtr, owns: false) : null; - var spanData = new ReadOnlySpan (dispatchData?.ToArray () ?? Array.Empty()); + var spanData = new ReadOnlySpan (dispatchData?.ToArray () ?? Array.Empty ()); del (spanData, contentContext == IntPtr.Zero ? null : new NWContentContext (contentContext, owns: false), isComplete, @@ -454,23 +454,23 @@ static void TrampolineSendCompletion (IntPtr block, IntPtr error) [DllImport (Constants.NetworkLibrary)] static extern unsafe void nw_connection_send (IntPtr handle, - IntPtr dispatchData, - IntPtr contentContext, - [MarshalAs(UnmanagedType.U1)] bool isComplete, - void *callback); + IntPtr dispatchData, + IntPtr contentContext, + [MarshalAs (UnmanagedType.U1)] bool isComplete, + void* callback); // // This has more uses than the current ones, we might want to introduce // additional SendXxx methods to encode the few options that are currently // configured via one of the three NWContentContext static properties // - unsafe void LowLevelSend (IntPtr handle, DispatchData? buffer, IntPtr contentContext, bool isComplete, void *callback) + unsafe void LowLevelSend (IntPtr handle, DispatchData? buffer, IntPtr contentContext, bool isComplete, void* callback) { nw_connection_send (handle: GetCheckedHandle (), - dispatchData: buffer.GetHandle (), - contentContext: contentContext, - isComplete: isComplete, - callback: callback); + dispatchData: buffer.GetHandle (), + contentContext: contentContext, + isComplete: isComplete, + callback: callback); } public void Send (byte [] buffer, NWContentContext context, bool isComplete, Action callback) @@ -501,7 +501,7 @@ public void Send (DispatchData? buffer, NWContentContext context, bool isComplet unsafe { BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_SendCompletion, callback); try { @@ -517,7 +517,7 @@ public unsafe void SendIdempotent (DispatchData? buffer, NWContentContext contex if (context is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (context)); - LowLevelSend (GetCheckedHandle (), buffer, context.Handle, isComplete, (void *) NWConnectionConstants._SendIdempotentContent); + LowLevelSend (GetCheckedHandle (), buffer, context.Handle, isComplete, (void*) NWConnectionConstants._SendIdempotentContent); } public void SendIdempotent (byte [] buffer, NWContentContext context, bool isComplete) @@ -579,7 +579,7 @@ public NWPath? CurrentPath { public void Batch (Action method) { - BlockLiteral.SimpleCall (method, (arg)=> nw_connection_batch (GetCheckedHandle (), arg)); + BlockLiteral.SimpleCall (method, (arg) => nw_connection_batch (GetCheckedHandle (), arg)); } #if NET @@ -588,14 +588,14 @@ public void Batch (Action method) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] unsafe static extern void nw_connection_access_establishment_report (IntPtr connection, IntPtr queue, ref BlockLiteral access_block); - delegate void nw_establishment_report_access_block_t (IntPtr block, nw_establishment_report_t report); + delegate void nw_establishment_report_access_block_t (IntPtr block, nw_establishment_report_t report); static nw_establishment_report_access_block_t static_GetEstablishmentReportHandler = TrampolineGetEstablishmentReportHandler; [MonoPInvokeCallback (typeof (nw_establishment_report_access_block_t))] @@ -615,9 +615,9 @@ static void TrampolineGetEstablishmentReportHandler (IntPtr block, nw_establishm [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [BindingImpl (BindingImplOptions.Optimizable)] public void GetEstablishmentReport (DispatchQueue queue, Action handler) diff --git a/src/Network/NWConnectionGroup.cs b/src/Network/NWConnectionGroup.cs index d4bfd4dee75e..9e6a310e6949 100644 --- a/src/Network/NWConnectionGroup.cs +++ b/src/Network/NWConnectionGroup.cs @@ -3,16 +3,16 @@ using ObjCRuntime; using Foundation; using CoreFoundation; -using OS_nw_connection=System.IntPtr; -using OS_nw_connection_group=System.IntPtr; -using OS_nw_group_descriptor=System.IntPtr; -using OS_nw_parameters=System.IntPtr; -using OS_nw_content_context=System.IntPtr; -using OS_nw_path=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; -using OS_nw_protocol_metadata=System.IntPtr; -using OS_nw_protocol_definition=System.IntPtr; -using OS_nw_protocol_options=System.IntPtr; +using OS_nw_connection = System.IntPtr; +using OS_nw_connection_group = System.IntPtr; +using OS_nw_group_descriptor = System.IntPtr; +using OS_nw_parameters = System.IntPtr; +using OS_nw_content_context = System.IntPtr; +using OS_nw_path = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; +using OS_nw_protocol_metadata = System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using OS_nw_protocol_options = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -28,11 +28,11 @@ namespace Network { // [SupportedOSPlatform ("ios14.0")] // [SupportedOSPlatform ("maccatalyst14.0")] #else - [TV (14,0)] - [Mac (11,0)] - [iOS (14,0)] - [Watch (7,0)] - [MacCatalyst (14,0)] + [TV (14, 0)] + [Mac (11, 0)] + [iOS (14, 0)] + [Watch (7, 0)] + [MacCatalyst (14, 0)] #endif public delegate void NWConnectionGroupReceiveDelegate (DispatchData content, NWContentContext context, bool isCompleted); @@ -42,11 +42,11 @@ namespace Network { // [SupportedOSPlatform ("ios14.0")] // [SupportedOSPlatform ("maccatalyst14.0")] #else - [TV (14,0)] - [Mac (11,0)] - [iOS (14,0)] - [Watch (7,0)] - [MacCatalyst (14,0)] + [TV (14, 0)] + [Mac (11, 0)] + [iOS (14, 0)] + [Watch (7, 0)] + [MacCatalyst (14, 0)] #endif public delegate void NWConnectionGroupStateChangedDelegate (NWConnectionGroupState state, NWError? error); @@ -56,15 +56,15 @@ namespace Network { [SupportedOSPlatform ("ios14.0")] [SupportedOSPlatform ("maccatalyst14.0")] #else - [TV (14,0)] - [Mac (11,0)] - [iOS (14,0)] - [Watch (7,0)] - [MacCatalyst (14,0)] + [TV (14, 0)] + [Mac (11, 0)] + [iOS (14, 0)] + [Watch (7, 0)] + [MacCatalyst (14, 0)] #endif public class NWConnectionGroup : NativeObject { [Preserve (Conditional = true)] - protected internal NWConnectionGroup (NativeHandle handle, bool owns) : base (handle, owns) {} + protected internal NWConnectionGroup (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern OS_nw_connection_group nw_connection_group_create (OS_nw_group_descriptor group_descriptor, OS_nw_parameters parameters); @@ -106,19 +106,19 @@ public NWParameters? Parameters { [DllImport (Constants.NetworkLibrary)] static extern void nw_connection_group_start (OS_nw_connection_group group); - public void Start () => nw_connection_group_start (GetCheckedHandle ()); + public void Start () => nw_connection_group_start (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern void nw_connection_group_cancel (OS_nw_connection_group group); - public void Cancel () => nw_connection_group_cancel (GetCheckedHandle ()); + public void Cancel () => nw_connection_group_cancel (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern void nw_connection_group_set_queue (OS_nw_connection_group group, IntPtr queue); public void SetQueue (DispatchQueue queue) { - if (queue is null) + if (queue is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (queue)); nw_connection_group_set_queue (GetCheckedHandle (), queue.GetCheckedHandle ()); @@ -182,11 +182,11 @@ public void Reply (NWContentContext inboundMessage, NWContentContext outboundMes if (outboundMessage is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (outboundMessage)); - nw_connection_group_reply (GetCheckedHandle (), inboundMessage.GetCheckedHandle (), outboundMessage.GetCheckedHandle (), content.GetHandle ()); + nw_connection_group_reply (GetCheckedHandle (), inboundMessage.GetCheckedHandle (), outboundMessage.GetCheckedHandle (), content.GetHandle ()); } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_connection_group_send_message (OS_nw_connection_group group, /* [NullAllowed] DispatchData */ IntPtr content, /* [NullAllowed] */ OS_nw_endpoint endpoint, OS_nw_content_context context, BlockLiteral *handler); + unsafe static extern void nw_connection_group_send_message (OS_nw_connection_group group, /* [NullAllowed] DispatchData */ IntPtr content, /* [NullAllowed] */ OS_nw_endpoint endpoint, OS_nw_content_context context, BlockLiteral* handler); delegate void nw_connection_group_send_completion_t (IntPtr block, IntPtr error); static nw_connection_group_send_completion_t static_SendCompletion = TrampolineSendCompletion; @@ -229,7 +229,7 @@ public void Send (DispatchData? content, NWEndpoint? endpoint, NWContentContext } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_connection_group_set_receive_handler (OS_nw_connection_group group, uint maximum_message_size, [MarshalAs (UnmanagedType.I1)] bool reject_oversized_messages, BlockLiteral *handler); + unsafe static extern void nw_connection_group_set_receive_handler (OS_nw_connection_group group, uint maximum_message_size, [MarshalAs (UnmanagedType.I1)] bool reject_oversized_messages, BlockLiteral* handler); delegate void nw_connection_group_receive_handler_t (IntPtr block, IntPtr content, IntPtr context, bool isCompleted); static nw_connection_group_receive_handler_t static_ReceiveHandler = TrampolineReceiveHandler; @@ -265,9 +265,9 @@ public void SetReceiveHandler (uint maximumMessageSize, bool rejectOversizedMess } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_connection_group_set_state_changed_handler (OS_nw_connection_group group, BlockLiteral *handler); + unsafe static extern void nw_connection_group_set_state_changed_handler (OS_nw_connection_group group, BlockLiteral* handler); - delegate void nw_connection_group_state_changed_handler_t (IntPtr block, NWConnectionGroupState state , IntPtr error); + delegate void nw_connection_group_state_changed_handler_t (IntPtr block, NWConnectionGroupState state, IntPtr error); static nw_connection_group_state_changed_handler_t static_StateChangedHandler = TrampolineStateChangedHandler; [MonoPInvokeCallback (typeof (nw_connection_group_state_changed_handler_t))] @@ -305,11 +305,11 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_metadata nw_connection_group_copy_protocol_metadata (OS_nw_connection_group group, OS_nw_protocol_definition definition); @@ -320,13 +320,14 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif - public NWProtocolMetadata? GetProtocolMetadata (NWContentContext context) { + public NWProtocolMetadata? GetProtocolMetadata (NWContentContext context) + { if (context is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (context)); var ptr = nw_connection_group_copy_protocol_metadata (GetCheckedHandle (), context.Handle); @@ -339,11 +340,11 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_metadata nw_connection_group_copy_protocol_metadata_for_message (OS_nw_connection_group group, OS_nw_content_context context, OS_nw_protocol_definition definition); @@ -354,13 +355,14 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif - public NWProtocolMetadata? GetProtocolMetadata (NWContentContext context, NWProtocolDefinition definition) { + public NWProtocolMetadata? GetProtocolMetadata (NWContentContext context, NWProtocolDefinition definition) + { if (context is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (context)); if (definition is null) @@ -375,11 +377,11 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_connection nw_connection_group_extract_connection (OS_nw_connection_group group, OS_nw_endpoint endpoint, OS_nw_protocol_options protocolOptions); @@ -390,11 +392,11 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public NWConnection? ExtractConnection (NWEndpoint endpoint, NWProtocolOptions protocolOptions) { @@ -408,11 +410,11 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -424,11 +426,11 @@ public void SetStateChangedHandler (NWConnectionGroupStateChangedDelegate handle [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public bool TryReinsertExtractedConnection (NWConnection connection) { @@ -443,19 +445,19 @@ public bool TryReinsertExtractedConnection (NWConnection connection) [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_connection_group_set_new_connection_handler (OS_nw_connection_group group, ref BlockLiteral connectionHandler); - - delegate void nw_connection_group_new_connection_handler_t (IntPtr block, IntPtr connection); + + delegate void nw_connection_group_new_connection_handler_t (IntPtr block, IntPtr connection); static nw_connection_group_new_connection_handler_t static_SetNewConnectionHandler = TrampolineSetNewConnectionHandler; - - [MonoPInvokeCallback (typeof (nw_connection_group_new_connection_handler_t ))] + + [MonoPInvokeCallback (typeof (nw_connection_group_new_connection_handler_t))] static void TrampolineSetNewConnectionHandler (IntPtr block, IntPtr connection) { var del = BlockLiteral.GetTarget> (block); @@ -472,11 +474,11 @@ static void TrampolineSetNewConnectionHandler (IntPtr block, IntPtr connection) [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [BindingImpl (BindingImplOptions.Optimizable)] public void SetNewConnectionHandler (Action handler) diff --git a/src/Network/NWContentContext.cs b/src/Network/NWContentContext.cs index e60a244bc07b..4a972a371968 100644 --- a/src/Network/NWContentContext.cs +++ b/src/Network/NWContentContext.cs @@ -31,10 +31,10 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWContentContext : NativeObject { bool global; @@ -171,7 +171,7 @@ public void SetMetadata (NWProtocolMetadata protocolMetadata) [MonoPInvokeCallback (typeof (ProtocolIterator))] static void TrampolineProtocolIterator (IntPtr block, IntPtr definition, IntPtr metadata) { - var del = BlockLiteral.GetTarget> (block); + var del = BlockLiteral.GetTarget> (block); if (del is not null) { using NWProtocolDefinition? pdef = definition == IntPtr.Zero ? null : new NWProtocolDefinition (definition, owns: true); using NWProtocolMetadata? meta = metadata == IntPtr.Zero ? null : new NWProtocolMetadata (metadata, owns: true); @@ -184,7 +184,7 @@ static void TrampolineProtocolIterator (IntPtr block, IntPtr definition, IntPtr static extern void nw_content_context_foreach_protocol_metadata (IntPtr handle, ref BlockLiteral callback); [BindingImpl (BindingImplOptions.Optimizable)] - public void IterateProtocolMetadata (Action callback) + public void IterateProtocolMetadata (Action callback) { BlockLiteral block_handler = new BlockLiteral (); block_handler.SetupBlockUnsafe (static_ProtocolIterator, callback); @@ -215,7 +215,7 @@ public static NWContentContext DefaultMessage { public static NWContentContext FinalMessage { get { if (finalMessage is null) - finalMessage = MakeGlobal (NWContentContextConstants._FinalSend); + finalMessage = MakeGlobal (NWContentContextConstants._FinalSend); return finalMessage; } } diff --git a/src/Network/NWDataTransferReport.cs b/src/Network/NWDataTransferReport.cs index 7b2a9dbfdd81..772e91a11bba 100644 --- a/src/Network/NWDataTransferReport.cs +++ b/src/Network/NWDataTransferReport.cs @@ -17,9 +17,9 @@ using Foundation; using CoreFoundation; -using OS_nw_data_transfer_report=System.IntPtr; -using OS_nw_connection=System.IntPtr; -using OS_nw_interface=System.IntPtr; +using OS_nw_data_transfer_report = System.IntPtr; +using OS_nw_connection = System.IntPtr; +using OS_nw_interface = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -33,15 +33,15 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWDataTransferReport : NativeObject { [Preserve (Conditional = true)] - internal NWDataTransferReport (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWDataTransferReport (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern OS_nw_data_transfer_report nw_connection_create_new_data_transfer_report (OS_nw_connection connection); @@ -179,18 +179,18 @@ public void Collect (DispatchQueue queue, Action handler) static extern NWDataTransferReportState nw_data_transfer_report_get_state (OS_nw_data_transfer_report report); public NWDataTransferReportState State => nw_data_transfer_report_get_state (GetCheckedHandle ()); - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern NWInterfaceRadioType nw_data_transfer_report_get_path_radio_type (OS_nw_data_transfer_report report, uint pathIndex); @@ -201,11 +201,11 @@ public void Collect (DispatchQueue queue, Action handler) [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public NWInterfaceRadioType GetPathRadioType (uint pathIndex) => nw_data_transfer_report_get_path_radio_type (GetCheckedHandle (), pathIndex); @@ -217,11 +217,11 @@ public NWInterfaceRadioType GetPathRadioType (uint pathIndex) [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [Obsolete ("Use the 'GetPathRadioType' property instead.")] [EditorBrowsable (EditorBrowsableState.Never)] diff --git a/src/Network/NWEndpoint.cs b/src/Network/NWEndpoint.cs index 25a66db28e67..24ad1eb170a8 100644 --- a/src/Network/NWEndpoint.cs +++ b/src/Network/NWEndpoint.cs @@ -16,8 +16,8 @@ using Foundation; using CoreFoundation; -using OS_nw_endpoint=System.IntPtr; -using OS_nw_txt_record=System.IntPtr; +using OS_nw_endpoint = System.IntPtr; +using OS_nw_txt_record = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -31,10 +31,10 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWEndpoint : NativeObject { @@ -42,7 +42,7 @@ public class NWEndpoint : NativeObject { #if NET internal NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -133,9 +133,9 @@ public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] static extern OS_nw_endpoint nw_endpoint_create_url (string url); @@ -146,9 +146,9 @@ public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public static NWEndpoint? Create (string url) { @@ -166,9 +166,9 @@ public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr nw_endpoint_get_url (OS_nw_endpoint endpoint); @@ -179,9 +179,9 @@ public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public string? Url => Marshal.PtrToStringAnsi (nw_endpoint_get_url (GetCheckedHandle ())); @@ -192,10 +192,10 @@ public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern unsafe byte* nw_endpoint_get_signature (OS_nw_endpoint endpoint, out nuint out_signature_length); @@ -206,16 +206,16 @@ public NWEndpoint (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public ReadOnlySpan Signature { get { unsafe { var data = nw_endpoint_get_signature (GetCheckedHandle (), out var length); - var mValue = new ReadOnlySpan (data, (int)length); + var mValue = new ReadOnlySpan (data, (int) length); // we do not know who manages the byte array, so we return a copy, is more expensive but // safer until we know what is the mem management. return new ReadOnlySpan (mValue.ToArray ()); @@ -229,10 +229,10 @@ public ReadOnlySpan Signature { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_txt_record nw_endpoint_copy_txt_record (OS_nw_endpoint endpoint); @@ -243,10 +243,10 @@ public ReadOnlySpan Signature { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public NWTxtRecord? TxtRecord { get { diff --git a/src/Network/NWEnums.cs b/src/Network/NWEnums.cs index dc051d640ead..9c4da0cf61df 100644 --- a/src/Network/NWEnums.cs +++ b/src/Network/NWEnums.cs @@ -15,24 +15,24 @@ using Foundation; using CoreFoundation; -using OS_nw_browse_result=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; -using OS_nw_txt_record=System.IntPtr; +using OS_nw_browse_result = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; +using OS_nw_txt_record = System.IntPtr; namespace Network { - [Flags, TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [Flags, TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWBrowseResultChange : ulong { Invalid = 0x00, Identical = 0x01, ResultAdded = 0x02, ResultRemoved = 0x04, TxtRecordChanged = 0x20, - InterfaceAdded = 0x08, + InterfaceAdded = 0x08, InterfaceRemoved = 0x10, } - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWBrowserState { Invalid = 0, Ready = 1, @@ -40,19 +40,19 @@ public enum NWBrowserState { Cancelled = 3, } - [TV (12,0), Mac (10,14), iOS (12,0)] - [Watch (6,0)] + [TV (12, 0), Mac (10, 14), iOS (12, 0)] + [Watch (6, 0)] public enum NWConnectionState { - Invalid = 0, - Waiting = 1, + Invalid = 0, + Waiting = 1, Preparing = 2, - Ready = 3, - Failed = 4, + Ready = 3, + Failed = 4, Cancelled = 5, } - [TV (14,0), Mac (11,0), iOS (14,0), Watch (7,0)] - [MacCatalyst (14,0)] + [TV (14, 0), Mac (11, 0), iOS (14, 0), Watch (7, 0)] + [MacCatalyst (14, 0)] public enum NWConnectionGroupState { Invalid = 0, Waiting = 1, @@ -61,31 +61,31 @@ public enum NWConnectionGroupState { Cancelled = 4, } - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWDataTransferReportState { Collecting = 1, Collected = 2, } - [TV (12,0), Mac (10,14), iOS (12,0)] - [Watch (6,0)] + [TV (12, 0), Mac (10, 14), iOS (12, 0)] + [Watch (6, 0)] public enum NWEndpointType { Invalid = 0, Address = 1, Host = 2, BonjourService = 3, - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] Url = 4, } - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWReportResolutionSource { Query = 1, Cache = 2, ExpiredCache = 3, } - [NoWatch, NoTV, NoiOS, Mac (10,15)] + [NoWatch, NoTV, NoiOS, Mac (10, 15)] public enum NWEthernetChannelState { Invalid = 0, Waiting = 1, @@ -97,35 +97,35 @@ public enum NWEthernetChannelState { // from System/Library/Frameworks/Network.framework/Headers/framer_options.h: [Flags] - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWFramerCreateFlags : uint { Default = 0x00, } // from System/Library/Frameworks/Network.framework/Headers/framer_options.h: - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWFramerStartResult { Unknown = 0, Ready = 1, WillMarkReady = 2, } - [Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)] + [Watch (6, 0), TV (13, 0), Mac (10, 15), iOS (13, 0)] public enum NWIPLocalAddressPreference { Default = 0, Temporary = 1, Stable = 2, } - [Watch (6,0), TV (12,0), Mac (10,14), iOS (12,0)] + [Watch (6, 0), TV (12, 0), Mac (10, 14), iOS (12, 0)] public enum NWIPVersion { Any = 0, Version4 = 1, Version6 = 2, } - [TV (12,0), Mac (10,14), iOS (12,0)] - [Watch (6,0)] + [TV (12, 0), Mac (10, 14), iOS (12, 0)] + [Watch (6, 0)] public enum NWInterfaceType { Other = 0, Wifi = 1, @@ -134,8 +134,8 @@ public enum NWInterfaceType { Loopback = 4, } - [TV (12,0), Mac (10,14), iOS (12,0)] - [Watch (6,0)] + [TV (12, 0), Mac (10, 14), iOS (12, 0)] + [Watch (6, 0)] public enum NWListenerState { Invalid = 0, Waiting = 1, @@ -144,17 +144,17 @@ public enum NWListenerState { Cancelled = 4, } - [TV (12,0), Mac (10,14), iOS (12,0)] - [Watch (6,0)] + [TV (12, 0), Mac (10, 14), iOS (12, 0)] + [Watch (6, 0)] public enum NWMultiPathService { Disabled = 0, Handover = 1, Interactive = 2, - Aggregate = 3, + Aggregate = 3, } - [TV (12,0), Mac (10,14), iOS (12,0)] - [Watch (6,0)] + [TV (12, 0), Mac (10, 14), iOS (12, 0)] + [Watch (6, 0)] public enum NWParametersExpiredDnsBehavior { Default = 0, Allow = 1, @@ -162,8 +162,8 @@ public enum NWParametersExpiredDnsBehavior { } // this maps to `nw_path_status_t` in Network/Headers/path.h (and not the enum from NetworkExtension) - [TV (12,0), Mac (10,14), iOS (12,0)] - [Watch (6,0)] + [TV (12, 0), Mac (10, 14), iOS (12, 0)] + [Watch (6, 0)] public enum NWPathStatus { Invalid = 0, Satisfied = 1, @@ -187,7 +187,7 @@ public enum NWIPEcnFlag { Ce = 3, } - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWTxtRecordFindKey { Invalid = 0, NotPresent = 1, @@ -196,7 +196,7 @@ public enum NWTxtRecordFindKey { NonEmptyValue = 4, } - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWWebSocketOpCode : int { Cont = 0x0, Text = 0x1, @@ -207,7 +207,7 @@ public enum NWWebSocketOpCode : int { Invalid = -1, } - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWWebSocketCloseCode : int { NormalClosure = 1000, GoingAway = 1001, @@ -224,20 +224,20 @@ public enum NWWebSocketCloseCode : int { } // this maps to `nw_ws_version_t` in Network.framework/Headers/ws_options.h (and not the enum from NetworkExtension) - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWWebSocketVersion { Invalid = 0, Version13 = 1, } - [TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)] + [TV (13, 0), Mac (10, 15), iOS (13, 0), Watch (6, 0)] public enum NWWebSocketResponseStatus { Invalid = 0, Accept = 1, Reject = 2, } - [TV (15,0), Mac (12,0), iOS (15,0), Watch (8,0), MacCatalyst (15,0)] + [TV (15, 0), Mac (12, 0), iOS (15, 0), Watch (8, 0), MacCatalyst (15, 0)] public enum NWReportResolutionProtocol { Unknown = 0, Udp = 1, @@ -245,8 +245,8 @@ public enum NWReportResolutionProtocol { Tls = 3, Https = 4, } - - [Watch (7,0), TV (14,0), Mac (11,0), iOS (14,0)] + + [Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0)] public enum NWResolverConfigEndpointType { Https, Tls, @@ -268,7 +268,7 @@ public enum NWInterfaceRadioType { WifiN = 4, WifiAC = 5, WifiAX = 6, - + CellLte = 0x80, CellEndcSub6 = 0x81, CellEndcMmw = 0x82, @@ -279,14 +279,14 @@ public enum NWInterfaceRadioType { CellCdma = 0x87, CellEvdo = 0x88, } - - [Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0)] + + [Watch (8, 0), TV (15, 0), Mac (12, 0), iOS (15, 0)] public enum NWParametersAttribution { Developer = 1, User = 2, } - [Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)] + [Watch (8, 0), TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15, 0)] public enum NWQuicStreamType { Unknown = 0, Bidirectional = 1, diff --git a/src/Network/NWError.cs b/src/Network/NWError.cs index d40f41b2feb4..97e51a1a56ee 100644 --- a/src/Network/NWError.cs +++ b/src/Network/NWError.cs @@ -27,10 +27,10 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWError : NativeObject { [Preserve (Conditional = true)] diff --git a/src/Network/NWEstablishmentReport.cs b/src/Network/NWEstablishmentReport.cs index 849bda5126ed..80d232110bda 100644 --- a/src/Network/NWEstablishmentReport.cs +++ b/src/Network/NWEstablishmentReport.cs @@ -17,11 +17,11 @@ using Foundation; using CoreFoundation; -using OS_nw_establishment_report=System.IntPtr; -using nw_endpoint_t=System.IntPtr; -using nw_report_protocol_enumerator_t=System.IntPtr; -using nw_protocol_definition_t=System.IntPtr; -using nw_resolution_report_t=System.IntPtr; +using OS_nw_establishment_report = System.IntPtr; +using nw_endpoint_t = System.IntPtr; +using nw_report_protocol_enumerator_t = System.IntPtr; +using nw_protocol_definition_t = System.IntPtr; +using nw_resolution_report_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -35,15 +35,15 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWEstablishmentReport : NativeObject { [Preserve (Conditional = true)] - internal NWEstablishmentReport (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWEstablishmentReport (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -85,7 +85,7 @@ static void TrampolineResolutionEnumeratorHandler (IntPtr block, NWReportResolut if (del is not null) { using (var nwSuccesfulEndpoint = new NWEndpoint (successful_endpoint, owns: false)) using (var nwPreferredEndpoint = new NWEndpoint (preferred_endpoint, owns: false)) - del (source,TimeSpan.FromMilliseconds (milliseconds), endpoint_count, nwSuccesfulEndpoint, nwPreferredEndpoint); + del (source, TimeSpan.FromMilliseconds (milliseconds), endpoint_count, nwSuccesfulEndpoint, nwPreferredEndpoint); } } @@ -116,14 +116,14 @@ static void TrampolineEnumerateProtocolsHandler (IntPtr block, nw_protocol_defin var del = BlockLiteral.GetTarget> (block); if (del is not null) { using (var nwProtocolDefinition = new NWProtocolDefinition (protocol, owns: false)) - del (nwProtocolDefinition, TimeSpan.FromMilliseconds (handshake_milliseconds), TimeSpan.FromMilliseconds (handshake_rtt_milliseconds)); + del (nwProtocolDefinition, TimeSpan.FromMilliseconds (handshake_milliseconds), TimeSpan.FromMilliseconds (handshake_rtt_milliseconds)); } } [BindingImpl (BindingImplOptions.Optimizable)] public void EnumerateProtocols (Action handler) { - if (handler is null) + if (handler is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (handler)); BlockLiteral block_handler = new BlockLiteral (); @@ -141,25 +141,25 @@ public void EnumerateProtocols (Action public NWEndpoint? ProxyEndpoint { get { var ptr = nw_establishment_report_copy_proxy_endpoint (GetCheckedHandle ()); - return (ptr == IntPtr.Zero) ? null : new NWEndpoint (ptr, owns:true); + return (ptr == IntPtr.Zero) ? null : new NWEndpoint (ptr, owns: true); } } - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_establishment_report_enumerate_resolution_reports (OS_nw_establishment_report report, ref BlockLiteral enumerateBlock); - + delegate void nw_report_resolution_report_enumerator_t (IntPtr block, nw_resolution_report_t report); static nw_report_resolution_report_enumerator_t static_EnumerateResolutionReport = TrampolineEnumerateResolutionReport; @@ -179,16 +179,16 @@ static void TrampolineEnumerateResolutionReport (IntPtr block, nw_resolution_rep [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [BindingImpl (BindingImplOptions.Optimizable)] public void EnumerateResolutionReports (Action handler) { - if (handler is null) + if (handler is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (handler)); BlockLiteral blockHandler = new (); diff --git a/src/Network/NWFramer.cs b/src/Network/NWFramer.cs index decf989cb2d7..bf49dd8b1f68 100644 --- a/src/Network/NWFramer.cs +++ b/src/Network/NWFramer.cs @@ -16,13 +16,13 @@ using Foundation; using CoreFoundation; -using OS_nw_framer=System.IntPtr; -using OS_nw_protocol_metadata=System.IntPtr; -using OS_dispatch_data=System.IntPtr; -using OS_nw_protocol_definition=System.IntPtr; -using OS_nw_protocol_options=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; -using OS_nw_parameters=System.IntPtr; +using OS_nw_framer = System.IntPtr; +using OS_nw_protocol_metadata = System.IntPtr; +using OS_dispatch_data = System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using OS_nw_protocol_options = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; +using OS_nw_parameters = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -31,7 +31,7 @@ namespace Network { public delegate nuint NWFramerParseCompletionDelegate (Memory buffer, [MarshalAs (UnmanagedType.I1)] bool isCompleted); - public delegate nuint NWFramerInputDelegate (NWFramer framer); + public delegate nuint NWFramerInputDelegate (NWFramer framer); #if NET [SupportedOSPlatform ("tvos13.0")] @@ -39,14 +39,14 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWFramer : NativeObject { [Preserve (Conditional = true)] - internal NWFramer (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWFramer (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -65,18 +65,18 @@ public void WriteOutput (DispatchData data) } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_write_output (OS_nw_framer framer, byte *output_buffer, nuint output_length); + unsafe static extern void nw_framer_write_output (OS_nw_framer framer, byte* output_buffer, nuint output_length); public void WriteOutput (ReadOnlySpan data) { unsafe { - fixed (byte *mh = data) + fixed (byte* mh = data) nw_framer_write_output (GetCheckedHandle (), mh, (nuint) data.Length); } } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_set_wakeup_handler (OS_nw_framer framer, void *wakeup_handler); + unsafe static extern void nw_framer_set_wakeup_handler (OS_nw_framer framer, void* wakeup_handler); delegate void nw_framer_set_wakeup_handler_t (IntPtr block, OS_nw_framer framer); static nw_framer_set_wakeup_handler_t static_WakeupHandler = TrampolineWakeupHandler; @@ -100,7 +100,7 @@ public Action WakeupHandler { return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_WakeupHandler, value); try { nw_framer_set_wakeup_handler (GetCheckedHandle (), (void*) block_ptr_handler); @@ -112,7 +112,7 @@ public Action WakeupHandler { } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_set_stop_handler (OS_nw_framer framer, void *stop_handler); + unsafe static extern void nw_framer_set_stop_handler (OS_nw_framer framer, void* stop_handler); delegate void nw_framer_set_stop_handler_t (IntPtr block, OS_nw_framer framer); static nw_framer_set_stop_handler_t static_StopHandler = TrampolineStopHandler; @@ -136,7 +136,7 @@ public Action StopHandler { return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_StopHandler, value); try { nw_framer_set_stop_handler (GetCheckedHandle (), (void*) block_ptr_handler); @@ -148,7 +148,7 @@ public Action StopHandler { } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_set_output_handler (OS_nw_framer framer, void *output_handler); + unsafe static extern void nw_framer_set_output_handler (OS_nw_framer framer, void* output_handler); delegate void nw_framer_set_output_handler_t (IntPtr block, OS_nw_framer framer, OS_nw_protocol_metadata message, nuint message_length, bool is_complete); static nw_framer_set_output_handler_t static_OutputHandler = TrampolineOutputHandler; @@ -163,7 +163,7 @@ static void TrampolineOutputHandler (IntPtr block, OS_nw_framer framer, OS_nw_pr del (nwFramer, nwProtocolMetadata, message_length, is_complete); } } - + [BindingImpl (BindingImplOptions.Optimizable)] public Action OutputHandler { set { @@ -173,7 +173,7 @@ public Action OutputHandler { return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_OutputHandler, value); try { nw_framer_set_output_handler (GetCheckedHandle (), (void*) block_ptr_handler); @@ -185,7 +185,7 @@ public Action OutputHandler { } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_set_input_handler (OS_nw_framer framer, void *input_handler); + unsafe static extern void nw_framer_set_input_handler (OS_nw_framer framer, void* input_handler); delegate nuint nw_framer_set_input_handler_t (IntPtr block, OS_nw_framer framer); static nw_framer_set_input_handler_t static_InputHandler = TrampolineInputHandler; @@ -210,7 +210,7 @@ public NWFramerInputDelegate InputHandler { return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_InputHandler, value); try { nw_framer_set_input_handler (GetCheckedHandle (), (void*) block_ptr_handler); @@ -222,7 +222,7 @@ public NWFramerInputDelegate InputHandler { } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_set_cleanup_handler (OS_nw_framer framer, void *cleanup_handler); + unsafe static extern void nw_framer_set_cleanup_handler (OS_nw_framer framer, void* cleanup_handler); delegate void nw_framer_set_cleanup_handler_t (IntPtr block, OS_nw_framer framer); static nw_framer_set_cleanup_handler_t static_CleanupHandler = TrampolineCleanupHandler; @@ -246,7 +246,7 @@ public Action CleanupHandler { return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_InputHandler, value); try { nw_framer_set_cleanup_handler (GetCheckedHandle (), (void*) block_ptr_handler); @@ -282,22 +282,22 @@ public bool PrependApplicationProtocol (NWProtocolOptions options) [DllImport (Constants.NetworkLibrary)] static extern void nw_framer_pass_through_output (OS_nw_framer framer); - public void PassThroughOutput () => nw_framer_pass_through_output (GetCheckedHandle ()); + public void PassThroughOutput () => nw_framer_pass_through_output (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern void nw_framer_pass_through_input (OS_nw_framer framer); - public void PassThroughInput () => nw_framer_pass_through_input (GetCheckedHandle ()); + public void PassThroughInput () => nw_framer_pass_through_input (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern void nw_framer_mark_ready (OS_nw_framer framer); - public void MarkReady () => nw_framer_mark_ready (GetCheckedHandle ()); + public void MarkReady () => nw_framer_mark_ready (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern void nw_framer_mark_failed_with_error (OS_nw_framer framer, int error_code); - public void MarkFailedWithError (int errorCode) => nw_framer_mark_failed_with_error (GetCheckedHandle (), errorCode); + public void MarkFailedWithError (int errorCode) => nw_framer_mark_failed_with_error (GetCheckedHandle (), errorCode); [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -313,7 +313,7 @@ public bool DeliverInputNoCopy (nuint length, NWFramerMessage message, bool isCo [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_options nw_framer_create_options (OS_nw_protocol_definition framer_definition); - public static T? CreateOptions (NWProtocolDefinition protocolDefinition) where T: NWProtocolOptions + public static T? CreateOptions (NWProtocolDefinition protocolDefinition) where T : NWProtocolOptions { if (protocolDefinition is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (protocolDefinition)); @@ -337,13 +337,13 @@ public bool DeliverInputNoCopy (nuint length, NWFramerMessage message, bool isCo public NWEndpoint LocalEndpoint => new NWEndpoint (nw_framer_copy_local_endpoint (GetCheckedHandle ()), owns: true); [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_async (OS_nw_framer framer, void *async_block); + unsafe static extern void nw_framer_async (OS_nw_framer framer, void* async_block); delegate void nw_framer_async_t (IntPtr block); static nw_framer_async_t static_ScheduleHandler = TrampolineScheduleHandler; [MonoPInvokeCallback (typeof (nw_framer_async_t))] - static void TrampolineScheduleHandler (IntPtr block) + static void TrampolineScheduleHandler (IntPtr block) { var del = BlockLiteral.GetTarget (block); if (del is not null) { @@ -360,7 +360,7 @@ public void ScheduleAsync (Action handler) return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_ScheduleHandler, handler); try { nw_framer_async (GetCheckedHandle (), (void*) block_ptr_handler); @@ -372,7 +372,7 @@ public void ScheduleAsync (Action handler) [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] - static extern unsafe bool nw_framer_parse_output (OS_nw_framer framer, nuint minimum_incomplete_length, nuint maximum_length, byte *temp_buffer, ref BlockLiteral parse); + static extern unsafe bool nw_framer_parse_output (OS_nw_framer framer, nuint minimum_incomplete_length, nuint maximum_length, byte* temp_buffer, ref BlockLiteral parse); delegate void nw_framer_parse_output_t (IntPtr block, IntPtr buffer, nuint buffer_length, bool is_complete); static nw_framer_parse_output_t static_ParseOutputHandler = TrampolineParseOutputHandler; @@ -382,9 +382,9 @@ static void TrampolineParseOutputHandler (IntPtr block, IntPtr buffer, nuint buf { var del = BlockLiteral.GetTarget, bool>> (block); if (del is not null) { - var bBuffer = new byte[buffer_length]; - Marshal.Copy (buffer, bBuffer, 0, (int)buffer_length); - var mValue = new Memory(bBuffer); + var bBuffer = new byte [buffer_length]; + Marshal.Copy (buffer, bBuffer, 0, (int) buffer_length); + var mValue = new Memory (bBuffer); del (mValue, is_complete); } } @@ -399,7 +399,7 @@ public bool ParseOutput (nuint minimumIncompleteLength, nuint maximumLength, Mem block_handler.SetupBlockUnsafe (static_ParseOutputHandler, handler); try { using (var mh = tempBuffer.Pin ()) - return nw_framer_parse_output (GetCheckedHandle (), minimumIncompleteLength, maximumLength, (byte*)mh.Pointer, ref block_handler); + return nw_framer_parse_output (GetCheckedHandle (), minimumIncompleteLength, maximumLength, (byte*) mh.Pointer, ref block_handler); } finally { block_handler.CleanupBlock (); } @@ -408,7 +408,7 @@ public bool ParseOutput (nuint minimumIncompleteLength, nuint maximumLength, Mem [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] - static extern unsafe bool nw_framer_parse_input (OS_nw_framer framer, nuint minimum_incomplete_length, nuint maximum_length, byte *temp_buffer, ref BlockLiteral parse); + static extern unsafe bool nw_framer_parse_input (OS_nw_framer framer, nuint minimum_incomplete_length, nuint maximum_length, byte* temp_buffer, ref BlockLiteral parse); delegate nuint nw_framer_parse_input_t (IntPtr block, IntPtr buffer, nuint buffer_length, bool is_complete); static nw_framer_parse_input_t static_ParseInputHandler = TrampolineParseInputHandler; @@ -418,9 +418,9 @@ static nuint TrampolineParseInputHandler (IntPtr block, IntPtr buffer, nuint buf { var del = BlockLiteral.GetTarget (block); if (del is not null) { - var bBuffer = new byte[buffer_length]; - Marshal.Copy (buffer, bBuffer, 0, (int)buffer_length); - var mValue = new Memory(bBuffer); + var bBuffer = new byte [buffer_length]; + Marshal.Copy (buffer, bBuffer, 0, (int) buffer_length); + var mValue = new Memory (bBuffer); return del (mValue, is_complete); } return 0; @@ -436,7 +436,7 @@ public bool ParseInput (nuint minimumIncompleteLength, nuint maximumLength, Memo block_handler.SetupBlockUnsafe (static_ParseInputHandler, handler); try { using (var mh = tempBuffer.Pin ()) - return nw_framer_parse_input (GetCheckedHandle (), minimumIncompleteLength, maximumLength, (byte*)mh.Pointer, ref block_handler); + return nw_framer_parse_input (GetCheckedHandle (), minimumIncompleteLength, maximumLength, (byte*) mh.Pointer, ref block_handler); } finally { block_handler.CleanupBlock (); } @@ -444,15 +444,15 @@ public bool ParseInput (nuint minimumIncompleteLength, nuint maximumLength, Memo } [DllImport (Constants.NetworkLibrary)] - unsafe static extern void nw_framer_deliver_input (OS_nw_framer framer, byte *input_buffer, nuint input_length, OS_nw_protocol_metadata message, [MarshalAs (UnmanagedType.I1)] bool is_complete); + unsafe static extern void nw_framer_deliver_input (OS_nw_framer framer, byte* input_buffer, nuint input_length, OS_nw_protocol_metadata message, [MarshalAs (UnmanagedType.I1)] bool is_complete); public void DeliverInput (ReadOnlySpan buffer, NWFramerMessage message, bool isComplete) { if (message is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (message)); unsafe { - fixed (byte *mh = buffer) - nw_framer_deliver_input (GetCheckedHandle (),mh, (nuint)buffer.Length, message.Handle, isComplete); + fixed (byte* mh = buffer) + nw_framer_deliver_input (GetCheckedHandle (), mh, (nuint) buffer.Length, message.Handle, isComplete); } } @@ -462,11 +462,11 @@ public void DeliverInput (ReadOnlySpan buffer, NWFramerMessage message, bo [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [MacCatalyst (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [MacCatalyst (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_options nw_framer_copy_options (OS_nw_framer framer); @@ -477,11 +477,11 @@ public void DeliverInput (ReadOnlySpan buffer, NWFramerMessage message, bo [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [MacCatalyst (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [MacCatalyst (16, 0)] + [Watch (9, 0)] #endif public NSProtocolFramerOptions? ProtocolOptions { get { diff --git a/src/Network/NWFramerMessage.cs b/src/Network/NWFramerMessage.cs index 92f134fa2bd2..ac64032efa1c 100644 --- a/src/Network/NWFramerMessage.cs +++ b/src/Network/NWFramerMessage.cs @@ -16,13 +16,13 @@ using Foundation; using CoreFoundation; -using OS_nw_framer=System.IntPtr; -using OS_nw_protocol_metadata=System.IntPtr; -using OS_dispatch_data=System.IntPtr; -using OS_nw_protocol_definition=System.IntPtr; -using OS_nw_protocol_options=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; -using OS_nw_parameters=System.IntPtr; +using OS_nw_framer = System.IntPtr; +using OS_nw_protocol_metadata = System.IntPtr; +using OS_dispatch_data = System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using OS_nw_protocol_options = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; +using OS_nw_parameters = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -36,14 +36,14 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWFramerMessage : NWProtocolMetadata { [Preserve (Conditional = true)] - internal NWFramerMessage (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWFramerMessage (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_metadata nw_framer_protocol_create_message (OS_nw_protocol_definition definition); @@ -74,7 +74,7 @@ static void TrampolineSetDataHandler (IntPtr block, IntPtr data) } [BindingImpl (BindingImplOptions.Optimizable)] - public void SetData (string key, byte[] value) + public void SetData (string key, byte [] value) { // the method takes a callback to cleanup the data, but we do not need that since we are managed if (key is null) @@ -88,7 +88,7 @@ public void SetData (string key, byte[] value) BlockLiteral block_handler = new BlockLiteral (); block_handler.SetupBlockUnsafe (static_SetDataHandler, callback); try { - nw_framer_message_set_value (GetCheckedHandle (), key, pinned.AddrOfPinnedObject (), ref block_handler); + nw_framer_message_set_value (GetCheckedHandle (), key, pinned.AddrOfPinnedObject (), ref block_handler); } finally { block_handler.CleanupBlock (); } @@ -113,17 +113,18 @@ static bool TrampolineAccessValueHandler (IntPtr block, IntPtr data) } [BindingImpl (BindingImplOptions.Optimizable)] - public bool GetData (string key, int dataLength, out ReadOnlySpan outData) { + public bool GetData (string key, int dataLength, out ReadOnlySpan outData) + { IntPtr outPointer = IntPtr.Zero; // create a function that will get the data, and the data length passed and will set the out param returning the value Func callback = (inData) => { if (inData != IntPtr.Zero) { - outPointer = inData; + outPointer = inData; return true; } else { return false; } - }; + }; BlockLiteral block_handler = new BlockLiteral (); block_handler.SetupBlockUnsafe (static_AccessValueHandler, callback); @@ -132,10 +133,10 @@ public bool GetData (string key, int dataLength, out ReadOnlySpan outData) var found = nw_framer_message_access_value (GetCheckedHandle (), key, ref block_handler); if (found) { unsafe { - outData = new ReadOnlySpan((void*) outPointer, dataLength); + outData = new ReadOnlySpan ((void*) outPointer, dataLength); } } else { - outData = ReadOnlySpan.Empty; + outData = ReadOnlySpan.Empty; } return found; } finally { @@ -147,7 +148,7 @@ public bool GetData (string key, int dataLength, out ReadOnlySpan outData) static extern void nw_framer_message_set_object_value (OS_nw_protocol_metadata message, string key, IntPtr value); public void SetObject (string key, NSObject value) - => nw_framer_message_set_object_value (GetCheckedHandle (), key, value.GetHandle ()); + => nw_framer_message_set_object_value (GetCheckedHandle (), key, value.GetHandle ()); [DllImport (Constants.NetworkLibrary)] static extern IntPtr nw_framer_message_copy_object_value (OS_nw_protocol_metadata message, string key); diff --git a/src/Network/NWIPMetadata.cs b/src/Network/NWIPMetadata.cs index 2621dd4dc6a9..83519df5604d 100644 --- a/src/Network/NWIPMetadata.cs +++ b/src/Network/NWIPMetadata.cs @@ -26,17 +26,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWIPMetadata : NWProtocolMetadata { [Preserve (Conditional = true)] - internal NWIPMetadata (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWIPMetadata (NativeHandle handle, bool owns) : base (handle, owns) { } - public NWIPMetadata () : this (nw_ip_create_metadata (), owns: true) {} + public NWIPMetadata () : this (nw_ip_create_metadata (), owns: true) { } public NWIPEcnFlag EcnFlag { get => nw_ip_metadata_get_ecn_flag (GetCheckedHandle ()); diff --git a/src/Network/NWInterface.cs b/src/Network/NWInterface.cs index e73c0eaf32ec..f81a583a3acd 100644 --- a/src/Network/NWInterface.cs +++ b/src/Network/NWInterface.cs @@ -16,7 +16,7 @@ using Foundation; using CoreFoundation; -using OS_nw_interface=System.IntPtr; +using OS_nw_interface = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -30,17 +30,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWInterface : NativeObject { [Preserve (Conditional = true)] #if NET internal NWInterface (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWInterface (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWInterface (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] diff --git a/src/Network/NWListener.cs b/src/Network/NWListener.cs index 3aef33d4a318..4649384be235 100644 --- a/src/Network/NWListener.cs +++ b/src/Network/NWListener.cs @@ -15,7 +15,7 @@ using Foundation; using CoreFoundation; -using nw_connection_group_t=System.IntPtr; +using nw_connection_group_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -29,10 +29,10 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWListener : NativeObject { bool connectionHandlerWasSet = false; @@ -115,7 +115,8 @@ public void SetQueue (DispatchQueue queue) [DllImport (Constants.NetworkLibrary)] extern static void nw_listener_start (IntPtr handle); - public void Start () { + public void Start () + { lock (connectionHandlerLock) { // we will get a sigabort if the handler is not set, lets be nicer. if (!connectionHandlerWasSet) @@ -133,10 +134,10 @@ public void Start () { static nw_listener_state_changed_handler_t static_ListenerStateChanged = TrampolineListenerStateChanged; [MonoPInvokeCallback (typeof (nw_listener_state_changed_handler_t))] - static void TrampolineListenerStateChanged (IntPtr block, NWListenerState state, IntPtr nwerror) + static void TrampolineListenerStateChanged (IntPtr block, NWListenerState state, IntPtr nwerror) { - var del = BlockLiteral.GetTarget> (block); - if (del is not null){ + var del = BlockLiteral.GetTarget> (block); + if (del is not null) { NWError? err = nwerror == IntPtr.Zero ? null : new NWError (nwerror, owns: false); del (state, err); err?.Dispose (); @@ -144,19 +145,19 @@ static void TrampolineListenerStateChanged (IntPtr block, NWListenerState state, } [DllImport (Constants.NetworkLibrary)] - static extern unsafe void nw_listener_set_state_changed_handler (IntPtr handle, void *callback); + static extern unsafe void nw_listener_set_state_changed_handler (IntPtr handle, void* callback); [BindingImpl (BindingImplOptions.Optimizable)] - public void SetStateChangedHandler (Action callback) + public void SetStateChangedHandler (Action callback) { unsafe { - if (callback is null){ + if (callback is null) { nw_listener_set_state_changed_handler (GetCheckedHandle (), null); return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_ListenerStateChanged, callback); try { @@ -174,14 +175,14 @@ public void SetStateChangedHandler (Action callback) static void TrampolineNewConnection (IntPtr block, IntPtr connection) { var del = BlockLiteral.GetTarget> (block); - if (del is not null){ + if (del is not null) { var nwconnection = new NWConnection (connection, owns: false); del (nwconnection); } } [DllImport (Constants.NetworkLibrary)] - static extern unsafe void nw_listener_set_new_connection_handler (IntPtr handle, void *callback); + static extern unsafe void nw_listener_set_new_connection_handler (IntPtr handle, void* callback); [BindingImpl (BindingImplOptions.Optimizable)] public void SetNewConnectionHandler (Action callback) @@ -194,7 +195,7 @@ public void SetNewConnectionHandler (Action callback) } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_NewConnection, callback); try { @@ -223,19 +224,19 @@ static void TrampolineAdvertisedEndpointChangedHandler (IntPtr block, IntPtr end } [DllImport (Constants.NetworkLibrary)] - static extern unsafe void nw_listener_set_advertised_endpoint_changed_handler (IntPtr handle, void *callback); + static extern unsafe void nw_listener_set_advertised_endpoint_changed_handler (IntPtr handle, void* callback); [BindingImpl (BindingImplOptions.Optimizable)] public void SetAdvertisedEndpointChangedHandler (AdvertisedEndpointChanged callback) { unsafe { - if (callback is null){ + if (callback is null) { nw_listener_set_advertised_endpoint_changed_handler (GetCheckedHandle (), null); return; } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_AdvertisedEndpointChangedHandler, callback); try { @@ -260,9 +261,9 @@ public void SetAdvertiseDescriptor (NWAdvertiseDescriptor descriptor) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern uint nw_listener_get_new_connection_limit (IntPtr listener); @@ -273,9 +274,9 @@ public void SetAdvertiseDescriptor (NWAdvertiseDescriptor descriptor) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_listener_set_new_connection_limit (IntPtr listener, uint new_connection_limit); @@ -286,30 +287,30 @@ public void SetAdvertiseDescriptor (NWAdvertiseDescriptor descriptor) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public uint ConnectionLimit { get => nw_listener_get_new_connection_limit (GetCheckedHandle ()); set => nw_listener_set_new_connection_limit (GetCheckedHandle (), value); } - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_listener_set_new_connection_group_handler (IntPtr listener, /* [NullAllowed] */ ref BlockLiteral handler); - + delegate void nw_listener_new_connection_group_handler_t (IntPtr block, nw_connection_group_t group); static nw_listener_new_connection_group_handler_t static_NewConnectionGroup = TrampolineNewConnectionGroup; @@ -329,11 +330,11 @@ static void TrampolineNewConnectionGroup (IntPtr block, nw_connection_group_t co [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [BindingImpl (BindingImplOptions.Optimizable)] public void SetNewConnectionGroupHandler (Action handler) diff --git a/src/Network/NWMulticastGroup.cs b/src/Network/NWMulticastGroup.cs index 47af8a6b4e71..65b2f5df8b9e 100644 --- a/src/Network/NWMulticastGroup.cs +++ b/src/Network/NWMulticastGroup.cs @@ -3,8 +3,8 @@ using ObjCRuntime; using Foundation; using CoreFoundation; -using OS_nw_group_descriptor=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; +using OS_nw_group_descriptor = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -20,15 +20,15 @@ namespace Network { [SupportedOSPlatform ("ios14.0")] [SupportedOSPlatform ("maccatalyst14.0")] #else - [TV (14,0)] - [Mac (11,0)] - [iOS (14,0)] - [Watch (7,0)] - [MacCatalyst (14,0)] + [TV (14, 0)] + [Mac (11, 0)] + [iOS (14, 0)] + [Watch (7, 0)] + [MacCatalyst (14, 0)] #endif public class NWMulticastGroup : NativeObject { [Preserve (Conditional = true)] - internal NWMulticastGroup (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWMulticastGroup (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern OS_nw_group_descriptor nw_group_descriptor_create_multicast (OS_nw_endpoint multicast_group); @@ -61,8 +61,8 @@ public void AddEndpoint (NWEndpoint endpoint) public bool DisabledUnicastTraffic { get => nw_multicast_group_descriptor_get_disable_unicast_traffic (GetCheckedHandle ()); - set => nw_multicast_group_descriptor_set_disable_unicast_traffic (GetCheckedHandle (), value); - } + set => nw_multicast_group_descriptor_set_disable_unicast_traffic (GetCheckedHandle (), value); + } [DllImport (Constants.NetworkLibrary)] static extern void nw_multicast_group_descriptor_set_specific_source (OS_nw_group_descriptor multicast_descriptor, OS_nw_endpoint source); @@ -85,7 +85,7 @@ static bool TrampolineEnumerateEndpointsHandler (IntPtr block, OS_nw_endpoint en { var del = BlockLiteral.GetTarget> (block); if (del is not null) { - using var nsEndpoint = new NWEndpoint (endpoint, owns: false); + using var nsEndpoint = new NWEndpoint (endpoint, owns: false); return del (nsEndpoint); } return false; diff --git a/src/Network/NWMultiplexGroup.cs b/src/Network/NWMultiplexGroup.cs index 44aa1c7061db..a7b070f12cde 100644 --- a/src/Network/NWMultiplexGroup.cs +++ b/src/Network/NWMultiplexGroup.cs @@ -3,8 +3,8 @@ using ObjCRuntime; using Foundation; using CoreFoundation; -using OS_nw_group_descriptor=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; +using OS_nw_group_descriptor = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -20,21 +20,21 @@ namespace Network { [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public class NWMultiplexGroup : NWMulticastGroup { [DllImport (Constants.NetworkLibrary)] static extern OS_nw_group_descriptor nw_group_descriptor_create_multiplex (OS_nw_endpoint remoteEndpoint); - + [Preserve (Conditional = true)] - internal NWMultiplexGroup (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWMultiplexGroup (NativeHandle handle, bool owns) : base (handle, owns) { } - public NWMultiplexGroup (NWEndpoint endpoint) - : base (nw_group_descriptor_create_multiplex (endpoint.GetCheckedHandle ()), true) { } + public NWMultiplexGroup (NWEndpoint endpoint) + : base (nw_group_descriptor_create_multiplex (endpoint.GetCheckedHandle ()), true) { } } } diff --git a/src/Network/NWParameters.cs b/src/Network/NWParameters.cs index b6ae6626a437..58c18ed48d01 100644 --- a/src/Network/NWParameters.cs +++ b/src/Network/NWParameters.cs @@ -16,10 +16,10 @@ using ObjCRuntime; using CoreFoundation; -using nw_parameters_t=System.IntPtr; -using OS_nw_parameters=System.IntPtr; -using nw_parameters_attribution_t=System.IntPtr; -using OS_nw_privacy_context=System.IntPtr; +using nw_parameters_t = System.IntPtr; +using OS_nw_parameters = System.IntPtr; +using nw_parameters_attribution_t = System.IntPtr; +using OS_nw_privacy_context = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -33,17 +33,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWParameters : NativeObject { [Preserve (Conditional = true)] #if NET internal NWParameters (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWParameters (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWParameters (NativeHandle handle, bool owns) : base (handle, owns) { } #endif #if NET @@ -52,10 +52,10 @@ public NWParameters (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_parameters nw_parameters_create_application_service (); @@ -66,16 +66,16 @@ public NWParameters (NativeHandle handle, bool owns) : base (handle, owns) {} [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public static NWParameters CreateApplicationService () => new NWParameters (nw_parameters_create_application_service (), true); - static unsafe BlockLiteral *DEFAULT_CONFIGURATION () => (BlockLiteral *) NWParametersConstants._DefaultConfiguration; + static unsafe BlockLiteral* DEFAULT_CONFIGURATION () => (BlockLiteral*) NWParametersConstants._DefaultConfiguration; - static unsafe BlockLiteral *DISABLE_PROTOCOL () => (BlockLiteral *) NWParametersConstants._ProtocolDisable; + static unsafe BlockLiteral* DISABLE_PROTOCOL () => (BlockLiteral*) NWParametersConstants._ProtocolDisable; delegate void nw_parameters_configure_protocol_block_t (IntPtr block, IntPtr iface); static nw_parameters_configure_protocol_block_t static_ConfigureHandler = TrampolineConfigureHandler; @@ -85,7 +85,7 @@ static void TrampolineConfigureHandler (IntPtr block, IntPtr iface) { var del = BlockLiteral.GetTarget> (block); if (del is not null) { - using (var tempOptions = new NWProtocolOptions (iface, owns: false)) + using (var tempOptions = new NWProtocolOptions (iface, owns: false)) using (var definition = tempOptions.ProtocolDefinition) { NWProtocolOptions? castedOptions = null; @@ -99,7 +99,7 @@ static void TrampolineConfigureHandler (IntPtr block, IntPtr iface) castedOptions = new NWProtocolIPOptions (iface, owns: false); } else if (definition.Equals (NWProtocolDefinition.CreateWebSocketDefinition ())) { castedOptions = new NWWebSocketOptions (iface, owns: false); - } + } try { del (castedOptions ?? tempOptions); @@ -111,7 +111,7 @@ static void TrampolineConfigureHandler (IntPtr block, IntPtr iface) } [DllImport (Constants.NetworkLibrary)] - static unsafe extern nw_parameters_t nw_parameters_create_secure_tcp (void *configure_tls, void *configure_tcp); + static unsafe extern nw_parameters_t nw_parameters_create_secure_tcp (void* configure_tls, void* configure_tcp); // // If you pass null, to either configureTls, or configureTcp they will use the default options @@ -168,7 +168,7 @@ public unsafe static NWParameters CreateTcp (Action? configur [DllImport (Constants.NetworkLibrary)] - static extern unsafe nw_parameters_t nw_parameters_create_secure_udp (void *configure_tls, void *configure_tcp); + static extern unsafe nw_parameters_t nw_parameters_create_secure_udp (void* configure_tls, void* configure_tcp); // // If you pass null, to either configureTls, or configureTcp they will use the default options @@ -179,8 +179,8 @@ public unsafe static NWParameters CreateSecureUdp (Action? co var tlsHandler = new BlockLiteral (); var udpHandler = new BlockLiteral (); - BlockLiteral *tlsPtr = &tlsHandler; - BlockLiteral *udpPtr = &udpHandler; + BlockLiteral* tlsPtr = &tlsHandler; + BlockLiteral* udpPtr = &udpHandler; if (configureTls is null) tlsPtr = DEFAULT_CONFIGURATION (); @@ -409,7 +409,7 @@ public void ClearProhibitedInterfaceTypes () [return: MarshalAs (UnmanagedType.I1)] static bool TrampolineIterateProhibitedHandler (IntPtr block, IntPtr iface) { - var del = BlockLiteral.GetTarget> (block); + var del = BlockLiteral.GetTarget> (block); if (del is not null) { var x = new NWInterface (iface, owns: false); var ret = del (x); @@ -423,7 +423,7 @@ static bool TrampolineIterateProhibitedHandler (IntPtr block, IntPtr iface) static extern void nw_parameters_iterate_prohibited_interfaces (nw_parameters_t parameters, ref BlockLiteral callback); [BindingImpl (BindingImplOptions.Optimizable)] - public void IterateProhibitedInterfaces (Func iterationCallback) + public void IterateProhibitedInterfaces (Func iterationCallback) { BlockLiteral block_handler = new BlockLiteral (); block_handler.SetupBlockUnsafe (static_iterateProhibitedHandler, iterationCallback); @@ -442,7 +442,7 @@ public void IterateProhibitedInterfaces (Func iterationCallbac [return: MarshalAs (UnmanagedType.I1)] static bool TrampolineIterateProhibitedTypeHandler (IntPtr block, NWInterfaceType type) { - var del = BlockLiteral.GetTarget> (block); + var del = BlockLiteral.GetTarget> (block); if (del is not null) return del (type); return false; @@ -452,7 +452,7 @@ static bool TrampolineIterateProhibitedTypeHandler (IntPtr block, NWInterfaceTyp static extern void nw_parameters_iterate_prohibited_interface_types (IntPtr handle, ref BlockLiteral callback); [BindingImpl (BindingImplOptions.Optimizable)] - public void IterateProhibitedInterfaces (Func callback) + public void IterateProhibitedInterfaces (Func callback) { BlockLiteral block_handler = new BlockLiteral (); block_handler.SetupBlockUnsafe (static_IterateProhibitedTypeHandler, callback); @@ -550,9 +550,9 @@ public bool IncludePeerToPeer { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -564,9 +564,9 @@ public bool IncludePeerToPeer { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_parameters_set_prohibit_constrained (IntPtr parameters, [MarshalAs (UnmanagedType.I1)] bool prohibit_constrained); @@ -577,9 +577,9 @@ public bool IncludePeerToPeer { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public bool ProhibitConstrained { get => nw_parameters_get_prohibit_constrained (GetCheckedHandle ()); @@ -592,11 +592,11 @@ public bool ProhibitConstrained { [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_parameters_set_attribution (OS_nw_parameters parameters, NWParametersAttribution attribution); @@ -607,11 +607,11 @@ public bool ProhibitConstrained { [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern NWParametersAttribution nw_parameters_get_attribution (OS_nw_parameters parameters); @@ -622,28 +622,28 @@ public bool ProhibitConstrained { [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public NWParametersAttribution Attribution { get => nw_parameters_get_attribution (GetCheckedHandle ()); set => nw_parameters_set_attribution (GetCheckedHandle (), value); } - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_parameters_set_privacy_context (OS_nw_parameters parameters, OS_nw_privacy_context privacy_context); @@ -654,41 +654,41 @@ public NWParametersAttribution Attribution { [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public void SetPrivacyContext (NWPrivacyContext privacyContext) => nw_parameters_set_privacy_context (GetCheckedHandle (), privacyContext.Handle); - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] - static unsafe extern OS_nw_parameters nw_parameters_create_quic (void *configureQuic); - + static unsafe extern OS_nw_parameters nw_parameters_create_quic (void* configureQuic); + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [BindingImpl (BindingImplOptions.Optimizable)] public static NWParameters CreateQuic (Action? configureQuic = null) @@ -717,10 +717,10 @@ public static NWParameters CreateQuic (Action? configureQuic [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [return: MarshalAs (UnmanagedType.I1)] [DllImport (Constants.NetworkLibrary)] @@ -732,10 +732,10 @@ public static NWParameters CreateQuic (Action? configureQuic [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_parameters_set_requires_dnssec_validation (OS_nw_parameters parameters, [MarshalAs (UnmanagedType.I1)] bool requires_dnssec_validation); @@ -746,10 +746,10 @@ public static NWParameters CreateQuic (Action? configureQuic [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public bool RequiresDnssecValidation { get => nw_parameters_requires_dnssec_validation (GetCheckedHandle ()); diff --git a/src/Network/NWPath.cs b/src/Network/NWPath.cs index 8e832f30f89f..80f615512675 100644 --- a/src/Network/NWPath.cs +++ b/src/Network/NWPath.cs @@ -29,17 +29,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWPath : NativeObject { [Preserve (Conditional = true)] #if NET internal NWPath (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWPath (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWPath (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -138,8 +138,7 @@ public void EnumerateInterfaces (Action callback) if (callback is null) return; - Func func = (v) => - { + Func func = (v) => { callback (v); return true; }; @@ -169,9 +168,9 @@ public void EnumerateInterfaces (Func callback) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -183,9 +182,9 @@ public void EnumerateInterfaces (Func callback) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public bool IsConstrained => nw_path_is_constrained (GetCheckedHandle ()); @@ -195,9 +194,9 @@ public void EnumerateInterfaces (Func callback) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_path_enumerate_gateways (IntPtr path, ref BlockLiteral enumerate_block); @@ -224,16 +223,15 @@ static byte TrampolineGatewaysHandler (IntPtr block, IntPtr endpoint) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [Obsolete ("Use the overload that takes a 'Func' instead.")] [EditorBrowsable (EditorBrowsableState.Never)] public void EnumerateGateways (Action callback) { - Func func = (v) => - { + Func func = (v) => { callback (v); return true; }; @@ -247,9 +245,9 @@ public void EnumerateGateways (Action callback) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [BindingImpl (BindingImplOptions.Optimizable)] public void EnumerateGateways (Func callback) @@ -273,11 +271,11 @@ public void EnumerateGateways (Func callback) [SupportedOSPlatform ("macos11.0")] [SupportedOSPlatform ("maccatalyst14.2")] #else - [iOS (14,2)] - [TV (14,2)] - [Watch (7,1)] - [Mac (11,0)] - [MacCatalyst (14,2)] + [iOS (14, 2)] + [TV (14, 2)] + [Watch (7, 1)] + [Mac (11, 0)] + [MacCatalyst (14, 2)] #endif [DllImport (Constants.NetworkLibrary)] static extern NWPathUnsatisfiedReason /* nw_path_unsatisfied_reason_t */ nw_path_get_unsatisfied_reason (IntPtr /* OS_nw_path */ path); @@ -288,11 +286,11 @@ public void EnumerateGateways (Func callback) [SupportedOSPlatform ("macos11.0")] [SupportedOSPlatform ("maccatalyst14.2")] #else - [iOS (14,2)] - [TV (14,2)] - [Watch (7,1)] - [Mac (11,0)] - [MacCatalyst (14,2)] + [iOS (14, 2)] + [TV (14, 2)] + [Watch (7, 1)] + [Mac (11, 0)] + [MacCatalyst (14, 2)] #endif public NWPathUnsatisfiedReason GetUnsatisfiedReason () { diff --git a/src/Network/NWPathMonitor.cs b/src/Network/NWPathMonitor.cs index 33e47d4886fb..0826b5038fb2 100644 --- a/src/Network/NWPathMonitor.cs +++ b/src/Network/NWPathMonitor.cs @@ -16,7 +16,7 @@ using Foundation; using CoreFoundation; -using OS_nw_path_monitor=System.IntPtr; +using OS_nw_path_monitor = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -30,17 +30,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWPathMonitor : NativeObject { [Preserve (Conditional = true)] #if NET internal NWPathMonitor (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWPathMonitor (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWPathMonitor (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -100,7 +100,7 @@ static void TrampolineUpdatedSnapshot (IntPtr block, IntPtr path) } [DllImport (Constants.NetworkLibrary)] - static extern unsafe void nw_path_monitor_set_update_handler (IntPtr handle, void *callback); + static extern unsafe void nw_path_monitor_set_update_handler (IntPtr handle, void* callback); [BindingImpl (BindingImplOptions.Optimizable)] void _SetUpdatedSnapshotHandler (Action callback) @@ -112,7 +112,7 @@ void _SetUpdatedSnapshotHandler (Action callback) } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_UpdateSnapshot, callback); try { @@ -158,7 +158,7 @@ static void TrampolineMonitorCanceled (IntPtr block) } [DllImport (Constants.NetworkLibrary)] - static extern unsafe void nw_path_monitor_set_cancel_handler (IntPtr handle, void *callback); + static extern unsafe void nw_path_monitor_set_cancel_handler (IntPtr handle, void* callback); [BindingImpl (BindingImplOptions.Optimizable)] public void SetMonitorCanceledHandler (Action callback) @@ -170,7 +170,7 @@ public void SetMonitorCanceledHandler (Action callback) } BlockLiteral block_handler = new BlockLiteral (); - BlockLiteral *block_ptr_handler = &block_handler; + BlockLiteral* block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_MonitorCanceled, callback); try { @@ -180,19 +180,19 @@ public void SetMonitorCanceledHandler (Action callback) } } } - - + + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_path_monitor_prohibit_interface_type (OS_nw_path_monitor monitor, NWInterfaceType interfaceType); @@ -203,11 +203,11 @@ public void SetMonitorCanceledHandler (Action callback) [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public void ProhibitInterfaceType (NWInterfaceType interfaceType) => nw_path_monitor_prohibit_interface_type (GetCheckedHandle (), interfaceType); diff --git a/src/Network/NWPrivacyContext.cs b/src/Network/NWPrivacyContext.cs index a0eaaab50e31..99efb85e05ca 100644 --- a/src/Network/NWPrivacyContext.cs +++ b/src/Network/NWPrivacyContext.cs @@ -5,8 +5,8 @@ using ObjCRuntime; using CoreFoundation; using Foundation; -using OS_nw_privacy_context=System.IntPtr; -using OS_nw_resolver_config=System.IntPtr; +using OS_nw_privacy_context = System.IntPtr; +using OS_nw_resolver_config = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -19,29 +19,29 @@ namespace Network { [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public class NWPrivacyContext : NativeObject { public static NWPrivacyContext Default => - new NWPrivacyContext (NWPrivacyContextConstants._DefaultContext, false); + new NWPrivacyContext (NWPrivacyContextConstants._DefaultContext, false); [Preserve (Conditional = true)] #if NET internal NWPrivacyContext (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWPrivacyContext (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWPrivacyContext (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] static extern unsafe OS_nw_privacy_context nw_privacy_context_create (string description); public NWPrivacyContext (string description) - : base (nw_privacy_context_create (description), true) {} + : base (nw_privacy_context_create (description), true) { } [DllImport (Constants.NetworkLibrary)] static extern void nw_privacy_context_flush_cache (OS_nw_privacy_context privacyContext); @@ -53,7 +53,7 @@ public void FlushCache () static extern void nw_privacy_context_disable_logging (OS_nw_privacy_context privacyContext); public void DisableLogging () - => nw_privacy_context_disable_logging (GetCheckedHandle ()); + => nw_privacy_context_disable_logging (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern void nw_privacy_context_require_encrypted_name_resolution (OS_nw_privacy_context privacyContext, [MarshalAs (UnmanagedType.I1)] bool requireEncryptedNameResolution, OS_nw_resolver_config fallbackResolverConfig); diff --git a/src/Network/NWProtocolDefinition.cs b/src/Network/NWProtocolDefinition.cs index 3c3261041654..38db9dfa5d9c 100644 --- a/src/Network/NWProtocolDefinition.cs +++ b/src/Network/NWProtocolDefinition.cs @@ -16,7 +16,7 @@ using Foundation; using CoreFoundation; -using OS_nw_protocol_definition=System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -30,17 +30,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWProtocolDefinition : NativeObject { [Preserve (Conditional = true)] #if NET internal NWProtocolDefinition (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWProtocolDefinition (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWProtocolDefinition (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -102,17 +102,17 @@ public bool Equals (object other) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_definition nw_protocol_copy_ws_definition (); #if !NET - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] [Obsolete ("Use 'CreateWebSocketDefinition' method instead.")] public static NWProtocolDefinition WebSocketDefinition => new NWProtocolDefinition (nw_protocol_copy_ws_definition (), owns: true); #endif @@ -123,9 +123,9 @@ public bool Equals (object other) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public static NWProtocolDefinition CreateWebSocketDefinition () => new NWProtocolDefinition (nw_protocol_copy_ws_definition (), owns: true); @@ -135,9 +135,9 @@ public bool Equals (object other) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern unsafe OS_nw_protocol_definition nw_framer_create_definition (string identifier, NWFramerCreateFlags flags, ref BlockLiteral start_handler); @@ -148,7 +148,7 @@ public bool Equals (object other) static NWFramerStartResult TrampolineCreateFramerHandler (IntPtr block, IntPtr framer) { // get and call, this is internal and we are trying to do all the magic in the call - var del = BlockLiteral.GetTarget> (block); + var del = BlockLiteral.GetTarget> (block); if (del is not null) { var nwFramer = new NWFramer (framer, owns: true); return del (nwFramer); @@ -162,9 +162,9 @@ static NWFramerStartResult TrampolineCreateFramerHandler (IntPtr block, IntPtr f [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [BindingImpl (BindingImplOptions.Optimizable)] public static NWProtocolDefinition CreateFramerDefinition (string identifier, NWFramerCreateFlags flags, Func startCallback) @@ -176,19 +176,19 @@ public static NWProtocolDefinition CreateFramerDefinition (string identifier, NW } finally { block_handler.CleanupBlock (); } - } - + } + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_definition nw_protocol_copy_quic_definition (); @@ -199,11 +199,11 @@ public static NWProtocolDefinition CreateFramerDefinition (string identifier, NW [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public static NWProtocolDefinition CreateQuicDefinition () => new NWProtocolDefinition (nw_protocol_copy_quic_definition (), owns: true); } diff --git a/src/Network/NWProtocolFramerOptions.cs b/src/Network/NWProtocolFramerOptions.cs index d1817ae73306..11e70faad173 100644 --- a/src/Network/NWProtocolFramerOptions.cs +++ b/src/Network/NWProtocolFramerOptions.cs @@ -16,10 +16,10 @@ using Foundation; using CoreFoundation; using Security; -using IntPtr=System.IntPtr; +using IntPtr = System.IntPtr; #if !NET -using OS_nw_protocol_options=System.IntPtr; +using OS_nw_protocol_options = System.IntPtr; using NativeHandle = System.IntPtr; #else using OS_nw_protocol_options=ObjCRuntime.NativeHandle; @@ -33,16 +33,16 @@ namespace Network { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] - [MacCatalyst (16,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] + [MacCatalyst (16, 0)] #endif public class NSProtocolFramerOptions : NWProtocolOptions { - + [Preserve (Conditional = true)] - internal NSProtocolFramerOptions (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NSProtocolFramerOptions (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern void nw_framer_options_set_object_value (OS_nw_protocol_options options, string key, NativeHandle value); @@ -53,7 +53,8 @@ public void SetValue (string key, T? value) where T : NSObject [DllImport (Constants.NetworkLibrary)] static extern NativeHandle nw_framer_options_copy_object_value (OS_nw_protocol_options options, string key); - public T? GetValue (string key) where T : NSObject { + public T? GetValue (string key) where T : NSObject + { var value = nw_framer_options_copy_object_value (GetCheckedHandle (), key); return Runtime.GetNSObject (value, owns: true); } diff --git a/src/Network/NWProtocolIPOptions.cs b/src/Network/NWProtocolIPOptions.cs index d6bf65962389..25c9810d8719 100644 --- a/src/Network/NWProtocolIPOptions.cs +++ b/src/Network/NWProtocolIPOptions.cs @@ -16,9 +16,9 @@ using Foundation; using CoreFoundation; using Security; -using OS_nw_protocol_definition=System.IntPtr; -using OS_nw_protocol_options=System.IntPtr; -using IntPtr=System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using OS_nw_protocol_options = System.IntPtr; +using IntPtr = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -32,14 +32,14 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWProtocolIPOptions : NWProtocolOptions { [Preserve (Conditional = true)] - internal NWProtocolIPOptions (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWProtocolIPOptions (NativeHandle handle, bool owns) : base (handle, owns) { } public void SetVersion (NWIPVersion version) => nw_ip_options_set_version (GetCheckedHandle (), version); @@ -58,21 +58,21 @@ public void SetCalculateReceiveTime (bool shouldCalculateReceiveTime) public void SetIPLocalAddressPreference (NWIPLocalAddressPreference localAddressPreference) => nw_ip_options_set_local_address_preference (GetCheckedHandle (), localAddressPreference); - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] - static extern void nw_ip_options_set_disable_multicast_loopback (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool disableMulticastLoopback); + static extern void nw_ip_options_set_disable_multicast_loopback (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool disableMulticastLoopback); #if NET [SupportedOSPlatform ("tvos15.0")] @@ -80,11 +80,11 @@ public void SetIPLocalAddressPreference (NWIPLocalAddressPreference localAddress [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public void DisableMulticastLoopback (bool disable) => nw_ip_options_set_disable_multicast_loopback (GetCheckedHandle (), disable); diff --git a/src/Network/NWProtocolMetadata.cs b/src/Network/NWProtocolMetadata.cs index bff336b479d3..2a3c09f1e5f2 100644 --- a/src/Network/NWProtocolMetadata.cs +++ b/src/Network/NWProtocolMetadata.cs @@ -16,9 +16,9 @@ using Foundation; using CoreFoundation; using Security; -using OS_nw_protocol_definition=System.IntPtr; -using OS_nw_protocol_metadata=System.IntPtr; -using nw_service_class_t=System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using OS_nw_protocol_metadata = System.IntPtr; +using nw_service_class_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -32,10 +32,10 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWProtocolMetadata : NativeObject { @@ -65,7 +65,7 @@ public static NWProtocolMetadata CreateUdpMetadata () #if NET internal NWProtocolMetadata (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWProtocolMetadata (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWProtocolMetadata (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -96,18 +96,18 @@ public NWProtocolMetadata (NativeHandle handle, bool owns) : base (handle, owns) internal static extern bool nw_protocol_metadata_is_tcp (OS_nw_protocol_metadata metadata); public bool IsTcp => nw_protocol_metadata_is_tcp (GetCheckedHandle ()); - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -119,11 +119,11 @@ public NWProtocolMetadata (NativeHandle handle, bool owns) : base (handle, owns) [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public bool IsQuic => nw_protocol_metadata_is_quic (GetCheckedHandle ()); @@ -250,9 +250,9 @@ public uint TcpGetAvailableSendBuffer () [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -264,9 +264,9 @@ public uint TcpGetAvailableSendBuffer () [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public bool IsFramerMessage => nw_protocol_metadata_is_framer_message (GetCheckedHandle ()); @@ -276,9 +276,9 @@ public uint TcpGetAvailableSendBuffer () [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -290,9 +290,9 @@ public uint TcpGetAvailableSendBuffer () [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif public bool IsWebSocket => nw_protocol_metadata_is_ws (GetCheckedHandle ()); } diff --git a/src/Network/NWProtocolOptions.cs b/src/Network/NWProtocolOptions.cs index 9aa6401090fa..320784b685d2 100644 --- a/src/Network/NWProtocolOptions.cs +++ b/src/Network/NWProtocolOptions.cs @@ -16,8 +16,8 @@ using Foundation; using CoreFoundation; using Security; -using OS_nw_protocol_definition=System.IntPtr; -using IntPtr=System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using IntPtr = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -31,17 +31,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWProtocolOptions : NativeObject { [Preserve (Conditional = true)] #if NET internal NWProtocolOptions (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWProtocolOptions (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWProtocolOptions (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -90,11 +90,11 @@ public static NWProtocolOptions CreateUdp () [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] internal static extern IntPtr nw_quic_create_options (); @@ -107,9 +107,9 @@ public static NWProtocolOptions CreateQuic () } #endif -// -// IP Options -// + // + // IP Options + // [DllImport (Constants.NetworkLibrary)] internal static extern void nw_ip_options_set_version (IntPtr options, NWIPVersion version); @@ -155,7 +155,7 @@ public void IPSetDisableFragmentation (bool disableFragmentation) #endif // !NET [DllImport (Constants.NetworkLibrary)] - internal static extern void nw_ip_options_set_calculate_receive_time (IntPtr options,[MarshalAs (UnmanagedType.I1)] bool calculateReceiveTime); + internal static extern void nw_ip_options_set_calculate_receive_time (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool calculateReceiveTime); #if !NET [Obsolete ("Use the 'NWProtocolIPOptions' class instead.")] @@ -172,25 +172,25 @@ public void IPSetCalculateReceiveTime (bool calculateReceiveTime) [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] internal static extern void nw_ip_options_set_local_address_preference (IntPtr options, NWIPLocalAddressPreference preference); #if !NET - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] [Obsolete ("Use the 'NWProtocolIPOptions' class instead.")] #endif public NWIPLocalAddressPreference IPLocalAddressPreference { set => nw_ip_options_set_local_address_preference (GetCheckedHandle (), value); } -// -// TCP Options -// + // + // TCP Options + // [DllImport (Constants.NetworkLibrary)] internal extern static void nw_tcp_options_set_no_delay (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noDelay); @@ -250,7 +250,7 @@ public NWIPLocalAddressPreference IPLocalAddressPreference { [DllImport (Constants.NetworkLibrary)] internal extern static void nw_tcp_options_set_maximum_segment_size (IntPtr handle, uint maximumSegmentSize); - + #if !NET [Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")] public void TcpSetMaximumSegmentSize (uint maximumSegmentSize) => nw_tcp_options_set_maximum_segment_size (GetCheckedHandle (), maximumSegmentSize); @@ -312,9 +312,9 @@ public NWIPLocalAddressPreference IPLocalAddressPreference { public void TcpSetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn); #endif // !NET -// -// UDP Options -// + // + // UDP Options + // [DllImport (Constants.NetworkLibrary)] internal extern static void nw_udp_options_set_prefer_no_checksum (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool preferNoChecksums); @@ -323,9 +323,9 @@ public NWIPLocalAddressPreference IPLocalAddressPreference { public void UdpSetPreferNoChecksum (bool preferNoChecksums) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksums); #endif // !NET -// -// TLS options -// + // + // TLS options + // [DllImport (Constants.NetworkLibrary)] internal extern static IntPtr nw_tls_copy_sec_protocol_options (IntPtr options); @@ -334,18 +334,18 @@ public NWIPLocalAddressPreference IPLocalAddressPreference { [Obsolete ("Use the 'NWProtocolTlsOptions' class instead.")] public SecProtocolOptions TlsProtocolOptions => new SecProtocolOptions (nw_tls_copy_sec_protocol_options (GetCheckedHandle ()), owns: true); #endif - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] diff --git a/src/Network/NWProtocolQuicOptions.cs b/src/Network/NWProtocolQuicOptions.cs index 091449e76c56..f9411a112941 100644 --- a/src/Network/NWProtocolQuicOptions.cs +++ b/src/Network/NWProtocolQuicOptions.cs @@ -23,35 +23,35 @@ namespace Network { [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public class NWProtocolQuicOptions : NWProtocolOptions { [Preserve (Conditional = true)] - internal NWProtocolQuicOptions (NativeHandle handle, bool owns) : base (handle, owns) {} - - public NWProtocolQuicOptions () : this (nw_quic_create_options (), owns: true) {} + internal NWProtocolQuicOptions (NativeHandle handle, bool owns) : base (handle, owns) { } + + public NWProtocolQuicOptions () : this (nw_quic_create_options (), owns: true) { } [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_add_tls_application_protocol (OS_nw_protocol_options options, string applicationProtocol); public void AddTlsApplicationProtocol (string applicationProtocol) - => nw_quic_add_tls_application_protocol (GetCheckedHandle (), applicationProtocol); + => nw_quic_add_tls_application_protocol (GetCheckedHandle (), applicationProtocol); [DllImport (Constants.NetworkLibrary)] static extern SecProtocolOptionsRef nw_quic_copy_sec_protocol_options (OS_nw_protocol_options options); public SecProtocolOptions SecProtocolOptions => new SecProtocolOptions (nw_quic_copy_sec_protocol_options (GetCheckedHandle ()), true); - + [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] static extern bool nw_quic_get_stream_is_unidirectional (OS_nw_protocol_options options); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_stream_is_unidirectional (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool isUnidirectional); @@ -59,10 +59,10 @@ public bool StreamIsUnidirectional { get => nw_quic_get_stream_is_unidirectional (GetCheckedHandle ()); set => nw_quic_set_stream_is_unidirectional (GetCheckedHandle (), value); } - + [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_initial_max_data (OS_nw_protocol_options options); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_initial_max_data (OS_nw_protocol_options options, ulong initial_max_data); @@ -70,18 +70,18 @@ public ulong InitialMaxData { get => nw_quic_get_initial_max_data (GetCheckedHandle ()); set => nw_quic_set_initial_max_data (GetCheckedHandle (), value); } - + [DllImport (Constants.NetworkLibrary)] static extern ushort nw_quic_get_max_udp_payload_size (OS_nw_protocol_options options); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_max_udp_payload_size (OS_nw_protocol_options options, ushort max_udp_payload_size); public ushort MaxUdpPayloadSize { get => nw_quic_get_max_udp_payload_size (GetCheckedHandle ()); set => nw_quic_set_max_udp_payload_size (GetCheckedHandle (), value); - } - + } + [DllImport (Constants.NetworkLibrary)] static extern uint nw_quic_get_idle_timeout (OS_nw_protocol_options options); @@ -95,7 +95,7 @@ public uint IdleTimeout { [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_initial_max_streams_bidirectional (OS_nw_protocol_options options); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_initial_max_streams_bidirectional (OS_nw_protocol_options options, ulong initial_max_streams_bidirectional); @@ -106,18 +106,18 @@ public ulong InitialMaxStreamsBidirectional { [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_initial_max_streams_unidirectional (OS_nw_protocol_options options); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_initial_max_streams_unidirectional (OS_nw_protocol_options options, ulong initial_max_streams_unidirectional); public ulong InitialMaxStreamsUnidirectional { get => nw_quic_get_initial_max_streams_unidirectional (GetCheckedHandle ()); set => nw_quic_set_initial_max_streams_unidirectional (GetCheckedHandle (), value); - } - + } + [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_initial_max_stream_data_bidirectional_local (OS_nw_protocol_options options); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_initial_max_stream_data_bidirectional_local (OS_nw_protocol_options options, ulong initial_max_stream_data_bidirectional_local); @@ -125,10 +125,10 @@ public ulong InitialMaxStreamDataBidirectionalLocal { get => nw_quic_get_initial_max_stream_data_bidirectional_local (GetCheckedHandle ()); set => nw_quic_set_initial_max_stream_data_bidirectional_local (GetCheckedHandle (), value); } - + [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_initial_max_stream_data_bidirectional_remote (OS_nw_protocol_options options); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_initial_max_stream_data_bidirectional_remote (OS_nw_protocol_options options, ulong initial_max_stream_data_bidirectional_remote); @@ -136,7 +136,7 @@ public ulong InitialMaxStreamDataBidirectionalRemote { get => nw_quic_get_initial_max_stream_data_bidirectional_remote (GetCheckedHandle ()); set => nw_quic_set_initial_max_stream_data_bidirectional_remote (GetCheckedHandle (), value); } - + [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_initial_max_stream_data_unidirectional (OS_nw_protocol_options options); @@ -154,10 +154,10 @@ public ulong InitialMaxStreamDataUnidirectional { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern ushort nw_quic_get_max_datagram_frame_size (OS_nw_protocol_options options); @@ -168,10 +168,10 @@ public ulong InitialMaxStreamDataUnidirectional { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_max_datagram_frame_size (OS_nw_protocol_options options, ushort max_datagram_frame_size); @@ -182,10 +182,10 @@ public ulong InitialMaxStreamDataUnidirectional { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public ushort DatagramFrameSize { get => nw_quic_get_max_datagram_frame_size (GetCheckedHandle ()); @@ -198,10 +198,10 @@ public ushort DatagramFrameSize { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] @@ -213,10 +213,10 @@ public ushort DatagramFrameSize { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_stream_is_datagram (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool is_datagram); @@ -227,10 +227,10 @@ public ushort DatagramFrameSize { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public bool StreamIsDatagram { get => nw_quic_get_stream_is_datagram (GetCheckedHandle ()); @@ -243,10 +243,10 @@ public bool StreamIsDatagram { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern ushort nw_quic_get_stream_usable_datagram_frame_size (OS_nw_protocol_metadata metadata); @@ -257,10 +257,10 @@ public bool StreamIsDatagram { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public ushort StreamUsableDatagramFrameSize => nw_quic_get_stream_usable_datagram_frame_size (GetCheckedHandle ()); @@ -270,10 +270,10 @@ public bool StreamIsDatagram { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern byte nw_quic_get_stream_type (OS_nw_protocol_metadata stream_metadata); @@ -284,10 +284,10 @@ public bool StreamIsDatagram { [SupportedOSPlatform ("ios16.0")] [SupportedOSPlatform ("maccatalyst16.0")] #else - [TV (16,0)] - [Mac (13,0)] - [iOS (16,0)] - [Watch (9,0)] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + [Watch (9, 0)] #endif public NWQuicStreamType StreamType => (NWQuicStreamType) nw_quic_get_stream_type (GetCheckedHandle ()); diff --git a/src/Network/NWProtocolStack.cs b/src/Network/NWProtocolStack.cs index 37565473e223..55a7bc51e67a 100644 --- a/src/Network/NWProtocolStack.cs +++ b/src/Network/NWProtocolStack.cs @@ -15,11 +15,11 @@ using Foundation; using CoreFoundation; -using OS_nw_protocol_definition=System.IntPtr; -using OS_nw_protocol_metadata=System.IntPtr; -using nw_service_class_t=System.IntPtr; -using nw_protocol_stack_t=System.IntPtr; -using nw_protocol_options_t=System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using OS_nw_protocol_metadata = System.IntPtr; +using nw_service_class_t = System.IntPtr; +using nw_protocol_stack_t = System.IntPtr; +using nw_protocol_options_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -33,17 +33,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWProtocolStack : NativeObject { [Preserve (Conditional = true)] #if NET internal NWProtocolStack (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWProtocolStack (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWProtocolStack (NativeHandle handle, bool owns) : base (handle, owns) { } #endif [DllImport (Constants.NetworkLibrary)] @@ -72,7 +72,7 @@ static void TrampolineIterateHandler (IntPtr block, IntPtr options) { var del = BlockLiteral.GetTarget> (block); if (del is not null) { - using (var tempOptions = new NWProtocolOptions (options, owns: false)) + using (var tempOptions = new NWProtocolOptions (options, owns: false)) using (var definition = tempOptions.ProtocolDefinition) { NWProtocolOptions? castedOptions = null; @@ -86,7 +86,7 @@ static void TrampolineIterateHandler (IntPtr block, IntPtr options) castedOptions = new NWProtocolIPOptions (options, owns: false); } else if (definition.Equals (NWProtocolDefinition.CreateWebSocketDefinition ())) { castedOptions = new NWWebSocketOptions (options, owns: false); - } + } del (castedOptions ?? tempOptions); castedOptions?.Dispose (); @@ -121,7 +121,7 @@ public NWProtocolOptions? TransportProtocol { var pHandle = nw_protocol_stack_copy_transport_protocol (GetCheckedHandle ()); if (pHandle == IntPtr.Zero) return null; - var tempOptions = new NWProtocolOptions (pHandle, owns: true); + var tempOptions = new NWProtocolOptions (pHandle, owns: true); using (var definition = tempOptions.ProtocolDefinition) { NWProtocolOptions? castedOptions = null; @@ -130,7 +130,7 @@ public NWProtocolOptions? TransportProtocol { } if (definition.Equals (NWProtocolDefinition.CreateUdpDefinition ())) { castedOptions = new NWProtocolUdpOptions (pHandle, owns: true); - } + } if (castedOptions is null) { return tempOptions; } else { diff --git a/src/Network/NWProtocolTcpOptions.cs b/src/Network/NWProtocolTcpOptions.cs index 791486ae0feb..980a7e7a5b9b 100644 --- a/src/Network/NWProtocolTcpOptions.cs +++ b/src/Network/NWProtocolTcpOptions.cs @@ -16,9 +16,9 @@ using Foundation; using CoreFoundation; using Security; -using OS_nw_protocol_definition=System.IntPtr; -using OS_nw_protocol_options=System.IntPtr; -using IntPtr=System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using OS_nw_protocol_options = System.IntPtr; +using IntPtr = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -32,17 +32,17 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWProtocolTcpOptions : NWProtocolOptions { - + [Preserve (Conditional = true)] - internal NWProtocolTcpOptions (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWProtocolTcpOptions (NativeHandle handle, bool owns) : base (handle, owns) { } - public NWProtocolTcpOptions () : this (nw_tcp_create_options (), owns: true) {} + public NWProtocolTcpOptions () : this (nw_tcp_create_options (), owns: true) { } public void SetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay); @@ -50,7 +50,7 @@ public NWProtocolTcpOptions () : this (nw_tcp_create_options (), owns: true) {} public void SetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions); - public void SetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive); + public void SetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive); public void SetKeepAliveCount (uint keepAliveCount) => nw_tcp_options_set_keepalive_count (GetCheckedHandle (), keepAliveCount); @@ -80,18 +80,18 @@ public void SetDisableAckStretching (bool disableAckStretching) public void SetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen); public void SetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn); - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif [DllImport (Constants.NetworkLibrary)] static extern void nw_tcp_options_set_multipath_force_version (OS_nw_protocol_options options, NWMultipathVersion multipath_force_version); @@ -102,11 +102,11 @@ public void SetDisableAckStretching (bool disableAckStretching) [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public void ForceMultipathVersion (NWMultipathVersion version) => nw_tcp_options_set_multipath_force_version (GetCheckedHandle (), version); diff --git a/src/Network/NWProtocolTlsOptions.cs b/src/Network/NWProtocolTlsOptions.cs index 412753992245..c981317be7cd 100644 --- a/src/Network/NWProtocolTlsOptions.cs +++ b/src/Network/NWProtocolTlsOptions.cs @@ -16,8 +16,8 @@ using Foundation; using CoreFoundation; using Security; -using OS_nw_protocol_definition=System.IntPtr; -using IntPtr=System.IntPtr; +using OS_nw_protocol_definition = System.IntPtr; +using IntPtr = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -31,16 +31,16 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWProtocolTlsOptions : NWProtocolOptions { [Preserve (Conditional = true)] - internal NWProtocolTlsOptions (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWProtocolTlsOptions (NativeHandle handle, bool owns) : base (handle, owns) { } - public NWProtocolTlsOptions () : this (nw_tls_create_options (), owns: true) {} + public NWProtocolTlsOptions () : this (nw_tls_create_options (), owns: true) { } public SecProtocolOptions ProtocolOptions => new SecProtocolOptions (nw_tls_copy_sec_protocol_options (GetCheckedHandle ()), owns: true); } diff --git a/src/Network/NWProtocolUdpOptions.cs b/src/Network/NWProtocolUdpOptions.cs index fcd93e78c6a6..1f218a45b1f9 100644 --- a/src/Network/NWProtocolUdpOptions.cs +++ b/src/Network/NWProtocolUdpOptions.cs @@ -27,16 +27,16 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWProtocolUdpOptions : NWProtocolOptions { [Preserve (Conditional = true)] - internal NWProtocolUdpOptions (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWProtocolUdpOptions (NativeHandle handle, bool owns) : base (handle, owns) { } - public NWProtocolUdpOptions () : this (nw_udp_create_options (), owns: true) {} + public NWProtocolUdpOptions () : this (nw_udp_create_options (), owns: true) { } public void SetPreferNoChecksum (bool preferNoChecksum) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksum); } diff --git a/src/Network/NWQuicMetadata.cs b/src/Network/NWQuicMetadata.cs index a7d46d0655a2..6da781acbeca 100644 --- a/src/Network/NWQuicMetadata.cs +++ b/src/Network/NWQuicMetadata.cs @@ -42,7 +42,7 @@ public NWQuicMetadata (NativeHandle handle, bool owns) : base (handle, owns) { } public ulong RemoteIdleTimeout => nw_quic_get_remote_idle_timeout (GetCheckedHandle ()); - + [DllImport (Constants.NetworkLibrary)] static extern ushort nw_quic_get_keepalive_interval (OS_nw_protocol_metadata metadata); @@ -53,31 +53,31 @@ public ushort KeepaliveInterval { get => nw_quic_get_keepalive_interval (GetCheckedHandle ()); set => nw_quic_set_keepalive_interval (GetCheckedHandle (), value); } - + [DllImport (Constants.NetworkLibrary)] static extern string nw_quic_get_application_error_reason (OS_nw_protocol_metadata metadata); public string? ApplicationErrorReason => nw_quic_get_application_error_reason (GetCheckedHandle ()); - + [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_application_error (OS_nw_protocol_metadata metadata); public ulong ApplicationErrorCode => nw_quic_get_application_error (GetCheckedHandle ()); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_application_error (OS_nw_protocol_metadata metadata, ulong application_error, string? reason); public (ulong error, string? reason) ApplicationError { get => (ApplicationErrorCode, ApplicationErrorReason); - set => nw_quic_set_application_error (GetCheckedHandle (), value.error, value.reason); + set => nw_quic_set_application_error (GetCheckedHandle (), value.error, value.reason); } [DllImport (Constants.NetworkLibrary)] static extern SecProtocolMetadataRef nw_quic_copy_sec_protocol_metadata (OS_nw_protocol_metadata metadata); - public SecProtocolMetadata SecProtocolMetadata + public SecProtocolMetadata SecProtocolMetadata => new SecProtocolMetadata (nw_quic_copy_sec_protocol_metadata (GetCheckedHandle ()), owns: true); [DllImport (Constants.NetworkLibrary)] @@ -88,7 +88,7 @@ public ulong StreamId [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_stream_application_error (OS_nw_protocol_metadata metadata); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_stream_application_error (OS_nw_protocol_metadata metadata, ulong application_error); @@ -96,10 +96,10 @@ public ulong StreamApplicationError { get => nw_quic_get_stream_application_error (GetCheckedHandle ()); set => nw_quic_set_stream_application_error (GetCheckedHandle (), value); } - + [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_local_max_streams_bidirectional (OS_nw_protocol_metadata metadata); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_local_max_streams_bidirectional (OS_nw_protocol_metadata metadata, ulong max_streams_bidirectional); @@ -110,7 +110,7 @@ public ulong MaxStreamsBidirectional { [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_local_max_streams_unidirectional (OS_nw_protocol_metadata metadata); - + [DllImport (Constants.NetworkLibrary)] static extern void nw_quic_set_local_max_streams_unidirectional (OS_nw_protocol_metadata metadata, ulong max_streams_unidirectional); @@ -123,12 +123,12 @@ public ulong LocalMaxStreamsUnidirectional { static extern ulong nw_quic_get_remote_max_streams_bidirectional (OS_nw_protocol_metadata metadata); public ulong RemoteMaxStreamsBidirectional - => nw_quic_get_remote_max_streams_bidirectional (GetCheckedHandle ()); + => nw_quic_get_remote_max_streams_bidirectional (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern ulong nw_quic_get_remote_max_streams_unidirectional (OS_nw_protocol_metadata metadata); - - public ulong RemoteMaxStreamsUnidirectional - => nw_quic_get_remote_max_streams_unidirectional (GetCheckedHandle ()); + + public ulong RemoteMaxStreamsUnidirectional + => nw_quic_get_remote_max_streams_unidirectional (GetCheckedHandle ()); } } diff --git a/src/Network/NWResolutionReport.cs b/src/Network/NWResolutionReport.cs index 462cdf45ffe4..f661eaddaa9b 100644 --- a/src/Network/NWResolutionReport.cs +++ b/src/Network/NWResolutionReport.cs @@ -4,10 +4,10 @@ using Foundation; using CoreFoundation; -using nw_report_resolution_source_t=System.IntPtr; -using OS_nw_resolution_report=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; -using nw_report_resolution_protocol_t=System.IntPtr; +using nw_report_resolution_source_t = System.IntPtr; +using OS_nw_resolution_report = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; +using nw_report_resolution_protocol_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -16,41 +16,41 @@ #nullable enable namespace Network { - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public class NWResolutionReport : NativeObject { [Preserve (Conditional = true)] - internal NWResolutionReport (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWResolutionReport (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern NWReportResolutionSource nw_resolution_report_get_source (OS_nw_resolution_report resolutionReport); public NWReportResolutionSource Source - => nw_resolution_report_get_source (GetCheckedHandle ()); + => nw_resolution_report_get_source (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern ulong nw_resolution_report_get_milliseconds (OS_nw_resolution_report resolutionReport); public ulong Milliseconds - => nw_resolution_report_get_milliseconds (GetCheckedHandle ()); + => nw_resolution_report_get_milliseconds (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern uint nw_resolution_report_get_endpoint_count (OS_nw_resolution_report resolutionReport); public uint EndpointCount - => nw_resolution_report_get_endpoint_count (GetCheckedHandle ()); + => nw_resolution_report_get_endpoint_count (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern OS_nw_endpoint nw_resolution_report_copy_successful_endpoint (OS_nw_resolution_report resolutionReport); diff --git a/src/Network/NWResolverConfig.cs b/src/Network/NWResolverConfig.cs index 61faa1833d36..3beafb64ae4e 100644 --- a/src/Network/NWResolverConfig.cs +++ b/src/Network/NWResolverConfig.cs @@ -7,26 +7,26 @@ using ObjCRuntime; using CoreFoundation; -using OS_nw_resolver_config=System.IntPtr; -using OS_nw_endpoint=System.IntPtr; +using OS_nw_resolver_config = System.IntPtr; +using OS_nw_endpoint = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; #endif namespace Network { - + #if NET [SupportedOSPlatform ("tvos15.0")] [SupportedOSPlatform ("macos12.0")] [SupportedOSPlatform ("ios15.0")] [SupportedOSPlatform ("maccatalyst15.0")] #else - [Watch (8,0)] - [TV (15,0)] - [Mac (12,0)] - [iOS (15,0)] - [MacCatalyst (15,0)] + [Watch (8, 0)] + [TV (15, 0)] + [Mac (12, 0)] + [iOS (15, 0)] + [MacCatalyst (15, 0)] #endif public class NWResolverConfig : NativeObject { @@ -34,12 +34,12 @@ public class NWResolverConfig : NativeObject { #if NET internal NWResolverConfig (NativeHandle handle, bool owns) : base (handle, owns) {} #else - public NWResolverConfig (NativeHandle handle, bool owns) : base (handle, owns) {} + public NWResolverConfig (NativeHandle handle, bool owns) : base (handle, owns) { } #endif - + [DllImport (Constants.NetworkLibrary)] static extern OS_nw_resolver_config nw_resolver_config_create_https (OS_nw_endpoint urlEndpoint); - + [DllImport (Constants.NetworkLibrary)] static extern OS_nw_resolver_config nw_resolver_config_create_tls (OS_nw_endpoint serverEndpoint); diff --git a/src/Network/NWTcpMetadata.cs b/src/Network/NWTcpMetadata.cs index 898c8cfa9ea3..0c8b53765c71 100644 --- a/src/Network/NWTcpMetadata.cs +++ b/src/Network/NWTcpMetadata.cs @@ -26,15 +26,15 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWTcpMetadata : NWProtocolMetadata { [Preserve (Conditional = true)] - internal NWTcpMetadata (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWTcpMetadata (NativeHandle handle, bool owns) : base (handle, owns) { } public uint AvailableReceiveBuffer => nw_tcp_get_available_receive_buffer (GetCheckedHandle ()); diff --git a/src/Network/NWTlsMetadata.cs b/src/Network/NWTlsMetadata.cs index ca9f5bcbf39b..782c197cab1d 100644 --- a/src/Network/NWTlsMetadata.cs +++ b/src/Network/NWTlsMetadata.cs @@ -27,15 +27,15 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWTlsMetadata : NWProtocolMetadata { [Preserve (Conditional = true)] - internal NWTlsMetadata (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWTlsMetadata (NativeHandle handle, bool owns) : base (handle, owns) { } public SecProtocolMetadata SecProtocolMetadata => new SecProtocolMetadata (nw_tls_copy_sec_protocol_metadata (GetCheckedHandle ()), owns: true); diff --git a/src/Network/NWTxtRecord.cs b/src/Network/NWTxtRecord.cs index dc56bc259a51..d744b1343e1e 100644 --- a/src/Network/NWTxtRecord.cs +++ b/src/Network/NWTxtRecord.cs @@ -17,9 +17,9 @@ using Foundation; using CoreFoundation; -using nw_advertise_descriptor_t=System.IntPtr; -using OS_nw_advertise_descriptor=System.IntPtr; -using OS_nw_txt_record=System.IntPtr; +using nw_advertise_descriptor_t = System.IntPtr; +using OS_nw_advertise_descriptor = System.IntPtr; +using OS_nw_txt_record = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -34,17 +34,17 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWTxtRecord : NativeObject { [Preserve (Conditional = true)] internal NWTxtRecord (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] - unsafe static extern IntPtr nw_txt_record_create_with_bytes (byte *txtBytes, nuint len); + unsafe static extern IntPtr nw_txt_record_create_with_bytes (byte* txtBytes, nuint len); public static NWTxtRecord? FromBytes (ReadOnlySpan bytes) { @@ -71,12 +71,12 @@ internal NWTxtRecord (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern IntPtr nw_txt_record_copy (IntPtr other); - + public NWTxtRecord Clone () => new NWTxtRecord (nw_txt_record_copy (GetCheckedHandle ()), owns: true); [DllImport (Constants.NetworkLibrary)] static extern NWTxtRecordFindKey nw_txt_record_find_key (IntPtr handle, string key); - + public NWTxtRecordFindKey FindKey (string key) => nw_txt_record_find_key (GetCheckedHandle (), key); [DllImport (Constants.NetworkLibrary)] @@ -86,16 +86,17 @@ public bool Add (string key, ReadOnlySpan value) { unsafe { fixed (byte* mh = value) - return nw_txt_record_set_key (GetCheckedHandle (), key, (IntPtr)mh, (nuint) value.Length) != 0; + return nw_txt_record_set_key (GetCheckedHandle (), key, (IntPtr) mh, (nuint) value.Length) != 0; } } - public bool Add (string key) { + public bool Add (string key) + { unsafe { return nw_txt_record_set_key (GetCheckedHandle (), key, IntPtr.Zero, 0) != 0; } } - + public bool Add (string key, string value) => Add (key, value is null ? null : Encoding.UTF8.GetBytes (value)); @@ -106,7 +107,7 @@ public bool Add (string key, string value) [DllImport (Constants.NetworkLibrary)] static extern long nw_txt_record_get_key_count (IntPtr handle); - + public long KeyCount => nw_txt_record_get_key_count (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] @@ -150,7 +151,7 @@ unsafe static bool TrampolineApplyHandler (IntPtr block, string key, NWTxtRecord if (del is null) return false; - var mValue = new ReadOnlySpan ((void*)value, (int)valueLen); + var mValue = new ReadOnlySpan ((void*) value, (int) valueLen); #if NET return del (key, found, mValue); #else @@ -216,8 +217,8 @@ unsafe static void TrampolineAccessKeyHandler (IntPtr block, string key, NWTxtRe if (del is not null) { ReadOnlySpan mValue; if (found == NWTxtRecordFindKey.NonEmptyValue) - mValue = new ReadOnlySpan((void*)value, (int)valueLen); - else + mValue = new ReadOnlySpan ((void*) value, (int) valueLen); + else mValue = Array.Empty (); del (key, found, mValue); } @@ -252,7 +253,7 @@ unsafe static void TrampolineRawBytesHandler (IntPtr block, IntPtr value, nuint { var del = BlockLiteral.GetTarget (block); if (del is not null) { - var mValue = new ReadOnlySpan((void*)value, (int)valueLen); + var mValue = new ReadOnlySpan ((void*) value, (int) valueLen); del (mValue); } } diff --git a/src/Network/NWUdpMetadata.cs b/src/Network/NWUdpMetadata.cs index c7f30def055f..135a880eb174 100644 --- a/src/Network/NWUdpMetadata.cs +++ b/src/Network/NWUdpMetadata.cs @@ -27,16 +27,16 @@ namespace Network { [SupportedOSPlatform ("ios12.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (12,0)] - [Mac (10,14)] - [iOS (12,0)] - [Watch (6,0)] + [TV (12, 0)] + [Mac (10, 14)] + [iOS (12, 0)] + [Watch (6, 0)] #endif public class NWUdpMetadata : NWProtocolMetadata { [Preserve (Conditional = true)] - internal NWUdpMetadata (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWUdpMetadata (NativeHandle handle, bool owns) : base (handle, owns) { } - public NWUdpMetadata () : this (nw_udp_create_metadata (), owns: true) {} + public NWUdpMetadata () : this (nw_udp_create_metadata (), owns: true) { } } } diff --git a/src/Network/NWWebSocketMetadata.cs b/src/Network/NWWebSocketMetadata.cs index 7378c9c4e073..b847f35b71fd 100644 --- a/src/Network/NWWebSocketMetadata.cs +++ b/src/Network/NWWebSocketMetadata.cs @@ -16,9 +16,9 @@ using Foundation; using CoreFoundation; -using OS_nw_protocol_metadata=System.IntPtr; -using OS_nw_ws_response=System.IntPtr; -using dispatch_queue_t =System.IntPtr; +using OS_nw_protocol_metadata = System.IntPtr; +using OS_nw_ws_response = System.IntPtr; +using dispatch_queue_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -32,20 +32,20 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWWebSocketMetadata : NWProtocolMetadata { [Preserve (Conditional = true)] - internal NWWebSocketMetadata (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWWebSocketMetadata (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] static extern OS_nw_protocol_metadata nw_ws_create_metadata (NWWebSocketOpCode opcode); - public NWWebSocketMetadata (NWWebSocketOpCode opcode) : this (nw_ws_create_metadata (opcode), owns: true) {} + public NWWebSocketMetadata (NWWebSocketOpCode opcode) : this (nw_ws_create_metadata (opcode), owns: true) { } [DllImport (Constants.NetworkLibrary)] static extern NWWebSocketCloseCode nw_ws_metadata_get_close_code (OS_nw_protocol_metadata metadata); @@ -74,7 +74,7 @@ static void TrampolinePongHandler (IntPtr block, IntPtr error) { var del = BlockLiteral.GetTarget> (block); if (del is not null) { - var nwError = (error == IntPtr.Zero)? null : new NWError (error, owns: false); + var nwError = (error == IntPtr.Zero) ? null : new NWError (error, owns: false); del (nwError); } } @@ -105,8 +105,8 @@ public void SetPongHandler (DispatchQueue queue, Action handler) public NWWebSocketResponse? ServerResponse { get { var reponsePtr = nw_ws_metadata_copy_server_response (GetCheckedHandle ()); - return (reponsePtr == IntPtr.Zero) ? null : new NWWebSocketResponse (reponsePtr, owns: true); + return (reponsePtr == IntPtr.Zero) ? null : new NWWebSocketResponse (reponsePtr, owns: true); } - } + } } } diff --git a/src/Network/NWWebSocketOptions.cs b/src/Network/NWWebSocketOptions.cs index a26dacd28c57..88e28003d2f5 100644 --- a/src/Network/NWWebSocketOptions.cs +++ b/src/Network/NWWebSocketOptions.cs @@ -16,8 +16,8 @@ using Foundation; using CoreFoundation; -using OS_nw_protocol_options=System.IntPtr; -using nw_ws_request_t=System.IntPtr; +using OS_nw_protocol_options = System.IntPtr; +using nw_ws_request_t = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -31,10 +31,10 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWWebSocketOptions : NWProtocolOptions { bool autoReplyPing = false; @@ -42,21 +42,21 @@ public class NWWebSocketOptions : NWProtocolOptions { nuint maximumMessageSize; [Preserve (Conditional = true)] - internal NWWebSocketOptions (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWWebSocketOptions (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] extern static IntPtr nw_ws_create_options (NWWebSocketVersion version); - public NWWebSocketOptions (NWWebSocketVersion version) : base (nw_ws_create_options (version), true) { } + public NWWebSocketOptions (NWWebSocketVersion version) : base (nw_ws_create_options (version), true) { } [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] static extern void nw_ws_options_add_additional_header (OS_nw_protocol_options options, string name, string value); - public void SetHeader (string header, string value) + public void SetHeader (string header, string value) { if (header is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (header)); - nw_ws_options_add_additional_header (GetCheckedHandle(), header, value); + nw_ws_options_add_additional_header (GetCheckedHandle (), header, value); } [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] @@ -73,7 +73,7 @@ public void AddSubprotocol (string subprotocol) static extern void nw_ws_options_set_auto_reply_ping (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool auto_reply_ping); public bool AutoReplyPing { - get { return autoReplyPing;} + get { return autoReplyPing; } set { autoReplyPing = value; nw_ws_options_set_auto_reply_ping (GetCheckedHandle (), value); @@ -87,7 +87,7 @@ public nuint MaximumMessageSize { get { return maximumMessageSize; } set { maximumMessageSize = value; - nw_ws_options_set_maximum_message_size (GetCheckedHandle(), value); + nw_ws_options_set_maximum_message_size (GetCheckedHandle (), value); } } diff --git a/src/Network/NWWebSocketRequest.cs b/src/Network/NWWebSocketRequest.cs index 0db8ccd78901..16820740f09d 100644 --- a/src/Network/NWWebSocketRequest.cs +++ b/src/Network/NWWebSocketRequest.cs @@ -16,7 +16,7 @@ using Foundation; using CoreFoundation; -using OS_nw_ws_request=System.IntPtr; +using OS_nw_ws_request = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -30,14 +30,14 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWWebSocketRequest : NativeObject { [Preserve (Conditional = true)] - internal NWWebSocketRequest (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWWebSocketRequest (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] diff --git a/src/Network/NWWebSocketResponse.cs b/src/Network/NWWebSocketResponse.cs index d032d952a37d..084e5802afd0 100644 --- a/src/Network/NWWebSocketResponse.cs +++ b/src/Network/NWWebSocketResponse.cs @@ -16,7 +16,7 @@ using Foundation; using CoreFoundation; -using OS_nw_ws_response=System.IntPtr; +using OS_nw_ws_response = System.IntPtr; #if !NET using NativeHandle = System.IntPtr; @@ -30,15 +30,15 @@ namespace Network { [SupportedOSPlatform ("ios13.0")] [SupportedOSPlatform ("maccatalyst")] #else - [TV (13,0)] - [Mac (10,15)] - [iOS (13,0)] - [Watch (6,0)] + [TV (13, 0)] + [Mac (10, 15)] + [iOS (13, 0)] + [Watch (6, 0)] #endif public class NWWebSocketResponse : NativeObject { [Preserve (Conditional = true)] - internal NWWebSocketResponse (NativeHandle handle, bool owns) : base (handle, owns) {} + internal NWWebSocketResponse (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] static extern unsafe OS_nw_ws_response nw_ws_response_create (NWWebSocketResponseStatus status, string selected_subprotocol); @@ -49,12 +49,12 @@ public NWWebSocketResponse (NWWebSocketResponseStatus status, string subprotocol [DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] static extern string nw_ws_response_get_selected_subprotocol (OS_nw_ws_response response); - public string SelectedSubprotocol => nw_ws_response_get_selected_subprotocol (GetCheckedHandle ()); + public string SelectedSubprotocol => nw_ws_response_get_selected_subprotocol (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] static extern NWWebSocketResponseStatus nw_ws_response_get_status (OS_nw_ws_response response); - public NWWebSocketResponseStatus Status => nw_ws_response_get_status (GetCheckedHandle ()); + public NWWebSocketResponseStatus Status => nw_ws_response_get_status (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] [return: MarshalAs (UnmanagedType.I1)] diff --git a/src/NetworkExtension/NEEnums.cs b/src/NetworkExtension/NEEnums.cs index 1d0fbc08bd84..232574a0d88e 100644 --- a/src/NetworkExtension/NEEnums.cs +++ b/src/NetworkExtension/NEEnums.cs @@ -2,7 +2,8 @@ namespace NetworkExtension { - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [ErrorDomain ("NEVPNErrorDomain")] [Native] public enum NEVpnError : long { @@ -14,7 +15,8 @@ public enum NEVpnError : long { ConfigurationUnknown = 6 } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native] public enum NEVpnStatus : long { Invalid = 0, @@ -25,7 +27,8 @@ public enum NEVpnStatus : long { Disconnecting = 5 } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native] public enum NEVpnIkeAuthenticationMethod : long { None = 0, @@ -33,22 +36,27 @@ public enum NEVpnIkeAuthenticationMethod : long { SharedSecret = 2 } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native ("NEVPNIKEv2EncryptionAlgorithm")] public enum NEVpnIke2EncryptionAlgorithm : long { DES = 1, TripleDES = 2, AES128 = 3, AES256 = 4, - [iOS (8,3)][Mac (10,11)] + [iOS (8, 3)] + [Mac (10, 11)] AES128GCM = 5, - [iOS (8,3)][Mac (10,11)] + [iOS (8, 3)] + [Mac (10, 11)] AES256GCM = 6, - [Mac (10,15)][iOS (13,0)] + [Mac (10, 15)] + [iOS (13, 0)] ChaCha20Poly1305 = 7, } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native ("NEVPNIKEv2IntegrityAlgorithm")] public enum NEVpnIke2IntegrityAlgorithm : long { SHA96 = 1, @@ -58,7 +66,8 @@ public enum NEVpnIke2IntegrityAlgorithm : long { SHA512 = 5 } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native ("NEVPNIKEv2DeadPeerDetectionRate")] public enum NEVpnIke2DeadPeerDetectionRate : long { None = 0, @@ -67,7 +76,8 @@ public enum NEVpnIke2DeadPeerDetectionRate : long { High = 3 } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native ("NEVPNIKEv2DiffieHellmanGroup")] public enum NEVpnIke2DiffieHellman : long { Invalid = 0, @@ -83,11 +93,13 @@ public enum NEVpnIke2DiffieHellman : long { Group19 = 19, Group20 = 20, Group21 = 21, - [Mac (10,15)][iOS (13,0)] + [Mac (10, 15)] + [iOS (13, 0)] Group31 = 31, } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native] public enum NEOnDemandRuleAction : long { Connect = 1, @@ -96,7 +108,8 @@ public enum NEOnDemandRuleAction : long { Ignore = 4 } - [iOS (8,0)][Mac (10,11)] + [iOS (8, 0)] + [Mac (10, 11)] [Native] public enum NEOnDemandRuleInterfaceType : long { Any = 0, @@ -105,26 +118,29 @@ public enum NEOnDemandRuleInterfaceType : long { Cellular = 3 } - [iOS (8,0)][Mac (10,10)] + [iOS (8, 0)] + [Mac (10, 10)] [Native] public enum NEEvaluateConnectionRuleAction : long { ConnectIfNeeded = 1, NeverConnect = 2 } - [iOS (8,3)][Mac (10,11)] + [iOS (8, 3)] + [Mac (10, 11)] [Native ("NEVPNIKEv2CertificateType")] // NSInteger public enum NEVpnIke2CertificateType : long { RSA = 1, ECDSA256 = 2, ECDSA384 = 3, ECDSA521 = 4, - [Mac (10,15)][iOS (13,0)] + [Mac (10, 15)] + [iOS (13, 0)] Ed25519 = 5, } // in Xcode7 SDK but marked as 8.0 - [iOS (8,0)] + [iOS (8, 0)] [ErrorDomain ("NEFilterErrorDomain")] [Native] public enum NEFilterManagerError : long { @@ -137,7 +153,7 @@ public enum NEFilterManagerError : long { ConfigurationInternalError = 6, } - [iOS (9,0)] + [iOS (9, 0)] [ErrorDomain ("NETunnelProviderErrorDomain")] [Native] public enum NETunnelProviderError : long { @@ -147,7 +163,7 @@ public enum NETunnelProviderError : long { Failed = 3 } - [iOS (9,0)] + [iOS (9, 0)] [ErrorDomain ("NEAppProxyErrorDomain")] [Native] public enum NEAppProxyFlowError : long { @@ -165,10 +181,9 @@ public enum NEAppProxyFlowError : long { ReadAlreadyPending = 10, } - [iOS (9,0)] + [iOS (9, 0)] [Native] - public enum NEProviderStopReason : long - { + public enum NEProviderStopReason : long { None = 0, UserInitiated = 1, ProviderFailed = 2, @@ -184,26 +199,26 @@ public enum NEProviderStopReason : long UserLogout = 12, UserSwitch = 13, ConnectionFailed = 14, - [Mac (10,15)][iOS (13,0)] + [Mac (10, 15)] + [iOS (13, 0)] Sleep = 15, - [Mac (10,15)][iOS (13,0)] + [Mac (10, 15)] + [iOS (13, 0)] AppUpdate, } - [iOS (9,0)] + [iOS (9, 0)] [Native] - public enum NWPathStatus : long - { + public enum NWPathStatus : long { Invalid = 0, Satisfied = 1, Unsatisfied = 2, Satisfiable = 3 } - - [iOS (9,0)] + + [iOS (9, 0)] [Native] - public enum NWTcpConnectionState : long - { + public enum NWTcpConnectionState : long { Invalid = 0, Connecting = 1, Waiting = 2, @@ -212,10 +227,9 @@ public enum NWTcpConnectionState : long Cancelled = 5 } - [iOS (9,0)] + [iOS (9, 0)] [Native] - public enum NWUdpSessionState : long - { + public enum NWUdpSessionState : long { Invalid = 0, Waiting = 1, Preparing = 2, @@ -223,19 +237,21 @@ public enum NWUdpSessionState : long Failed = 4, Cancelled = 5 } - - [iOS (9,0)][Mac (10,11)] + + [iOS (9, 0)] + [Mac (10, 11)] [Native] public enum NETunnelProviderRoutingMethod : long { DestinationIP = 1, SourceApplication = 2, - [Mac (10,15)][NoiOS] + [Mac (10, 15)] + [NoiOS] NetworkRule = 3, } #if !MONOMAC [NoMac] - [iOS (9,0)] + [iOS (9, 0)] [Native] public enum NEHotspotHelperCommandType : long { None = 0, @@ -248,7 +264,7 @@ public enum NEHotspotHelperCommandType : long { } [NoMac] - [iOS (9,0)] + [iOS (9, 0)] [Native] public enum NEHotspotHelperConfidence : long { None = 0, @@ -257,7 +273,7 @@ public enum NEHotspotHelperConfidence : long { } [NoMac] - [iOS (9,0)] + [iOS (9, 0)] [Native] public enum NEHotspotHelperResult : long { Success = 0, @@ -270,7 +286,7 @@ public enum NEHotspotHelperResult : long { } #endif - [NoWatch, NoTV, NoMac, iOS (14,0)] + [NoWatch, NoTV, NoMac, iOS (14, 0)] [Native] [ErrorDomain ("NEAppPushErrorDomain")] public enum NEAppPushManagerError : long { @@ -280,7 +296,7 @@ public enum NEAppPushManagerError : long { InactiveSession = 4, } - [NoWatch, NoTV, Mac (11,0), iOS (14,0)] + [NoWatch, NoTV, Mac (11, 0), iOS (14, 0)] [Native ("NEDNSProtocol")] public enum NEDnsProtocol : long { Cleartext = 1, @@ -288,7 +304,7 @@ public enum NEDnsProtocol : long { Https = 3, } - [NoWatch, NoTV, Mac (11,0), iOS (14,0)] + [NoWatch, NoTV, Mac (11, 0), iOS (14, 0)] [Native ("NEDNSSettingsManagerError")] [ErrorDomain ("NEDNSSettingsErrorDomain")] public enum NEDnsSettingsManagerError : long { diff --git a/src/NetworkExtension/NEHotspotConfiguration.cs b/src/NetworkExtension/NEHotspotConfiguration.cs index 69f6a34e8d96..88a4648f7e19 100644 --- a/src/NetworkExtension/NEHotspotConfiguration.cs +++ b/src/NetworkExtension/NEHotspotConfiguration.cs @@ -26,7 +26,7 @@ public NEHotspotConfiguration (string ssid, string passphrase, bool isWep) [UnsupportedOSPlatform ("macos")] [UnsupportedOSPlatform ("tvos")] #else - [iOS (13,0)] + [iOS (13, 0)] #endif public NEHotspotConfiguration (string ssid, bool ssidIsPrefix) { @@ -40,7 +40,7 @@ public NEHotspotConfiguration (string ssid, bool ssidIsPrefix) [UnsupportedOSPlatform ("macos")] [UnsupportedOSPlatform ("tvos")] #else - [iOS (13,0)] + [iOS (13, 0)] #endif public NEHotspotConfiguration (string ssid, string passphrase, bool isWep, bool ssidIsPrefix) { diff --git a/src/NetworkExtension/NEHotspotHelperOptions.cs b/src/NetworkExtension/NEHotspotHelperOptions.cs index 378f4550c9df..44d5aefd1ca1 100644 --- a/src/NetworkExtension/NEHotspotHelperOptions.cs +++ b/src/NetworkExtension/NEHotspotHelperOptions.cs @@ -9,8 +9,8 @@ namespace NetworkExtension { public class NEHotspotHelperOptions : DictionaryContainer { #if !COREBUILD - public NEHotspotHelperOptions () : base (new NSMutableDictionary ()) {} - public NEHotspotHelperOptions (NSDictionary dictionary) : base (dictionary) {} + public NEHotspotHelperOptions () : base (new NSMutableDictionary ()) { } + public NEHotspotHelperOptions (NSDictionary dictionary) : base (dictionary) { } public NSString? DisplayName { get { diff --git a/src/NetworkExtension/NEVpnConnectionStartOptions.cs b/src/NetworkExtension/NEVpnConnectionStartOptions.cs index 2f8d18a6254c..5b9030aac67a 100644 --- a/src/NetworkExtension/NEVpnConnectionStartOptions.cs +++ b/src/NetworkExtension/NEVpnConnectionStartOptions.cs @@ -14,8 +14,8 @@ namespace NetworkExtension { public class NEVpnConnectionStartOptions : DictionaryContainer { #if !COREBUILD - public NEVpnConnectionStartOptions () : base (new NSMutableDictionary ()) {} - public NEVpnConnectionStartOptions (NSDictionary dictionary) : base (dictionary) {} + public NEVpnConnectionStartOptions () : base (new NSMutableDictionary ()) { } + public NEVpnConnectionStartOptions (NSDictionary dictionary) : base (dictionary) { } public NSString? Username { get { diff --git a/src/NotificationCenter/NCEnums.cs b/src/NotificationCenter/NCEnums.cs index 213c295ec40b..58216cd4f2aa 100644 --- a/src/NotificationCenter/NCEnums.cs +++ b/src/NotificationCenter/NCEnums.cs @@ -10,9 +10,10 @@ namespace NotificationCenter { - [iOS (8,0)][Mac (10,10)] - [Deprecated (PlatformName.iOS, 14,0)] - [Deprecated (PlatformName.MacOSX, 11,0)] + [iOS (8, 0)] + [Mac (10, 10)] + [Deprecated (PlatformName.iOS, 14, 0)] + [Deprecated (PlatformName.MacOSX, 11, 0)] [Native] public enum NCUpdateResult : ulong { NewData, @@ -20,8 +21,9 @@ public enum NCUpdateResult : ulong { Failed } - [iOS (10,0)][NoMac] - [Deprecated (PlatformName.iOS, 14,0)] + [iOS (10, 0)] + [NoMac] + [Deprecated (PlatformName.iOS, 14, 0)] [Native] public enum NCWidgetDisplayMode : long { Compact, diff --git a/tools/autoformat.sh b/tools/autoformat.sh index 9a69236b342f..c6f9c3d67aa1 100755 --- a/tools/autoformat.sh +++ b/tools/autoformat.sh @@ -108,6 +108,9 @@ dotnet format whitespace --folder "$SRC_DIR/src/MediaAccessibility" dotnet format whitespace --folder "$SRC_DIR/src/MediaLibrary" dotnet format whitespace --folder "$SRC_DIR/src/MediaPlayer" dotnet format whitespace --folder "$SRC_DIR/src/MediaToolbox" +dotnet format whitespace --folder "$SRC_DIR/src/Network" +dotnet format whitespace --folder "$SRC_DIR/src/NetworkExtension" +dotnet format whitespace --folder "$SRC_DIR/src/NotificationCenter" dotnet format whitespace --folder "$SRC_DIR/src/SceneKit" dotnet format whitespace --folder "$SRC_DIR/src/Security" dotnet format whitespace --folder "$SRC_DIR/src/SensorKit"