-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Labels
Description
In the dotnet/runtime
libraries, we have the following code in System.SR:
private static bool UsingResourceKeys() => false;
internal static string GetResourceString(string resourceKey, string? defaultString = null)
{
if (UsingResourceKeys())
{
return defaultString ?? resourceKey;
}
// do the resource look-up
When this is passed through the linker, the IL is re-written to remove the branch around the constant UsingResourceKeys()
, but the linker is leaving the call site to UsingResourceKeys()
in GetResourceString()
.
.method assembly hidebysig static string
GetResourceString(string resourceKey,
[opt] string defaultString) cil managed
{
.param [2] = nullref
// Code size 42 (0x2a)
.maxstack 2
.locals (string V_0)
IL_0000: call bool System.SR::UsingResourceKeys()
IL_0005: brfalse.s IL_0007
IL_0007: ldnull
IL_0008: stloc.0
.try
{
IL_0009: call class [System.Runtime]System.Resources.ResourceManager System.SR::get_ResourceManager()
We should be removing the call to UsingResourceKeys()
as well, since it is not used.