dotnet / winforms

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

Winform Designer generates confliting resource files on partial class #11411

Open CyrilPaulus opened 1 month ago

CyrilPaulus commented 1 month ago

Environment

Version 17.9.6

.NET version

8.0.204

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

No response

Issue description

When editing a control split into a partial class, the designer generates a new resource file for each file contributing to the partial class. This makes compilation impossible, as the generated resource files conflict with each other.

Steps to reproduce

  1. Clone the repo https://github.com/CyrilPaulus/WinFormDesignerPartialResourceBug
  2. Open the file Form1_partial.cs with the WinForm Designer.
  3. The file Form1_partial.resx should have been generated.
  4. Try to compile the project.

Diagnostics

No response

LeafShi1 commented 1 month ago

This issue reproduce in .Net6.0 and not reproduce in .NetFramework 4.8.1

The call stack in the designer repo:

Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Serialization.ResourceCodeDomSerializer.GetResourceManager(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) Line 252  C#
    Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Serialization.ResourceCodeDomSerializer.GetMetadataEnumerator(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) Line 246   C#
    Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Serialization.CodeDomSerializerBase.DeserializePropertiesFromResources(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value, System.Attribute[] filter) Line 1059    C#
    Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Serialization.TypeCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration) Line 237
elachlan commented 1 month ago

@LeafShi1 you will probably need to search the designer repo and see if there is an existing issue.

LeafShi1 commented 1 month ago

@LeafShi1 you will probably need to search the designer repo and see if there is an existing issue.

No existing issue found in designer repo

elachlan commented 1 month ago

@LeafShi1 create a new designer issue and link it here I think.

CC: @Shyam-Gupta

Tanya-Solyanik commented 1 month ago

This is a duplicate of https://github.com/microsoft/winforms-designer/issues/5900

Tanya-Solyanik commented 1 month ago

Workaround: add a second class to Form1_partial.cs