未验证 提交 5a3da7d9 编写于 作者: M Marek Safar 提交者: GitHub

Separate GetResourceString method with defaultString value. (#51073)

It's not used in Release build and it injects ununsed null value to every callsite
上级 b1f7ca4c
......@@ -23,11 +23,11 @@ internal static partial class SR
false;
#endif
internal static string GetResourceString(string resourceKey, string? defaultString = null)
internal static string GetResourceString(string resourceKey)
{
if (UsingResourceKeys())
{
return defaultString ?? resourceKey;
return resourceKey;
}
string? resourceString = null;
......@@ -42,14 +42,16 @@ internal static string GetResourceString(string resourceKey, string? defaultStri
}
catch (MissingManifestResourceException) { }
if (defaultString != null && resourceKey.Equals(resourceString))
{
return defaultString;
}
return resourceString!; // only null if missing resources
}
internal static string GetResourceString(string resourceKey, string defaultString)
{
string resourceString = GetResourceString(resourceKey);
return resourceKey == resourceString || resourceString == null ? defaultString : resourceString;
}
internal static string Format(string resourceFormat, object? p1)
{
if (UsingResourceKeys())
......
......@@ -197,7 +197,7 @@ public string Category
/// <summary>
/// Looks up the localized name of a given category.
/// </summary>
protected virtual string? GetLocalizedString(string value) => SR.GetResourceString("PropertyCategory" + value, null);
protected virtual string? GetLocalizedString(string value) => SR.GetResourceString("PropertyCategory" + value);
public override bool IsDefaultAttribute() => Category == Default.Category;
}
......
......@@ -17,12 +17,6 @@ internal static partial class SR
private static int _infinitelyRecursingCount;
private static bool _resourceManagerInited;
// Needed for debugger integration
internal static string GetResourceString(string resourceKey)
{
return GetResourceString(resourceKey, null);
}
private static string InternalGetResourceString(string key)
{
if (key.Length == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册