From c65b813f458cec66f20663ec1b72c6911fcde7c2 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 6 May 2024 16:05:25 +0200 Subject: [PATCH] [dotnet] Throw an exception if the developer tries to use server garbage collection. Fixes #16853. Our runtime doesn't support server garbage collection: https://github.com/xamarin/xamarin-macios/blob/main/runtime/coreclr-bridge.m#L203-L210 Fixes https://github.com/xamarin/xamarin-macios/issues/16853. --- dotnet/targets/Xamarin.Shared.Sdk.targets | 6 ++++++ src/ObjCRuntime/Runtime.cs | 22 ++++++++++++++++++++++ tools/mtouch/Errors.designer.cs | 9 +++++++++ tools/mtouch/Errors.resx | 5 +++++ 4 files changed, 42 insertions(+) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 2cae73aa144a..513f7b2357c7 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -2124,6 +2124,12 @@ + + + + RegistrationMap is not null && options->RegistrationMap->classHandles is not null) { ClassHandles.InitializeClassHandles (options->RegistrationMap->classHandles); diff --git a/tools/mtouch/Errors.designer.cs b/tools/mtouch/Errors.designer.cs index bf2075c8616a..15b3ed749e75 100644 --- a/tools/mtouch/Errors.designer.cs +++ b/tools/mtouch/Errors.designer.cs @@ -4257,5 +4257,14 @@ public static string MX8056 { return ResourceManager.GetString("MX8056", resourceCulture); } } + + /// + /// Looks up a localized string similar to .NET for {0} does not support server garbage collection.. + /// + public static string MX8057 { + get { + return ResourceManager.GetString("MX8057", resourceCulture); + } + } } } diff --git a/tools/mtouch/Errors.resx b/tools/mtouch/Errors.resx index 77718d85f59d..c059da1cbffa 100644 --- a/tools/mtouch/Errors.resx +++ b/tools/mtouch/Errors.resx @@ -2266,4 +2266,9 @@ Failed to marshal the Objective-C object 0x{0} (type: {1}). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance of generic type {2}. + + + .NET for {0} does not support server garbage collection. + {0}: the platform (iOS, macOS, etc.) +