Skip to content

Make XElement serializable in netstandard #21454

Closed

Description

@huanwu

The default XElement constroctor is public in corefx, but not in dotnet standard. This breaks our serialization generator for XElement type. The code will be generated based on the corefx and use the default constructor when create a new XElement instance. But it cannot compile in dotnet standard since the default public constructor doesn't exist. Need make them be consistent to unblock our scenario. Either make XElement default contructor be internal like in desktop version. Or add it in the dotnet standard.

#20445

Activity

  1. karelz commented on May 1, 2017

    @karelz
    Member

    @huanwu @shmao should it got into 2.0?

  2. huanwu commented on May 1, 2017

    @huanwu
    ContributorAuthor

    @karelz yes, it is 2.0

  3. karelz commented on May 1, 2017

    @karelz
    Member

    Can you please also add issue type label? See triage rules for details.

  4. danmoseley commented on May 2, 2017

    @danmoseley
    Contributor
  5. krwq commented on May 2, 2017

    @krwq
    Member

    Previously we have have marked XElement constructor internal in the contract so that serialization worked fine - would that be sufficient?

    EDIT: It already is internal - https://github.com/dotnet/corefx/blob/master/src/System.Xml.XDocument/ref/System.Xml.XDocument.Manual.cs#L14 - I guess this doesn't help

  6. weshaggard commented on May 2, 2017

    @weshaggard
    Member
  7. krwq commented on May 2, 2017

    @krwq
    Member

    @huanwu - I don't see why internal wouldn't work - is it uapaot problem? Should you update rd.xml?

  8. huanwu commented on May 2, 2017

    @huanwu
    ContributorAuthor

    @krwq This impact our serialization code generator scenario. The code was generated based on corefx,. Since the default constructor for XElement is public, (https://github.com/dotnet/corefx/blob/master/src/System.Private.Xml.Linq/src/System/Xml/Linq/XElement.cs#L132)
    the generated code is like
    o.@MyElement = (global::System.Xml.Linq.XElement)ReadSerializable(( System.Xml.Serialization.IXmlSerializable)new global::System.Xml.Linq.XElement());

    However the generated code cannot compile since the default constructor is not public in dotnet standard.

  9. krwq commented on May 2, 2017

    @krwq
    Member

    @huanwu would changing it to internal fix the issue and cause proper code to get generated?

  10. huanwu commented on May 2, 2017

    @huanwu
    ContributorAuthor

    @krwq yes, it will solve our problem if you change it to internal.

  11. self-assigned this
    on May 2, 2017
  12. changed the title [-]Make the default XELement contructor be public in dotnet Standard[/-] [+]Make XElement serializable in netstandard[/+] on May 2, 2017
  13. transferred this issue fromdotnet/corefxon Jan 31, 2020
  14. added this to the 2.0.0 milestone on Jan 31, 2020
  15. ghost locked as resolved and limited conversation to collaborators on Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions