Skip to content

6.0 - System.Text.Json.JsonSerializer.Deserialize System.Net.DnsEndPoint System.NotSupportedException #48205

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

Closed
vindicatorr opened this issue Feb 12, 2021 · 4 comments

Comments

@vindicatorr
Copy link

Description

System.Text.Json.JsonSerializer.Deserialize for System.Net.DnsEndPoint results in: "Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'System.Net.DnsEndPoint'..."

Configuration

  • Which version of .NET is the code running on? 6.0.100-preview.1.21107.2
  • What OS and version, and what distro if applicable? Arch Linux
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? I don't believe so.
  • If you're using Blazor, which web browser(s) do you see this issue in? N/A

Regression?

I don't believe so: #29895

Other information

I thought I read it was supposed to work in 5.0, but I was already using that.
When I saw it was marked as "Done" for 6.0 (#29895 (comment)), I installed that, but it's still an issue.
It at least serialized the object:

{"PDnsEndPoint":{"Host":"hostName","AddressFamily":0,"Port":0},"POther0":null,"POther1":null}
@ghost ghost added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Feb 12, 2021
@ghost
Copy link

ghost commented Feb 12, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

System.Text.Json.JsonSerializer.Deserialize for System.Net.DnsEndPoint results in: "Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'System.Net.DnsEndPoint'..."

Configuration

  • Which version of .NET is the code running on? 6.0.100-preview.1.21107.2
  • What OS and version, and what distro if applicable? Arch Linux
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? I don't believe so.
  • If you're using Blazor, which web browser(s) do you see this issue in? N/A

Regression?

I don't believe so: #29895

Other information

I thought I read it was supposed to work in 5.0, but I was already using that.
When I saw it was marked as "Done" for 6.0 (#29895 (comment)), I installed that, but it's still an issue.
It at least serialized the object:

{"PDnsEndPoint":{"Host":"hostName","AddressFamily":0,"Port":0},"POther0":null,"POther1":null}
Author: vindicatorr
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@eiriktsarpalis
Copy link
Member

I believe the standard approach for serializing a class you don't own is to define a JsonConverter. cc @layomia to comment on whether it is possible to specify deserialization constructors for class we don't own.

@vindicatorr
Copy link
Author

That's a great feature. I just made use of it and like it. https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-converters-how-to?pivots=dotnet-5-0

@layomia
Copy link
Contributor

layomia commented Feb 16, 2021

Later in .NET 6.0 when we expose the internal serialization metadata classes as part of the JSON code gen work - #34456 - users will be able to specify the deserialization constructor to use for any type (including non-owned types), without JsonConstructorAttrbute.

@layomia layomia removed the untriaged New issue has not been triaged by the area owner label Feb 16, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants