winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Designer removes needed code

Open MisinformedDNA opened this issue 4 years ago • 20 comments

  • .NET Core Version: TargetFramework: net5.0-windows SDKs: 6.0.100-rc.1.21463.6, 5.0.401

  • Have you experienced this same bug with .NET Framework?: Haven't tried

Problem description:

When I try to edit a control from the designer. The designer will remove needed parts of the code from *.Designer.cs which results in run-time errors.

Expected behavior:

Designer doesn't remove necessary code.

Minimal repro:

  1. Open control in designer
  2. Edit a property

Designer removed the assignment of two fields resulting in NullReferenceExceptions at run-time.

Video

Code

~Code after designer changes~ New after changes

NOTE: I inherited this code and have never used the designer on this control before, so maybe something the designer.cs or resx files are invalid in some way?

dotnet --info

❯ dotnet --info .NET SDK (reflecting any global.json): Version:
Commit: e627d556a1

Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\

Host (useful for support): Version: 6.0.0-rc.1.21451.13 Commit: d7619cd4b1

.NET SDKs installed: 3.1.409 [C:\Program Files\dotnet\sdk] 5.0.400 [C:\Program Files\dotnet\sdk] 5.0.401 [C:\Program Files\dotnet\sdk] 6.0.100-rc.1.21463.6 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

MisinformedDNA avatar Oct 04 '21 17:10 MisinformedDNA

DevExpress package used in the project probably does not have the Code designers.

    <PackageReference Include="DevExpress.Win.Reporting" Version="21.1.5" />

Tanya-Solyanik avatar Oct 05 '21 17:10 Tanya-Solyanik

But the ones disappearing are a DataSet and a TableAdapter. Also, DevExpress has a pretty mature library, if there is a bug with their code, I'd love to be able to tell them what is wrong. I spent hours narrowing this down, so any help is much appreciated.

MisinformedDNA avatar Oct 05 '21 18:10 MisinformedDNA

@Tanya-Solyanik I didn't want to edit the designer file for my repro, but I went ahead and did it. DevExpress is now removed as a dependency. I updated main and here's the new change commit. Same issue.

MisinformedDNA avatar Oct 05 '21 18:10 MisinformedDNA

@MisinformedDNA have you contacted DevExpress?

RussKie avatar Oct 05 '21 23:10 RussKie

@RussKie I shared a repro with DevExpress removed. It's clearly not them.

MisinformedDNA avatar Oct 05 '21 23:10 MisinformedDNA

I've also tested this on VS 2019 and 2022 previews that do not have any DevExpress extensions installed.

MisinformedDNA avatar Oct 07 '21 15:10 MisinformedDNA

@KlausLoeffelmann , can you take a look at the sample here and see anything stand out?

dreddy-work avatar Oct 08 '21 00:10 dreddy-work

@KlausLoeffelmann Have you had a chance to look?

MisinformedDNA avatar Oct 20 '21 21:10 MisinformedDNA

@KlausLoeffelmann @dreddy-work Can I get some help? How do I get this resolved?

MisinformedDNA avatar Nov 04 '21 17:11 MisinformedDNA

Hey @MisinformedDNA,

thanks for reporting that. We would need a repo which doesn't use a third party custom control, of which we don't know how compatible it is with the new designer.

Please also note that Designer support for Typed DataSets is limited for .NET WinForms Apps, since the Data Source Provider Service (which are necessary for maintaining Typed DataSets and get the necessary components into a Form/UserControl on demand) is not available for .NET apps.

That said, the most important scenarios we enabled (in WinForms! WPF is a different story, btw) without resorting to the Data Source Provider Service, so, I'd be interested if we can find a purely WinForms based scenario for this, since this would need to be fixed then!

KlausLoeffelmann avatar Nov 04 '21 19:11 KlausLoeffelmann

@KlausLoeffelmann The project does not depend on a 3rd party, that dependency was removed Oct 5 (see above).

The note about designer support for Typed DataSets is more of an FYI, since I'm using WinForms? Is that correct?

MisinformedDNA avatar Nov 04 '21 19:11 MisinformedDNA

The note about designer support for Typed DataSets is more of an FYI, since I'm using WinForms? Is that correct?

No, there might be issues, but I never personally encountered code-loss with using them. And sorry, I was watching your video primarily and saw it had the dependency to DevExpress. I missed that you removed that dependency. I would need to investigate some more, but it's taking a few days at least, so I'd ask to hang in there for a bit longer!

KlausLoeffelmann avatar Nov 04 '21 19:11 KlausLoeffelmann

@KlausLoeffelmann Thanks for looking into it!

MisinformedDNA avatar Nov 04 '21 22:11 MisinformedDNA

@KlausLoeffelmann Any update?

MisinformedDNA avatar Dec 01 '21 19:12 MisinformedDNA

@KlausLoeffelmann is currently OOF. With the holiday season is almost upon us our responses may be delayed.

RussKie avatar Dec 02 '21 23:12 RussKie

That said, I know my debt, even watching my Mom-visiting-from-Germany backing Holiday cookies. Will take a while though, still... 🎅

KlausLoeffelmann avatar Dec 02 '21 23:12 KlausLoeffelmann

@KlausLoeffelmann getting this back on your radar.

merriemcgaw avatar Feb 25 '22 00:02 merriemcgaw

Follow up question: From your demo, I can't really see for component the generated code is swallowed. Can you provide the sample without any references to third party controls, so I can debug into the repo?

Are you using a .NET Framework control by any chance in the context of a .NET (Core) application?

KlausLoeffelmann avatar Feb 25 '22 00:02 KlausLoeffelmann

You guys keep asking about a sample without third party controls, but the linked code in OP does not use any third party controls.

MisinformedDNA avatar Feb 27 '22 04:02 MisinformedDNA

@Olina-Zhang can your team attempt a repro and close this if we don't see the issue any more?

merriemcgaw avatar Oct 23 '24 20:10 merriemcgaw