From a25e98d7faa3b130889cbefdfe0d252539f39874 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 9 Jun 2025 13:11:02 +0200 Subject: [PATCH 1/9] feeedback --- .../tests/TestUtilities/System/PlatformDetection.cs | 1 + .../Runtime/InteropServices/ComponentActivator.cs | 2 ++ .../src/System/Runtime/InteropServices/Marshal.cs | 6 ++++++ .../ref/System.Runtime.InteropServices.cs | 4 ++++ .../Marshal/GetDelegateForFunctionPointerTests.cs | 2 +- .../Marshal/GetFunctionPointerForDelegateTests.cs | 12 ++++-------- src/mono/browser/runtime/runtime.c | 2 ++ src/mono/mono/mini/interp/interp.c | 8 ++++++++ 8 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 9a7ef0734ad082..f1699137caec4d 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -33,6 +33,7 @@ public static partial class PlatformDetection public static bool IsNotMonoInterpreter => !IsMonoInterpreter; public static bool IsMonoAOT => Environment.GetEnvironmentVariable("MONO_AOT_MODE") == "aot"; public static bool IsNotMonoAOT => Environment.GetEnvironmentVariable("MONO_AOT_MODE") != "aot"; + public static bool IsNotMonoAOTOrBrowser => IsNotMonoAOT && !IsBrowser; public static bool IsNativeAot => IsNotMonoRuntime && !IsReflectionEmitSupported; public static bool IsNotNativeAot => !IsNativeAot; public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")); diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs index 33d08bf108174c..e8f9d9dc7ed433 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs @@ -350,7 +350,9 @@ private static IntPtr InternalGetFunctionPointer(AssemblyLoadContext alc, { Delegate d = Delegate.CreateDelegate(delegateType, type, methodName)!; +#pragma warning disable CA1416 // This call site is reachable on all platforms. functionPtr = Marshal.GetFunctionPointerForDelegate(d); +#pragma warning restore CA1416 lock (s_delegates) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index a2b30029b0216f..e62390bab45f8f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -1137,15 +1137,21 @@ public static TDelegate GetDelegateForFunctionPointer(IntPtr ptr) [RequiresDynamicCode("Marshalling code for the delegate might not be available. Use the GetFunctionPointerForDelegate overload instead.")] [EditorBrowsable(EditorBrowsableState.Never)] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("wasi")] public static IntPtr GetFunctionPointerForDelegate(Delegate d) { ArgumentNullException.ThrowIfNull(d); + if (OperatingSystem.IsWasi() || OperatingSystem.IsBrowser()) throw new PlatformNotSupportedException(SR.PlatformNotSupported_DynamicEntrypoint); + return GetFunctionPointerForDelegateInternal(d); } [UnconditionalSuppressMessage("AotAnalysis", "IL3050:AotUnfriendlyApi", Justification = "AOT compilers can see the T.")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("wasi")] public static IntPtr GetFunctionPointerForDelegate(TDelegate d) where TDelegate : notnull { return GetFunctionPointerForDelegate((Delegate)(object)d); diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index e00a6de33c437f..0fc0fd8aa79a5d 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -1070,7 +1070,11 @@ public static void FreeHGlobal(System.IntPtr hglobal) { } public static System.IntPtr GetExceptionPointers() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the delegate might not be available. Use the GetFunctionPointerForDelegate overload instead.")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("wasi")] public static System.IntPtr GetFunctionPointerForDelegate(System.Delegate d) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("wasi")] public static System.IntPtr GetFunctionPointerForDelegate(TDelegate d) where TDelegate : notnull { throw null; } [System.Diagnostics.CodeAnalysis.RequiresAssemblyFiles("Windows only assigns HINSTANCE to assemblies loaded from disk. This API will return -1 for modules without a file on disk.")] public static System.IntPtr GetHINSTANCE(System.Reflection.Module m) { throw null; } diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs index f0745272af906c..5e70e5801e57d5 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetDelegateForFunctionPointerTests.cs @@ -11,7 +11,7 @@ namespace System.Runtime.InteropServices.Tests { - [ActiveIssue("https://github.com/dotnet/runtime/issues/39187", TestPlatforms.Browser)] + [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] public class GetDelegateForFunctionPointerTests { [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs index 79c3adb3c91abc..750cefd167fa5b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetFunctionPointerForDelegateTests.cs @@ -10,8 +10,7 @@ namespace System.Runtime.InteropServices.Tests { public class GetFunctionPointerForDelegateTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/39187", TestPlatforms.Browser)] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOTOrBrowser))] public void GetFunctionPointerForDelegate_NormalDelegateNonGeneric_ReturnsExpected() { MethodInfo targetMethod = typeof(GetFunctionPointerForDelegateTests).GetMethod(nameof(Method), BindingFlags.NonPublic | BindingFlags.Static); @@ -23,8 +22,7 @@ public void GetFunctionPointerForDelegate_NormalDelegateNonGeneric_ReturnsExpect Assert.Equal(pointer1, pointer2); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/39187", TestPlatforms.Browser)] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOTOrBrowser))] public void GetFunctionPointerForDelegate_MarshalledDelegateNonGeneric_ReturnsExpected() { MethodInfo targetMethod = typeof(GetFunctionPointerForDelegateTests).GetMethod(nameof(Method), BindingFlags.NonPublic | BindingFlags.Static); @@ -40,8 +38,7 @@ public void GetFunctionPointerForDelegate_MarshalledDelegateNonGeneric_ReturnsEx Assert.Equal(pointer1, pointer2); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/39187", TestPlatforms.Browser)] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOTOrBrowser))] public void GetFunctionPointerForDelegate_NormalDelegateGeneric_ReturnsExpected() { MethodInfo targetMethod = typeof(GetFunctionPointerForDelegateTests).GetMethod(nameof(Method), BindingFlags.NonPublic | BindingFlags.Static); @@ -53,8 +50,7 @@ public void GetFunctionPointerForDelegate_NormalDelegateGeneric_ReturnsExpected( Assert.Equal(pointer1, pointer2); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/39187", TestPlatforms.Browser)] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOTOrBrowser))] public void GetFunctionPointerForDelegate_MarshalledDelegateGeneric_ReturnsExpected() { MethodInfo targetMethod = typeof(GetFunctionPointerForDelegateTests).GetMethod(nameof(Method), BindingFlags.NonPublic | BindingFlags.Static); diff --git a/src/mono/browser/runtime/runtime.c b/src/mono/browser/runtime/runtime.c index 49dae17f50228f..e19a212c34a4de 100644 --- a/src/mono/browser/runtime/runtime.c +++ b/src/mono/browser/runtime/runtime.c @@ -197,6 +197,8 @@ init_icall_table (void) static void* get_native_to_interp (MonoMethod *method, void *extra_arg) { + assert (method); + void *addr = NULL; MONO_ENTER_GC_UNSAFE; MonoClass *klass = mono_method_get_class (method); diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 6d3d290955b6f8..30529371c414af 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -3469,6 +3469,14 @@ interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *e if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) { WrapperInfo *info = mono_marshal_get_wrapper_info (method); MonoMethod *orig_method = info->d.native_to_managed.method; + if (!orig_method) { + char *s = mono_method_get_full_name (method); + char *msg = g_strdup_printf ("No native to managed transition for method '%s', missing [UnmanagedCallersOnly] attribute.", s); + mono_error_set_platform_not_supported (error, msg); + g_free (s); + g_free (msg); + return NULL; + } /* * These are called from native code. Ask the host app for a trampoline. From 0de105275704959475c1f52dba2b6121800da129 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 9 Jun 2025 13:39:23 +0200 Subject: [PATCH 2/9] more --- .../Loader/AssemblyDependencyResolver.PlatformNotSupported.cs | 1 + .../src/System/Runtime/Loader/AssemblyDependencyResolver.cs | 1 + src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs index 5f0597bf337bed..53d396c76ca834 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs @@ -8,6 +8,7 @@ namespace System.Runtime.Loader { [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public sealed class AssemblyDependencyResolver diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs index e4e6f2269a070e..0f6507df60df60 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs @@ -12,6 +12,7 @@ namespace System.Runtime.Loader { [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public sealed class AssemblyDependencyResolver diff --git a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs index a272e40c33db39..db5115c1fb2801 100644 --- a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs +++ b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs @@ -45,6 +45,7 @@ namespace System.Runtime.Loader { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public sealed partial class AssemblyDependencyResolver From f98552db9ac07fbece7e393aee55f551b2886c97 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 9 Jun 2025 15:02:23 +0200 Subject: [PATCH 3/9] more --- .../src/System/Runtime/Loader/AssemblyDependencyResolver.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs index 0f6507df60df60..fe9ab708457447 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs @@ -48,7 +48,9 @@ public AssemblyDependencyResolver(string componentAssemblyPath) // to the writer specified. Have to store the previous writer to set it back once this is done. var errorWriter = new Interop.HostPolicy.corehost_error_writer_fn(message => errorMessage.AppendLine(Marshal.PtrToStringAuto(message))); +#pragma warning disable CA1416 // This call site is reachable on all platforms. IntPtr errorWriterPtr = Marshal.GetFunctionPointerForDelegate(errorWriter); +#pragma warning restore CA1416 IntPtr previousErrorWriterPtr = Interop.HostPolicy.corehost_set_error_writer(errorWriterPtr); try From 3f41716f4e67fab3c46cb675072ffdab89938f72 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 9 Jun 2025 16:16:48 +0200 Subject: [PATCH 4/9] more --- src/libraries/Common/src/Interop/Interop.Ldap.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/Common/src/Interop/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Interop.Ldap.cs index 512242230093ff..5277ffe947ac43 100644 --- a/src/libraries/Common/src/Interop/Interop.Ldap.cs +++ b/src/libraries/Common/src/Interop/Interop.Ldap.cs @@ -244,9 +244,11 @@ public void FromManaged(LdapReferralCallback managed) { _managed = managed; _native.sizeofcallback = sizeof(Native); +#pragma warning disable CA1416 // This call site is reachable on all platforms. _native.query = managed.query is not null ? Marshal.GetFunctionPointerForDelegate(managed.query) : IntPtr.Zero; _native.notify = managed.notify is not null ? Marshal.GetFunctionPointerForDelegate(managed.notify) : IntPtr.Zero; _native.dereference = managed.dereference is not null ? Marshal.GetFunctionPointerForDelegate(managed.dereference) : IntPtr.Zero; +#pragma warning restore CA1416 } public Native ToUnmanaged() => _native; From 132c53a4f40dd60f4dfa321ce10e3bbe56756ae9 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 9 Jun 2025 18:00:26 +0200 Subject: [PATCH 5/9] more --- .../src/Microsoft/Win32/SystemEvents.cs | 2 ++ src/libraries/System.Data.OleDb/src/OleDbWrapper.cs | 4 ++++ .../DirectoryServices/ActiveDirectory/DirectoryServer.cs | 2 ++ .../src/System/ServiceProcess/ServiceBase.cs | 2 ++ 4 files changed, 10 insertions(+) diff --git a/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs b/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs index 786ab50e0742be..6d5f5592c58bf7 100644 --- a/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs +++ b/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs @@ -671,7 +671,9 @@ private unsafe void Initialize() Interop.User32.WNDCLASS windowClass = new Interop.User32.WNDCLASS { hbrBackground = (IntPtr)(Interop.User32.COLOR_WINDOW + 1), +#pragma warning disable CA1416 // This call site is reachable on all platforms. lpfnWndProc = Marshal.GetFunctionPointerForDelegate(_windowProc), +#pragma warning restore CA1416 lpszClassName = className, hInstance = hInstance }; diff --git a/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs b/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs index 4fc5470229df12..8b71abbc54b824 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs @@ -141,7 +141,9 @@ internal unsafe OleDbHResult InitializeAndCreateSession(OleDbConnectionString co // since the delegate lifetime is longer than the original instance used to create it // we double check before each usage to verify the delegates function pointer +#pragma warning disable CA1416 // This call site is reachable on all platforms. if ((null == QueryInterface) || (method != Marshal.GetFunctionPointerForDelegate(QueryInterface))) +#pragma warning restore CA1416 { QueryInterface = (UnsafeNativeMethods.IUnknownQueryInterface)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IUnknownQueryInterface)); constr.DangerousDataSourceIUnknownQueryInterface = QueryInterface; @@ -386,7 +388,9 @@ internal void VerifyIDBCreateCommand(OleDbConnectionString constr) // since the delegate lifetime is longer than the original instance used to create it // we double check before each usage to verify the delegates function pointer +#pragma warning disable CA1416 // This call site is reachable on all platforms. if ((null == CreateCommand) || (method != Marshal.GetFunctionPointerForDelegate(CreateCommand))) +#pragma warning restore CA1416 { CreateCommand = (UnsafeNativeMethods.IDBCreateCommandCreateCommand)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDBCreateCommandCreateCommand)); constr.DangerousIDBCreateCommandCreateCommand = CreateCommand; diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs index 4a5d463414f04b..2abacc9285086c 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs @@ -642,7 +642,9 @@ internal unsafe void SyncReplicaAllHelper(IntPtr handle, SyncReplicaFromAllServe int result; fixed (char* partitionPtr = partition) { +#pragma warning disable CA1416 // This call site is reachable on all platforms. IntPtr syncAllFunctionPointer = Marshal.GetFunctionPointerForDelegate(syncAllCallback); +#pragma warning restore CA1416 result = dsReplicaSyncAllW(handle, partitionPtr, (int)option | DS_REPSYNCALL_ID_SERVERS_BY_DN, syncAllFunctionPointer, (IntPtr)0, &pErrors); GC.KeepAlive(syncAllCallback); } diff --git a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs index fa6be7f42e7403..bcb9005ae08a4e 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs +++ b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs @@ -697,11 +697,13 @@ private void Initialize(bool multipleServices) private SERVICE_TABLE_ENTRY GetEntry() { _nameFrozen = true; +#pragma warning disable CA1416 // This call site is reachable on all platforms. return new SERVICE_TABLE_ENTRY() { callback = Marshal.GetFunctionPointerForDelegate(_mainCallback!), name = Marshal.StringToHGlobalUni(_serviceName) }; +#pragma warning restore CA1416 } private int ServiceCommandCallbackEx(int command, int eventType, IntPtr eventData, IntPtr eventContext) From d4cbc38b5233abe996f1ffec04819858df055e9a Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 9 Jun 2025 19:54:21 +0200 Subject: [PATCH 6/9] more --- src/libraries/System.Data.OleDb/src/OleDbWrapper.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs b/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs index 8b71abbc54b824..5224263e181d51 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs @@ -160,7 +160,9 @@ internal unsafe OleDbHResult InitializeAndCreateSession(OleDbConnectionString co // since the delegate lifetime is longer than the original instance used to create it // we double check before each usage to verify the delegates function pointer +#pragma warning disable CA1416 // This call site is reachable on all platforms. if ((null == Initialize) || (method != Marshal.GetFunctionPointerForDelegate(Initialize))) +#pragma warning restore CA1416 { Initialize = (UnsafeNativeMethods.IDBInitializeInitialize)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDBInitializeInitialize)); constr.DangerousIDBInitializeInitialize = Initialize; @@ -189,7 +191,9 @@ internal unsafe OleDbHResult InitializeAndCreateSession(OleDbConnectionString co // since the delegate lifetime is longer than the original instance used to create it // we double check before each usage to verify the delegates function pointer +#pragma warning disable CA1416 // This call site is reachable on all platforms. if ((null == CreateSession) || (method != Marshal.GetFunctionPointerForDelegate(CreateSession))) +#pragma warning restore CA1416 { CreateSession = (UnsafeNativeMethods.IDBCreateSessionCreateSession)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDBCreateSessionCreateSession)); constr.DangerousIDBCreateSessionCreateSession = CreateSession; From 22b533f1d86f14f0a165ef4ba401f6e90f997224 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 24 Jun 2025 12:37:25 +0200 Subject: [PATCH 7/9] more --- .../src/Internal/Runtime/InteropServices/ComponentActivator.cs | 2 ++ .../Runtime/InteropServices/IsolatedComponentLoadContext.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs index e8f9d9dc7ed433..496e23b9c6bb8a 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs @@ -18,6 +18,7 @@ internal static partial class ComponentActivator [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] @@ -139,6 +140,7 @@ public static int LoadAssembly(IntPtr assemblyPathNative, IntPtr loadContext, In [RequiresUnreferencedCode(TrimIncompatibleWarningMessage, Url = "https://aka.ms/dotnet-illink/nativehost")] [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs index 6dcc8f661d9dc4..01d495e0f6848c 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs @@ -16,6 +16,7 @@ namespace Internal.Runtime.InteropServices /// [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] From afd5524bafe0a5e31c17054e7bd97cff9e1c5415 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 25 Jun 2025 13:23:04 +0200 Subject: [PATCH 8/9] more --- .../Internal/Runtime/InteropServices/ComponentActivator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs index 496e23b9c6bb8a..ac33cf22aa1edb 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs @@ -18,7 +18,7 @@ internal static partial class ComponentActivator [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] @@ -107,6 +107,7 @@ public static unsafe int LoadAssemblyAndGetFunctionPointer(IntPtr assemblyPathNa [RequiresDynamicCode(NativeAOTIncompatibleWarningMessage)] [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] @@ -283,6 +284,7 @@ public static unsafe int GetFunctionPointer(IntPtr typeNameNative, [RequiresUnreferencedCode(TrimIncompatibleWarningMessage, Url = "https://aka.ms/dotnet-illink/nativehost")] [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] private static IsolatedComponentLoadContext GetIsolatedComponentLoadContext(string assemblyPath) From da9250cf5d12a6da4726991825c02a63654209e6 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 25 Jun 2025 14:23:07 +0200 Subject: [PATCH 9/9] more --- .../src/Internal/Runtime/InteropServices/ComponentActivator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs index ac33cf22aa1edb..b53a6bfa4a7600 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs @@ -57,6 +57,7 @@ private static string MarshalToString(IntPtr arg, string argName) [RequiresUnreferencedCode(TrimIncompatibleWarningMessage, Url = "https://aka.ms/dotnet-illink/nativehost")] [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")]