mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
VB can lower event-handler closures through generated wrapper methods, closure copy constructors, and immediately invoked VB anonymous delegate helpers. Recognizing and unwrapping those shapes leaves the expected lambda form and lets captured locals be scalar-replaced instead of exposing generated closure artifacts. Assisted-by: OpenCode:openai/gpt-5.5:OpenCode
36 lines
609 B
C#
36 lines
609 B
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
public class Issue2199
|
|
{
|
|
private class Item
|
|
{
|
|
public string Text;
|
|
}
|
|
|
|
public event EventHandler Click;
|
|
|
|
public event EventHandler DoubleClick;
|
|
|
|
public void Register(string value)
|
|
{
|
|
Item item = new Item();
|
|
item.Text = value.Trim();
|
|
#if EXPECTED_OUTPUT
|
|
Click += [SpecialName] () => {
|
|
Console.WriteLine(item.Text);
|
|
};
|
|
DoubleClick += [SpecialName] () => {
|
|
Console.WriteLine(item.Text);
|
|
};
|
|
#else
|
|
Click += delegate {
|
|
Console.WriteLine(item.Text);
|
|
};
|
|
DoubleClick += delegate {
|
|
Console.WriteLine(item.Text);
|
|
};
|
|
#endif
|
|
}
|
|
}
|