{
internal static partial class SR
{
- // 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()
- {
- return false;
- }
+ private static readonly object _lock = new object();
+ private static List<string>? _currentlyLoading;
+ private static int _infinitelyRecursingCount;
+ private static bool _resourceManagerInited;
// Needed for debugger integration
- internal static string? GetResourceString(string resourceKey)
+ internal static string GetResourceString(string resourceKey)
{
return GetResourceString(resourceKey, string.Empty);
}
- internal static string GetResourceString(string resourceKey, string? defaultString)
- {
- if (UsingResourceKeys())
- return defaultString ?? resourceKey;
-
- string? resourceString = null;
- try { resourceString = InternalGetResourceString(resourceKey); }
- catch (MissingManifestResourceException) { }
-
- if (defaultString != null && resourceKey.Equals(resourceString, StringComparison.Ordinal))
- {
- return defaultString;
- }
-
- return resourceString!; // only null if missing resource
- }
-
- private static readonly object _lock = new object();
- private static List<string>? _currentlyLoading;
- private static int _infinitelyRecursingCount;
- private static bool _resourceManagerInited = false;
-
[PreserveDependency(".cctor()", "System.Resources.ResourceManager")]
- private static string? InternalGetResourceString(string? key)
+ private static string InternalGetResourceString(string key)
{
- if (string.IsNullOrEmpty(key))
+ if (key.Length == 0)
{
- Debug.Fail("SR::GetResourceString with null or empty key. Bug in caller, or weird recursive loading problem?");
- return key!;
+ Debug.Fail("SR::GetResourceString with empty resourceKey. Bug in caller, or weird recursive loading problem?");
+ return key;
}
// We have a somewhat common potential for infinite
}
}
}
-
- internal static string Format(IFormatProvider? provider, string resourceFormat, params object?[]? args)
- {
- if (args != null)
- {
- if (UsingResourceKeys())
- {
- return resourceFormat + ", " + string.Join(", ", args);
- }
-
- return string.Format(provider, resourceFormat, args);
- }
-
- return resourceFormat;
- }
-
- internal static string Format(string resourceFormat, params object?[]? args)
- {
- if (args != null)
- {
- if (UsingResourceKeys())
- {
- return resourceFormat + ", " + string.Join(", ", args);
- }
-
- return string.Format(resourceFormat, args);
- }
-
- return resourceFormat;
- }
-
- internal static string Format(string resourceFormat, object? p1)
- {
- if (UsingResourceKeys())
- {
- return string.Join(", ", resourceFormat, p1);
- }
-
- return string.Format(resourceFormat, p1);
- }
-
- internal static string Format(string resourceFormat, object? p1, object? p2)
- {
- if (UsingResourceKeys())
- {
- return string.Join(", ", resourceFormat, p1, p2);
- }
-
- return string.Format(resourceFormat, p1, p2);
- }
-
- internal static string Format(string resourceFormat, object? p1, object? p2, object? p3)
- {
- if (UsingResourceKeys())
- {
- return string.Join(", ", resourceFormat, p1, p2, p3);
- }
- return string.Format(resourceFormat, p1, p2, p3);
- }
}
}