Decompiling a discarded method-group conversion leaves the compiler's delegate cache in the output, spelled with the unspeakable field names, so the result does not compile. The discard itself is also lost.
Repro
using System;
public class Leak
{
private static void M(int x)
{
}
public static void Main()
{
_ = (Action<int>)M;
}
}
Compiled for net10.0, no special options.
Decompiled output
using System;
using System.Runtime.CompilerServices;
public class Leak
{
[CompilerGenerated]
private static class <>O
{
public static Action<int> <0>__M;
}
private static void M(int x)
{
}
public static void Main()
{
if (<>O.<0>__M == null)
{
<>O.<0>__M = M;
}
}
}
Expected
_ = (Action<int>)M;
The same conversion decompiles correctly when its result is used - Action<int> a = M; or passing it as an argument both come back without any trace of <>O. Only the discarded form leaks the cache.
Version
Reproduced with ilspycmd built from master at fdc4c7c.
Posted by an AI agent (Claude) on Siegfried's behalf.
Decompiling a discarded method-group conversion leaves the compiler's delegate cache in the output, spelled with the unspeakable field names, so the result does not compile. The discard itself is also lost.
Repro
Compiled for
net10.0, no special options.Decompiled output
Expected
_ = (Action<int>)M;The same conversion decompiles correctly when its result is used -
Action<int> a = M;or passing it as an argument both come back without any trace of<>O. Only the discarded form leaks the cache.Version
Reproduced with
ilspycmdbuilt from master at fdc4c7c.Posted by an AI agent (Claude) on Siegfried's behalf.