dotnet / project-system

The .NET Project System for Visual Studio
MIT License
971 stars 389 forks source link

Background image disappears while newly project name with hyphen using project template #9100

Open Eudora-Li01 opened 1 year ago

Eudora-Li01 commented 1 year ago

Visual Studio Version

17.7.0 Preview 3.0 [33814.344.main]

Steps to Reproduce

  1. Create Winforms .Net Core application
  2. Add a button and set its background image to a png via Project resource file, probably any graphic will work
  3. Export this project as a Template
  4. Start a new WinForms project using the exported template
  5. For the new project name, put a hyphen in the same, e.g. Test-App (This is key step)
  6. Open Form1.cs[Design] and observe the button

https://github.com/microsoft/winforms-designer/assets/130345015/14dbb178-b393-4a24-b403-8c68d6ea10ef

Expected Behavior

The button’s background image should display.

https://github.com/microsoft/winforms-designer/assets/130345015/636056ce-9b90-4061-a1c7-5a6662b0ced8

Actual Behavior

The button’s background image will be gone. image

Have you experienced this same issue with previous previews of VisualStudio?

Yes, it also repro on VS 16.11.20 and 17.5.2.

More Info

  1. It doesn't repro for Local resource.
  2. The initial feedback ticket is: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1833409
drewnoakes commented 1 year ago

This is not specific to templates. From an internal discussion:

This is the bug I see when I create a new winforms Core application named WinformsApp, then rename it to Winforms-App, with a hyphen, and then add a resource to it:

namespace WinForms-App2.Properties {
    using System;

Application name is used for the namespace name as is, project system had not escaped namespace name when I renamed the application. This is incorrect because the minus sign will be interpreted as an operator. It should have been replaced with an underscore (all unsupported chars are), as it is done when a new project with a hyphen is created. In the legacy project system, the old namespace name is retained in this scenario -

namespace WindowsFormsApp1.Properties {
    using System;

It's apparently a problem related to invalid characters in code symbols.

We should investigate to come up with more focussed repro steps.