Closed as duplicate of#78042
Description
VS 2022 Preview 5
Steps to Reproduce:
- Create basic console app for .net
- set preview for the project
- add code:
public static class Program
{
[STAThread]
static void Main()
{
}
}
public class EventSender
{
public EventSender(string name) => Name = name;
public string Name { get; set; }
public event EventHandler<EventArgs>? Event;
public void FireEvent() => Event?.Invoke(this, EventArgs.Empty);
}
public static class Extensions
{
extension(EventSender extendee)
{
public void Extend()
{
extendee.Event += (s, e) =>
{
// V---- not building
//if (s is EventSender sender)
// Console.WriteLine(sender.Name);
// V---- building
Console.WriteLine((s as EventSender)?.Name);
};
}
}
}