Serialization Issues at Design Time with CustomType Properties Using CustomCodeDomSerializer and CodeExpression in overidden Serialize Method #12754
Labels
untriaged
The team needs to look at this issue in the next triage
Environment
Visual Studio professional 2022 - version 17.12.0
.NET version
.NET 8
Did this work in a previous version of Visual Studio and/or previous .NET release?
No
Issue description
We are currently working with a custom type property that utilizes a CustomCodeDomSerializer as its DesignerSerializer. Within the CustomCodeDomSerializer class, the CodeExpression is employed in the Serialize method.
However, this implementation is causing serialization issues. Specifically:
When the property value is changed in the property window, the updated code is not generated in the Form1.Designer.cs file.
Upon rebuilding the solution, the changes made in the property window are reverted.
Through design-time debugging, we identified that the Serialize method is not being triggered for property changes. The root cause appears to be the inclusion of the CodeExpression in the serialization logic. When this line is commented out, the Serialize method triggers as expected.
However, in our scenario, the CodeExpression is essential for serializing the data.
We would appreciate any guidance or suggestions on resolving this issue while maintaining the use of CodeExpression in the serialization process.
Demo link - CodeDomSerializerIssue.zip
Steps to reproduce
1.Open the Designer.
2.Click the CustomControl and go to the propertwindow.
3.Expand the ColorCheck (Custom property) and change the Color property.
4.Save the changes and check the form1.Designer.cs page.
Expected Behavior - Changes needs to be added in the Designer.cs page.
Observed Behavior - Changes are not added in the Designer.cs page.
Expected Behavior - Updated values needs to maintain in the property window.
Observed Behavior - property value changes to its Default value.
The text was updated successfully, but these errors were encountered: