project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Review VB's "My Application" behaviour in .NET 5 under WinForms and WPF

Open drewnoakes opened this issue 3 years ago • 5 comments

#6548 fixed a bug introduced in #6486, and also opted this feature in for VB .NET Framework projects for which UseWindowsForms is true.

We should investigate whether this feature applies for WPF projects too, as well as run more thorough tests on its behaviour in WinForms scenarios too.

Given current priorities, if it doesn't behave correctly we should back out the change that opts it in for .NET Framework rather than fix the behaviour and file a legacy compat issue for future.

drewnoakes avatar Aug 26 '20 13:08 drewnoakes

@drewnoakes .NET Framework was always opt'd in, and not behind UseWindowsForms.

davkean avatar Aug 26 '20 14:08 davkean

@drewnoakes and I looked at how these properties behave in the legacy world, for WPF and WinForms projects. The MyApplication feature has two modes of operation, one for WinForms and the other for WPF. These appears to provide different sets of properties.

Investigating .NET 5 behaviour:

  • UseWindowsForms currently shows the MyApplication UI, and it seems to work correctly. We could only validate that it writes to the makes the .myapp XML file correctly, as we couldn't build due to restore failures with SDK preview 8.
  • UseWPF currently does not show the MyApplication properties. When we updated the condition to make it appear, it shows in the WinForms "mode", not the WPF one. We began looking into how to make it show in the WPF mode, but realised the following.

In legacy, a project identified as either WinForms or WPF. It could contain both forms and windows, mixing the technologies, but the project itself identified one way or the other.

In .NET 5, a project can "use" both WinForms and WPF. The MyApplication feature is not designed to support this.

Given the above, it seems that where we are today (after #6548) is the sweet spot in terms of correctness and effort. Making it work for WPF will likely require work on the MyApplication feature.

Given we are redesigning the property pages, it seems as though investing in those to support this scenario might make more sense.

cc @KathleenDollard

melytc avatar Aug 28 '20 02:08 melytc

If loading a .NET Framework project with the new project system, the MyApplication feature doesn't appear to have the information it needs to identify whether the project is WinForms or WPF. We tried adding a few properties and items to the project file to get this working but were not able to. We assume that state is coming from a project flavour.

melytc avatar Aug 28 '20 02:08 melytc

Targeting .NET Framework with UseWinForms should result in the same behavior as .NET Core.

Based on above, if I'm using WPF and .NET Core I cannot use MyApplication?

davkean avatar Aug 28 '20 02:08 davkean

I think the work remaining here is to incorporate unit tests to both WPF and WinForms scenarios, some of which are already in.

melytc avatar Nov 10 '22 21:11 melytc