Mark class ctors as preserved for dependencies of System.SR (#31718)
authorVitek Karas <vitek.karas@microsoft.com>
Mon, 24 Feb 2020 12:55:42 +0000 (04:55 -0800)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2020 12:55:42 +0000 (07:55 -0500)
The System.SR.InternalGetResourceString calls RuntimeHelpers.RunClassConstructor on several classes. This is a dependency the ILLinker won't be able to figure out, so explicit PreserveDependency is needed.

src/libraries/System.Private.CoreLib/src/System/SR.cs

index a613ea8..fff60a9 100644 (file)
@@ -46,6 +46,7 @@ namespace System
         private static int _infinitelyRecursingCount;
         private static bool _resourceManagerInited = false;
 
+        [PreserveDependency(".cctor()", "System.Resources.ResourceManager")]
         private static string? InternalGetResourceString(string? key)
         {
             if (string.IsNullOrEmpty(key))