Skip to content

[dotnet-sdk-9.0.100-rc.2.24470.13] Some Winfroms Apps build with error: Property 'XXX' does not configure the code serialization for its property content #12220

Closed

Description

@Junjun-zhao

.NET version

Dotnet Info:

.NET SDK:
 Version:           9.0.100-rc.2.24470.13
 Commit:            3229e54b07
 Workload version:  9.0.100-manifests.8fbc914b
 MSBuild version:   17.12.0-preview-24469-05+fea15fbd1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-rc.2.24470.13\

Host:
  Version:      9.0.0-rc.2.24463.7
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  9.0.100-rc.2.24470.13 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-rc.2.24466.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-rc.2.24463.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.2.24464.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Did it work in .NET Framework?

Not tested/verified

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes

Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.300(default target net8.0): Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.2.24470.13(default target net8.0): Pass
3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.2.24470.13(retarget net9.0): Fail
4). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.1.24452.12(retarget net9.0): Fail
5). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24407.12(retarget net9.0): Pass

Issue description

When retarget the 3rd party application to net9.0 and build with the latest .NET 9 sdk, it failed with error: Property 'CellTemplate' does not configure the code serialization for its property content.

Application Name: WinformsSamples, mRemoteNG, Character-Builder-5, AutoVersionsDB,HeroesPowerPlant
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-rc.2.24470.13
App & Source checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2260303
Github Link: GitHub - dotnet/samples: Sample code referenced by the .NET documentation

Steps to reproduce

App Repro Steps:(dotnet-sdk-9.0.100-rc.2.24470.13 installed)
1.Retarget app to net9.0 in \WinformsAPP\datagridview\CSWinFormDataGridView\CSWinFormDataGridView.csproj
net9.0-windows
2. Run command "dotnet build" in \WinformsAPP\datagridview\CSWinFormDataGridView.

Expected Result:
Build successfully.

Actual Result:
Build failed with error: WFO1000: Property 'CellTemplate' does not configure the code serialization for its property content.

Minimal Repro Steps (Demo attached:WinformsDemo.zip):

  1. Create a default8.0 winforms project.
  2. Create Class1.cs.
internal class Class1 : DataGridViewColumn
{
    private string test;
    public string Test
    {
        get
        {
            return this.test;
        }
        set
        {  
        }
    }
}
  1. Retarget to net9.0.
  2. Build with dotnet-sdk-9.0.100-rc.2.24470.13.

Expected Result:
Build successfully.

Actual Result:
Build failed with error: Property 'Test' does not configure the code serialization for its property content.

Findings:
There is a similar issue filed on github: DesignerSerializationVisibility - Behaviour Changes · Issue #41964 · dotnet/docs (github.com)
This issue starts from .NET 9 RC1 release and if we use the workaround mentioned in above issue to add DesignerSerializationVisibility to property, error will go.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

@dotnet-actwx-bot @dotnet/compat

Activity

  1. added
    untriaged
    on Sep 25, 2024
  2. Junjun-zhao commented on Sep 25, 2024

    @Junjun-zhao
    MemberAuthor

    @merriemcgaw Could you please take a look at this issue? There are 5 apps affected in our lab.

    CC: @richaverma1 @PriyaPurkayastha @marklio for awareness.

  3. PriyaPurkayastha commented on Sep 25, 2024

    @PriyaPurkayastha

    Adding @KlausLoeffelmann per chat with @merriemcgaw. Also cc @gewarren since customer created an issue for missing doc linked above. @KlausLoeffelmann is this an intentional breaking change (the analyzer work done as part of binary formatter removal) that hasn't been documented? Can you please create a breaking change issue for this using the template https://github.com/dotnet/docs/issues/new?assignees=gewarren&labels=breaking-change%2CPri1%2Cdoc-idea&projects=&template=02-breaking-change.yml&title=%5BBreaking+change%5D%3A+

  4. PriyaPurkayastha commented on Sep 25, 2024

    @PriyaPurkayastha

    Also adding @JeremyKuhne as requested by @merriemcgaw

  5. added this to the .NET 9.0 milestone on Sep 25, 2024
  6. KlausLoeffelmann commented on Sep 25, 2024

    @KlausLoeffelmann
    Member

    This is by design, introduced with .NET 9 (RC1).
    We need to make sure for security reasons, that properties for WinForms Designer are not serialized by accident.

    We will follow up with a respective Blog Post shortly.

    In the meanwhile, please fix the CodeDOM Serialization configuration for properties according to WinForms best practices:

    • Attribute with the DesignerSerializationVisibilityAttribute OR
    • Attribute with the DefaultValueAttribute OR
    • Amend a private bool ShouldSerialize[Property] method, which controls the serialization at Design Time.
  7. PriyaPurkayastha commented on Sep 25, 2024

    @PriyaPurkayastha

    @KlausLoeffelmann thanks for confirming. However, our breaking change process for .NET is that whenever we introduce a breaking change, it has to be accompanied by a breaking change doc in the very same release so that customers that start using the new release are not taken by surprise (like we saw with this change where two customers as well as .NET AppCompat lab did not know to expect this). Request you to kindly create the breaking change doc issue using the template provided above immediately. The blog post will definitely help everyone but does not substitute the breaking change documentation.

  8. KlausLoeffelmann commented on Sep 26, 2024

    @KlausLoeffelmann
    Member

    OK, yes, that makes sense!

    I created this and will make sure the blog post will be out ASAP!
    (It's almost done, so, no problem).

    dotnet/docs#42724

    @JeremyKuhne, @merriemcgaw.

  9. kirsan31 commented on Sep 26, 2024

    @kirsan31
    Contributor

    @KlausLoeffelmann
    I think it would be helpful to point out default behaviour:

    Members that do not have a DesignerSerializationVisibilityAttribute will be treated as though they have a DesignerSerializationVisibilityAttribute with a value of Visible. The values of a property marked as Visible will be serialized, if possible, by a serializer for the type.

  10. Junjun-zhao commented on Oct 8, 2024

    @Junjun-zhao
    MemberAuthor

    @KlausLoeffelmann Thank you for creating the breaking change doc quickly. Could you please close this issue? Thanks.

  11. removed
    untriaged
    on Oct 8, 2024
  12. locked and limited conversation to collaborators on Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions