From c58018c23c29c53f0980044d680f17b28f589069 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 5 May 2020 15:34:14 +0200 Subject: [PATCH] Synchronize SR.cs (#35830) Ports .NET Native change https://github.com/dotnet/corert/commit/0ac83cb8d6f9ab10df616a608fcf6fdfa6eabe2b to the Runtime repo. --- src/libraries/System.Private.CoreLib/src/System/SR.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/SR.cs b/src/libraries/System.Private.CoreLib/src/System/SR.cs index fff60a9..e70d618 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SR.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SR.cs @@ -15,6 +15,10 @@ namespace System { // This method is used to decide if we need to append the exception message parameters to the message when calling SR.Format. // by default it returns false. + // Native code generators can replace the value this returns based on user input at the time of native code generation. + // Marked as NoInlining because if this is used in an AoT compiled app that is not compiled into a single file, the user + // could compile each module with a different setting for this. We want to make sure there's a consistent behavior + // that doesn't depend on which native module this method got inlined into. [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { @@ -29,6 +33,9 @@ namespace System internal static string GetResourceString(string resourceKey, string? defaultString) { + if (UsingResourceKeys()) + return defaultString ?? resourceKey; + string? resourceString = null; try { resourceString = InternalGetResourceString(resourceKey); } catch (MissingManifestResourceException) { } -- 2.7.4