Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Data.DataColumn serializes some properties with a default value (different from the .NET Framework) #11314

Open
rmkarasev opened this issue May 5, 2024 · 3 comments
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues 💥 regression-release Regression from a public release tracking-external-issue An issue is caused by an external system and won't be fixed in this repo
Milestone

Comments

@rmkarasev
Copy link

rmkarasev commented May 5, 2024

Environment

Microsoft Visual Studio 2022
Version 17.9.3

.NET version

.NET 6 (we use)
.NET 8

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

Works in the same Visual Studio 2022 Version 17.9.3 or previous versions, but targeting to .NET Framework 4.8.

Issue description

We have a custom Component and ComponentDesigner those are used to create/populate multiple DataTable and DataColumn in the design-time.

After migrating to .NET 6 we are experiencing with an issue that each DataColumn serialize some properties to .Designer.cs and .resx files that looks needless and just increase file size and noise.

Previous code:

this.dataColumn35.ColumnName = "DischargedDate";
this.dataColumn35.DataType = typeof(System.DateTime);

Current code:

dataColumn35.Caption = "DischargedDate";
dataColumn35.ColumnName = "DischargedDate";
dataColumn35.DataType = typeof(System.DateTime);
dataColumn35.DefaultValue = resources.GetObject("dataColumn35.DefaultValue");
dataColumn35.Namespace = "";

and .resx

  <data name="dataColumn35.DefaultValue" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
        AAEAAAD/////AQAAAAAAAAAMAgAAAEhTeXN0ZW0uUHJpdmF0ZS5Db3JlTGliLCBDdWx0dXJlPW5ldXRy
        YWwsIFB1YmxpY0tleVRva2VuPTdjZWM4NWQ3YmVhNzc5OGUFAQAAAB9TeXN0ZW0uVW5pdHlTZXJpYWxp
        emF0aW9uSG9sZGVyAwAAAAREYXRhCVVuaXR5VHlwZQxBc3NlbWJseU5hbWUBAAEIAgAAAAoCAAAABgMA
        AAAACw==
</value>
  </data>

So, ton of Caption, DefaultValue, Namespace properties are added when changing the form design in new Windows Forms Designer..

Is this issue already known? How can be this fixed?

Steps to reproduce

Minimal project is attached

DataColumnSerializationIssue.zip

@rmkarasev rmkarasev added the untriaged The team needs to look at this issue in the next triage label May 5, 2024
@elachlan elachlan added the area-VSDesigner Windows Forms out-of-proc designer related issues label May 6, 2024
@elachlan
Copy link
Contributor

@Tanya-Solyanik are we serialising some default values on purpose?

@Tanya-Solyanik Tanya-Solyanik added the 💥 regression-release Regression from a public release label May 13, 2024
@Tanya-Solyanik
Copy link
Member

DataColumn.Caption should be serialized on both versions:
https://source.dot.net/#System.Data.Common/System/Data/DataColumn.cs,345
https://referencesource.microsoft.com/#System.Data/fx/src/data/System/Data/DataColumn.cs,371
If it's not set explicitly, column name is used.

DataColumn.Namespace should be serialized on both versions too:
https://source.dot.net/#System.Data.Common/System/Data/DataColumn.cs,987
https://referencesource.microsoft.com/#System.Data/fx/src/data/System/Data/DataColumn.cs,1002
It seems that in NET6 version of the app _columnUri is not null.

DataColumn.DefaultValue should be serialized as a string using the converter -
https://source.dot.net/#System.Data.Common/System/Data/DataColumn.cs,640
https://source.dot.net/#System.Data.Common/System/Data/DefaultValueTypeConverter.cs,3060fb00499d852e
https://source.dot.net/#System.Data.Common/System/Data/DataColumn.cs,1750
https://referencesource.microsoft.com/#System.Data/fx/src/data/System/Data/DataColumn.cs,1725

So far this looks like designer bug. @Olina-Zhang - could you please copy it to the designer repo?

@Philip-Wang01
Copy link
Contributor

@Tanya-Solyanik Filed a DT issue: https://github.com/microsoft/winforms-designer/issues/5964 to track it.

@Tanya-Solyanik Tanya-Solyanik added tracking-external-issue An issue is caused by an external system and won't be fixed in this repo and removed untriaged The team needs to look at this issue in the next triage labels May 14, 2024
@Tanya-Solyanik Tanya-Solyanik added the untriaged The team needs to look at this issue in the next triage label May 15, 2024
@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label May 21, 2024
@merriemcgaw merriemcgaw added this to the VS release milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues 💥 regression-release Regression from a public release tracking-external-issue An issue is caused by an external system and won't be fixed in this repo
Projects
None yet
Development

No branches or pull requests

5 participants