From 87a68aab12919ec4388a837df0e78def0373588d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 30 May 2024 11:54:37 +0200 Subject: [PATCH] [Network] Make the remaining P/Invokes have blittable signatures. Contributes towards #15684. --- src/Network/NWContentContext.cs | 9 ++- src/Network/NWEndpoint.cs | 5 +- src/Network/NWEstablishmentReport.cs | 10 ++- src/Network/NWMulticastGroup.cs | 12 ++-- src/Network/NWParameters.cs | 72 +++++++++---------- src/Network/NWPath.cs | 35 ++++----- src/Network/NWPrivacyContext.cs | 4 +- src/Network/NWTxtRecord.cs | 22 +++--- .../BlittablePInvokes.KnownFailures.cs | 36 ---------- 9 files changed, 73 insertions(+), 132 deletions(-) diff --git a/src/Network/NWContentContext.cs b/src/Network/NWContentContext.cs index de9f00eea4b3..7d1f21bdfa48 100644 --- a/src/Network/NWContentContext.cs +++ b/src/Network/NWContentContext.cs @@ -83,15 +83,14 @@ public NWContentContext (string contextIdentifier) public string? Identifier => Marshal.PtrToStringAnsi (nw_content_context_get_identifier (GetCheckedHandle ())); [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool nw_content_context_get_is_final (IntPtr handle); + extern static byte nw_content_context_get_is_final (IntPtr handle); [DllImport (Constants.NetworkLibrary)] - extern static void nw_content_context_set_is_final (IntPtr handle, [MarshalAs (UnmanagedType.I1)] bool is_final); + extern static void nw_content_context_set_is_final (IntPtr handle, byte is_final); public bool IsFinal { - get => nw_content_context_get_is_final (GetCheckedHandle ()); - set => nw_content_context_set_is_final (GetCheckedHandle (), value); + get => nw_content_context_get_is_final (GetCheckedHandle ()) != 0; + set => nw_content_context_set_is_final (GetCheckedHandle (), value.AsByte ()); } [DllImport (Constants.NetworkLibrary)] diff --git a/src/Network/NWEndpoint.cs b/src/Network/NWEndpoint.cs index 7e3da222ffbe..ce83caa597ee 100644 --- a/src/Network/NWEndpoint.cs +++ b/src/Network/NWEndpoint.cs @@ -211,7 +211,7 @@ static string nw_endpoint_copy_address_string (OS_nw_endpoint endpoint) [Watch (9, 0)] #endif [DllImport (Constants.NetworkLibrary)] - static extern unsafe byte* nw_endpoint_get_signature (OS_nw_endpoint endpoint, out nuint out_signature_length); + static extern unsafe byte* nw_endpoint_get_signature (OS_nw_endpoint endpoint, nuint* out_signature_length); #if NET [SupportedOSPlatform ("tvos16.0")] @@ -227,7 +227,8 @@ static string nw_endpoint_copy_address_string (OS_nw_endpoint endpoint) public ReadOnlySpan Signature { get { unsafe { - var data = nw_endpoint_get_signature (GetCheckedHandle (), out var length); + nuint length; + var data = nw_endpoint_get_signature (GetCheckedHandle (), &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. diff --git a/src/Network/NWEstablishmentReport.cs b/src/Network/NWEstablishmentReport.cs index 8fd6ec1d6628..943a548cc363 100644 --- a/src/Network/NWEstablishmentReport.cs +++ b/src/Network/NWEstablishmentReport.cs @@ -45,16 +45,14 @@ public class NWEstablishmentReport : NativeObject { internal NWEstablishmentReport (NativeHandle handle, bool owns) : base (handle, owns) { } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_establishment_report_get_used_proxy (OS_nw_establishment_report report); + static extern byte nw_establishment_report_get_used_proxy (OS_nw_establishment_report report); - public bool UsedProxy => nw_establishment_report_get_used_proxy (GetCheckedHandle ()); + public bool UsedProxy => nw_establishment_report_get_used_proxy (GetCheckedHandle ()) != 0; [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_establishment_report_get_proxy_configured (OS_nw_establishment_report report); + static extern byte nw_establishment_report_get_proxy_configured (OS_nw_establishment_report report); - public bool ProxyConfigured => nw_establishment_report_get_proxy_configured (GetCheckedHandle ()); + public bool ProxyConfigured => nw_establishment_report_get_proxy_configured (GetCheckedHandle ()) != 0; [DllImport (Constants.NetworkLibrary)] static extern uint nw_establishment_report_get_previous_attempt_count (OS_nw_establishment_report report); diff --git a/src/Network/NWMulticastGroup.cs b/src/Network/NWMulticastGroup.cs index 56130206f909..e45a414c91a1 100644 --- a/src/Network/NWMulticastGroup.cs +++ b/src/Network/NWMulticastGroup.cs @@ -42,8 +42,7 @@ public NWMulticastGroup (NWEndpoint endpoint) } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_group_descriptor_add_endpoint (OS_nw_group_descriptor descriptor, OS_nw_endpoint endpoint); + static extern byte nw_group_descriptor_add_endpoint (OS_nw_group_descriptor descriptor, OS_nw_endpoint endpoint); public void AddEndpoint (NWEndpoint endpoint) { @@ -53,15 +52,14 @@ public void AddEndpoint (NWEndpoint endpoint) } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_multicast_group_descriptor_get_disable_unicast_traffic (OS_nw_group_descriptor multicast_descriptor); + static extern byte nw_multicast_group_descriptor_get_disable_unicast_traffic (OS_nw_group_descriptor multicast_descriptor); [DllImport (Constants.NetworkLibrary)] - static extern void nw_multicast_group_descriptor_set_disable_unicast_traffic (OS_nw_group_descriptor multicast_descriptor, [MarshalAs (UnmanagedType.I1)] bool disable_unicast_traffic); + static extern void nw_multicast_group_descriptor_set_disable_unicast_traffic (OS_nw_group_descriptor multicast_descriptor, byte disable_unicast_traffic); public bool DisabledUnicastTraffic { - get => nw_multicast_group_descriptor_get_disable_unicast_traffic (GetCheckedHandle ()); - set => nw_multicast_group_descriptor_set_disable_unicast_traffic (GetCheckedHandle (), value); + get => nw_multicast_group_descriptor_get_disable_unicast_traffic (GetCheckedHandle ()) != 0; + set => nw_multicast_group_descriptor_set_disable_unicast_traffic (GetCheckedHandle (), value.AsByte ()); } [DllImport (Constants.NetworkLibrary)] diff --git a/src/Network/NWParameters.cs b/src/Network/NWParameters.cs index 89a29f95a493..2140e0e5d4c3 100644 --- a/src/Network/NWParameters.cs +++ b/src/Network/NWParameters.cs @@ -288,27 +288,25 @@ public NWMultiPathService MultipathService { public NWProtocolStack ProtocolStack => new NWProtocolStack (nw_parameters_copy_default_protocol_stack (GetCheckedHandle ()), owns: true); [DllImport (Constants.NetworkLibrary)] - static extern void nw_parameters_set_local_only (nw_parameters_t parameters, [MarshalAs (UnmanagedType.I1)] bool local_only); + static extern void nw_parameters_set_local_only (nw_parameters_t parameters, byte local_only); [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_parameters_get_local_only (nw_parameters_t parameters); + static extern byte nw_parameters_get_local_only (nw_parameters_t parameters); public bool LocalOnly { - get => nw_parameters_get_local_only (GetCheckedHandle ()); - set => nw_parameters_set_local_only (GetCheckedHandle (), value); + get => nw_parameters_get_local_only (GetCheckedHandle ()) != 0; + set => nw_parameters_set_local_only (GetCheckedHandle (), value.AsByte ()); } [DllImport (Constants.NetworkLibrary)] - static extern void nw_parameters_set_prefer_no_proxy (nw_parameters_t parameters, [MarshalAs (UnmanagedType.I1)] bool prefer_no_proxy); + static extern void nw_parameters_set_prefer_no_proxy (nw_parameters_t parameters, byte prefer_no_proxy); [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_parameters_get_prefer_no_proxy (nw_parameters_t parameters); + static extern byte nw_parameters_get_prefer_no_proxy (nw_parameters_t parameters); public bool PreferNoProxy { - get => nw_parameters_get_prefer_no_proxy (GetCheckedHandle ()); - set => nw_parameters_set_prefer_no_proxy (GetCheckedHandle (), value); + get => nw_parameters_get_prefer_no_proxy (GetCheckedHandle ()) != 0; + set => nw_parameters_set_prefer_no_proxy (GetCheckedHandle (), value.AsByte ()); } [DllImport (Constants.NetworkLibrary)] @@ -461,39 +459,36 @@ public void IterateProhibitedInterfaces (Func callback) } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_parameters_get_prohibit_expensive (IntPtr handle); + static extern byte nw_parameters_get_prohibit_expensive (IntPtr handle); [DllImport (Constants.NetworkLibrary)] - static extern void nw_parameters_set_prohibit_expensive (IntPtr handle, [MarshalAs (UnmanagedType.I1)] bool prohibit_expensive); + static extern void nw_parameters_set_prohibit_expensive (IntPtr handle, byte prohibit_expensive); public bool ProhibitExpensive { - get => nw_parameters_get_prohibit_expensive (GetCheckedHandle ()); - set => nw_parameters_set_prohibit_expensive (GetCheckedHandle (), value); + get => nw_parameters_get_prohibit_expensive (GetCheckedHandle ()) != 0; + set => nw_parameters_set_prohibit_expensive (GetCheckedHandle (), value.AsByte ()); } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_parameters_get_reuse_local_address (IntPtr handle); + static extern byte nw_parameters_get_reuse_local_address (IntPtr handle); [DllImport (Constants.NetworkLibrary)] - static extern void nw_parameters_set_reuse_local_address (IntPtr handle, [MarshalAs (UnmanagedType.I1)] bool reuse_local_address); + static extern void nw_parameters_set_reuse_local_address (IntPtr handle, byte reuse_local_address); public bool ReuseLocalAddress { - get => nw_parameters_get_reuse_local_address (GetCheckedHandle ()); - set => nw_parameters_set_reuse_local_address (GetCheckedHandle (), value); + get => nw_parameters_get_reuse_local_address (GetCheckedHandle ()) != 0; + set => nw_parameters_set_reuse_local_address (GetCheckedHandle (), value.AsByte ()); } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_parameters_get_fast_open_enabled (IntPtr handle); + static extern byte nw_parameters_get_fast_open_enabled (IntPtr handle); [DllImport (Constants.NetworkLibrary)] - static extern void nw_parameters_set_fast_open_enabled (IntPtr handle, [MarshalAs (UnmanagedType.I1)] bool fast_open_enabled); + static extern void nw_parameters_set_fast_open_enabled (IntPtr handle, byte fast_open_enabled); public bool FastOpenEnabled { - get => nw_parameters_get_fast_open_enabled (GetCheckedHandle ()); - set => nw_parameters_set_fast_open_enabled (GetCheckedHandle (), value); + get => nw_parameters_get_fast_open_enabled (GetCheckedHandle ()) != 0; + set => nw_parameters_set_fast_open_enabled (GetCheckedHandle (), value.AsByte ()); } [DllImport (Constants.NetworkLibrary)] @@ -529,15 +524,14 @@ public NWEndpoint? LocalEndpoint { [DllImport (Constants.NetworkLibrary)] - static extern void nw_parameters_set_include_peer_to_peer (IntPtr handle, [MarshalAs (UnmanagedType.I1)] bool includePeerToPeer); + static extern void nw_parameters_set_include_peer_to_peer (IntPtr handle, byte includePeerToPeer); [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_parameters_get_include_peer_to_peer (IntPtr handle); + static extern byte nw_parameters_get_include_peer_to_peer (IntPtr handle); public bool IncludePeerToPeer { - get => nw_parameters_get_include_peer_to_peer (GetCheckedHandle ()); - set => nw_parameters_set_include_peer_to_peer (GetCheckedHandle (), value); + get => nw_parameters_get_include_peer_to_peer (GetCheckedHandle ()) != 0; + set => nw_parameters_set_include_peer_to_peer (GetCheckedHandle (), value.AsByte ()); } #if NET @@ -550,8 +544,7 @@ public bool IncludePeerToPeer { [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_parameters_get_prohibit_constrained (IntPtr parameters); + static extern byte nw_parameters_get_prohibit_constrained (IntPtr parameters); #if NET [SupportedOSPlatform ("tvos13.0")] @@ -563,7 +556,7 @@ public bool IncludePeerToPeer { [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] - static extern void nw_parameters_set_prohibit_constrained (IntPtr parameters, [MarshalAs (UnmanagedType.I1)] bool prohibit_constrained); + static extern void nw_parameters_set_prohibit_constrained (IntPtr parameters, byte prohibit_constrained); #if NET [SupportedOSPlatform ("tvos13.0")] @@ -575,8 +568,8 @@ public bool IncludePeerToPeer { [iOS (13, 0)] #endif public bool ProhibitConstrained { - get => nw_parameters_get_prohibit_constrained (GetCheckedHandle ()); - set => nw_parameters_set_prohibit_constrained (GetCheckedHandle (), value); + get => nw_parameters_get_prohibit_constrained (GetCheckedHandle ()) != 0; + set => nw_parameters_set_prohibit_constrained (GetCheckedHandle (), value.AsByte ()); } #if NET @@ -708,9 +701,8 @@ public unsafe static NWParameters CreateQuic (Action? configu [iOS (16, 0)] [Watch (9, 0)] #endif - [return: MarshalAs (UnmanagedType.I1)] [DllImport (Constants.NetworkLibrary)] - static extern bool nw_parameters_requires_dnssec_validation (OS_nw_parameters parameters); + static extern byte nw_parameters_requires_dnssec_validation (OS_nw_parameters parameters); #if NET [SupportedOSPlatform ("tvos16.0")] @@ -724,7 +716,7 @@ public unsafe static NWParameters CreateQuic (Action? configu [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); + static extern void nw_parameters_set_requires_dnssec_validation (OS_nw_parameters parameters, byte requires_dnssec_validation); #if NET [SupportedOSPlatform ("tvos16.0")] @@ -738,8 +730,8 @@ public unsafe static NWParameters CreateQuic (Action? configu [Watch (9, 0)] #endif public bool RequiresDnssecValidation { - get => nw_parameters_requires_dnssec_validation (GetCheckedHandle ()); - set => nw_parameters_set_requires_dnssec_validation (GetCheckedHandle (), value); + get => nw_parameters_requires_dnssec_validation (GetCheckedHandle ()) != 0; + set => nw_parameters_set_requires_dnssec_validation (GetCheckedHandle (), value.AsByte ()); } } } diff --git a/src/Network/NWPath.cs b/src/Network/NWPath.cs index 539107f8b1c3..c5c3f4debaa7 100644 --- a/src/Network/NWPath.cs +++ b/src/Network/NWPath.cs @@ -47,34 +47,29 @@ public NWPath (NativeHandle handle, bool owns) : base (handle, owns) { } public NWPathStatus Status => nw_path_get_status (GetCheckedHandle ()); [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.U1)] - extern static bool nw_path_is_expensive (IntPtr handle); + extern static byte nw_path_is_expensive (IntPtr handle); - public bool IsExpensive => nw_path_is_expensive (GetCheckedHandle ()); + public bool IsExpensive => nw_path_is_expensive (GetCheckedHandle ()) != 0; [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.U1)] - extern static bool nw_path_has_ipv4 (IntPtr handle); + extern static byte nw_path_has_ipv4 (IntPtr handle); - public bool HasIPV4 => nw_path_has_ipv4 (GetCheckedHandle ()); + public bool HasIPV4 => nw_path_has_ipv4 (GetCheckedHandle ()) != 0; [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.U1)] - extern static bool nw_path_has_ipv6 (IntPtr handle); + extern static byte nw_path_has_ipv6 (IntPtr handle); - public bool HasIPV6 => nw_path_has_ipv6 (GetCheckedHandle ()); + public bool HasIPV6 => nw_path_has_ipv6 (GetCheckedHandle ()) != 0; [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.U1)] - extern static bool nw_path_has_dns (IntPtr handle); + extern static byte nw_path_has_dns (IntPtr handle); - public bool HasDns => nw_path_has_dns (GetCheckedHandle ()); + public bool HasDns => nw_path_has_dns (GetCheckedHandle ()) != 0; [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.U1)] - extern static bool nw_path_uses_interface_type (IntPtr handle, NWInterfaceType type); + extern static byte nw_path_uses_interface_type (IntPtr handle, NWInterfaceType type); - public bool UsesInterfaceType (NWInterfaceType type) => nw_path_uses_interface_type (GetCheckedHandle (), type); + public bool UsesInterfaceType (NWInterfaceType type) => nw_path_uses_interface_type (GetCheckedHandle (), type) != 0; [DllImport (Constants.NetworkLibrary)] extern static IntPtr nw_path_copy_effective_local_endpoint (IntPtr handle); @@ -101,15 +96,14 @@ public NWEndpoint? EffectiveRemoteEndpoint { } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.U1)] - extern static bool nw_path_is_equal (IntPtr p1, IntPtr p2); + extern static byte nw_path_is_equal (IntPtr p1, IntPtr p2); public bool EqualsTo (NWPath other) { if (other is null) return false; - return nw_path_is_equal (GetCheckedHandle (), other.Handle); + return nw_path_is_equal (GetCheckedHandle (), other.Handle) != 0; } // Returning 'byte' since 'bool' isn't blittable @@ -177,8 +171,7 @@ public void EnumerateInterfaces (Func callback) [iOS (13, 0)] #endif [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_path_is_constrained (IntPtr path); + static extern byte nw_path_is_constrained (IntPtr path); #if NET [SupportedOSPlatform ("tvos13.0")] @@ -189,7 +182,7 @@ public void EnumerateInterfaces (Func callback) [TV (13, 0)] [iOS (13, 0)] #endif - public bool IsConstrained => nw_path_is_constrained (GetCheckedHandle ()); + public bool IsConstrained => nw_path_is_constrained (GetCheckedHandle ()) != 0; #if NET [SupportedOSPlatform ("tvos13.0")] diff --git a/src/Network/NWPrivacyContext.cs b/src/Network/NWPrivacyContext.cs index 5292000a0233..636727d16f7a 100644 --- a/src/Network/NWPrivacyContext.cs +++ b/src/Network/NWPrivacyContext.cs @@ -63,10 +63,10 @@ public void DisableLogging () => 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); + static extern void nw_privacy_context_require_encrypted_name_resolution (OS_nw_privacy_context privacyContext, byte requireEncryptedNameResolution, OS_nw_resolver_config fallbackResolverConfig); public void RequireEncryptedNameResolution (bool requireEncryptedNameResolution, NWResolverConfig? fallbackResolverConfig) - => nw_privacy_context_require_encrypted_name_resolution (GetCheckedHandle (), requireEncryptedNameResolution, fallbackResolverConfig.GetHandle ()); + => nw_privacy_context_require_encrypted_name_resolution (GetCheckedHandle (), requireEncryptedNameResolution.AsByte (), fallbackResolverConfig.GetHandle ()); #if NET [SupportedOSPlatform ("tvos17.0")] diff --git a/src/Network/NWTxtRecord.cs b/src/Network/NWTxtRecord.cs index e07bc003a338..73f86ed0640d 100644 --- a/src/Network/NWTxtRecord.cs +++ b/src/Network/NWTxtRecord.cs @@ -129,19 +129,17 @@ static byte nw_txt_record_remove_key (IntPtr handle, string key) public bool IsDictionary => nw_txt_record_is_dictionary (GetCheckedHandle ()) != 0; [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool nw_txt_record_is_equal (OS_nw_txt_record left, OS_nw_txt_record right); + static extern byte nw_txt_record_is_equal (OS_nw_txt_record left, OS_nw_txt_record right); public bool Equals (NWTxtRecord other) { if (other is null) return false; - return nw_txt_record_is_equal (GetCheckedHandle (), other.GetCheckedHandle ()); + return nw_txt_record_is_equal (GetCheckedHandle (), other.GetCheckedHandle ()) != 0; } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - unsafe static extern bool nw_txt_record_apply (OS_nw_txt_record txt_record, BlockLiteral* applier); + unsafe static extern byte nw_txt_record_apply (OS_nw_txt_record txt_record, BlockLiteral* applier); #if !NET delegate byte nw_txt_record_apply_t (IntPtr block, IntPtr key, NWTxtRecordFindKey found, IntPtr value, nuint valueLen); @@ -203,7 +201,7 @@ public bool Apply (NWTxtRecordApplyDelegate handler) using var block = new BlockLiteral (); block.SetupBlockUnsafe (static_ApplyHandler, handler); #endif - return nw_txt_record_apply (GetCheckedHandle (), &block); + return nw_txt_record_apply (GetCheckedHandle (), &block) != 0; } } @@ -217,14 +215,13 @@ public bool Apply (NWTxtRecordApplyDelegate2 handler) unsafe { using var block = new BlockLiteral (); block.SetupBlockUnsafe (static_ApplyHandler, handler); - return nw_txt_record_apply (GetCheckedHandle (), &block); + return nw_txt_record_apply (GetCheckedHandle (), &block) != 0; } } #endif [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern unsafe bool nw_txt_record_access_key (OS_nw_txt_record txt_record, IntPtr key, BlockLiteral* access_value); + static extern unsafe byte nw_txt_record_access_key (OS_nw_txt_record txt_record, IntPtr key, BlockLiteral* access_value); #if !NET unsafe delegate void nw_txt_record_access_key_t (IntPtr IntPtr, IntPtr key, NWTxtRecordFindKey found, IntPtr value, nuint valueLen); @@ -267,13 +264,12 @@ public bool GetValue (string key, NWTxtRecordGetValueDelegete handler) block.SetupBlockUnsafe (static_AccessKeyHandler, handler); #endif using var keyPtr = new TransientString (key); - return nw_txt_record_access_key (GetCheckedHandle (), keyPtr, &block); + return nw_txt_record_access_key (GetCheckedHandle (), keyPtr, &block) != 0; } } [DllImport (Constants.NetworkLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - unsafe static extern bool nw_txt_record_access_bytes (OS_nw_txt_record txt_record, BlockLiteral* access_bytes); + unsafe static extern byte nw_txt_record_access_bytes (OS_nw_txt_record txt_record, BlockLiteral* access_bytes); #if !NET unsafe delegate void nw_txt_record_access_bytes_t (IntPtr block, IntPtr value, nuint valueLen); @@ -310,7 +306,7 @@ public bool GetRawBytes (NWTxtRecordGetRawByteDelegate handler) using var block = new BlockLiteral (); block.SetupBlockUnsafe (static_RawBytesHandler, handler); #endif - return nw_txt_record_access_bytes (GetCheckedHandle (), &block); + return nw_txt_record_access_bytes (GetCheckedHandle (), &block) != 0; } } } diff --git a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs index d5d360d4f9e1..1e5259183f19 100644 --- a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs +++ b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs @@ -27,45 +27,9 @@ public partial class BlittablePInvokes { "AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSend(System.IntPtr,System.IntPtr)", "AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(System.IntPtr,System.IntPtr)", "AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)", - "System.Boolean Network.NWContentContext::nw_content_context_get_is_final(System.IntPtr)", - "System.Boolean Network.NWEstablishmentReport::nw_establishment_report_get_proxy_configured(System.IntPtr)", - "System.Boolean Network.NWEstablishmentReport::nw_establishment_report_get_used_proxy(System.IntPtr)", - "System.Boolean Network.NWMulticastGroup::nw_group_descriptor_add_endpoint(System.IntPtr,System.IntPtr)", - "System.Boolean Network.NWMulticastGroup::nw_multicast_group_descriptor_get_disable_unicast_traffic(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_get_fast_open_enabled(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_get_include_peer_to_peer(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_get_local_only(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_get_prefer_no_proxy(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_get_prohibit_constrained(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_get_prohibit_expensive(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_get_reuse_local_address(System.IntPtr)", - "System.Boolean Network.NWParameters::nw_parameters_requires_dnssec_validation(System.IntPtr)", - "System.Boolean Network.NWPath::nw_path_has_dns(System.IntPtr)", - "System.Boolean Network.NWPath::nw_path_has_ipv4(System.IntPtr)", - "System.Boolean Network.NWPath::nw_path_has_ipv6(System.IntPtr)", - "System.Boolean Network.NWPath::nw_path_is_constrained(System.IntPtr)", - "System.Boolean Network.NWPath::nw_path_is_equal(System.IntPtr,System.IntPtr)", - "System.Boolean Network.NWPath::nw_path_is_expensive(System.IntPtr)", - "System.Boolean Network.NWPath::nw_path_uses_interface_type(System.IntPtr,Network.NWInterfaceType)", - "System.Boolean Network.NWTxtRecord::nw_txt_record_access_bytes(System.IntPtr,ObjCRuntime.BlockLiteral*)", - "System.Boolean Network.NWTxtRecord::nw_txt_record_access_key(System.IntPtr,System.IntPtr,ObjCRuntime.BlockLiteral*)", - "System.Boolean Network.NWTxtRecord::nw_txt_record_apply(System.IntPtr,ObjCRuntime.BlockLiteral*)", - "System.Boolean Network.NWTxtRecord::nw_txt_record_is_equal(System.IntPtr,System.IntPtr)", - "System.Byte* Network.NWEndpoint::nw_endpoint_get_signature(System.IntPtr,System.UIntPtr&)", "System.Int32 AudioUnit.AUGraph::NewAUGraph(System.IntPtr&)", "System.IntPtr ObjCRuntime.Selector::GetHandle(System.String)", "System.IntPtr Security.SecKey::SecKeyCreateEncryptedData(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)", - "System.Void Network.NWContentContext::nw_content_context_set_is_final(System.IntPtr,System.Boolean)", - "System.Void Network.NWMulticastGroup::nw_multicast_group_descriptor_set_disable_unicast_traffic(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_fast_open_enabled(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_include_peer_to_peer(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_local_only(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_prefer_no_proxy(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_prohibit_constrained(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_prohibit_expensive(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_requires_dnssec_validation(System.IntPtr,System.Boolean)", - "System.Void Network.NWParameters::nw_parameters_set_reuse_local_address(System.IntPtr,System.Boolean)", - "System.Void Network.NWPrivacyContext::nw_privacy_context_require_encrypted_name_resolution(System.IntPtr,System.Boolean,System.IntPtr)", "System.Void ObjCRuntime.Messaging::void_objc_msgSend_GCDualSenseAdaptiveTriggerPositionalAmplitudes_float(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalAmplitudes,System.Single)", "System.Void ObjCRuntime.Messaging::void_objc_msgSend_GCDualSenseAdaptiveTriggerPositionalResistiveStrengths(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalResistiveStrengths)", "System.Void ObjCRuntime.Messaging::void_objc_msgSendSuper_GCDualSenseAdaptiveTriggerPositionalAmplitudes_float(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalAmplitudes,System.Single)",