dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.41k stars 984 forks source link

Designer delete code from event handlers #7042

Closed kirsan31 closed 2 years ago

kirsan31 commented 2 years ago

Environment

Microsoft Visual Studio Community 2022 Version 17.1.4 VisualStudio.17.Release/17.1.4+32407.343 Microsoft .NET Framework Version 4.8.04084

.NET version

net6.0-windows;net4.8

Did this work in a previous version of Visual Studio and/or previous .NET release?

As I understand, this behavior was changed (the bug appeared) in VS2017. https://developercommunity.visualstudio.com/t/winforms-designer-event-removes-handler-content/131896 https://developercommunity.visualstudio.com/t/windows-forms-removing-event-function-deletes-the/823941 https://developercommunity.visualstudio.com/t/Resubmitting:-Windows-Forms---removing-e/961082 and other reports...

Issue description

Designer delete even handler code on event handler removing / changing. See video below. This is very nasty bug 😭 Some how related to https://github.com/dotnet/winforms/issues/6550.

Steps to reproduce

Default WinForms .Net6 project:

https://user-images.githubusercontent.com/17767561/163788224-88e1450c-5dee-4282-8d01-89757c3e01b6.mp4

MenuTest.zip This is modified default WinForms .Net6 project (net4.8 target was added).

Diagnostics

No response

Olina-Zhang commented 2 years ago

This issue was fixed in internal VS build, please use incoming Visual Studio 2022 preview build for testing. eventsVerify