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

How to serialize System.Uri? #40

Open
JohanLarsson opened this issue Sep 12, 2018 · 8 comments
Open

How to serialize System.Uri? #40

JohanLarsson opened this issue Sep 12, 2018 · 8 comments

Comments

@JohanLarsson
Copy link
Member

<Uri AbsoluteUri="https://gitter.im/GuOrg/Gu.Xml" />
@jnm2
Copy link

jnm2 commented Sep 12, 2018

Why not <Uri>https://gitter.im/GuOrg/Gu.Xml</Uri>?

@JohanLarsson
Copy link
Member Author

Can we figure out relative/absolute in all cases when deserializing then?

@jnm2
Copy link

jnm2 commented Sep 12, 2018

@JohanLarsson <Uri Relative="true">...</Uri> for the less common case?

I did think Uri could roundtrip through a string losslessly. Do you have tests with counterexamples?

@JohanLarsson
Copy link
Member Author

Nope no unit tests, I don't use uri much so don't know it well. Hence the issue.

@jnm2
Copy link

jnm2 commented Sep 12, 2018

Looks like UriKind would need to be serialized: https://docs.microsoft.com/dotnet/api/system.uri.-ctor#System_Uri__ctor_System_String_System_UriKind_
It would be nice if the most common case was the shortest.

@JohanLarsson
Copy link
Member Author

JohanLarsson commented Sep 12, 2018

<Uri AbsoluteUri="https://gitter.im/GuOrg/Gu.Xml" />
<Uri RelativeUri="GuOrg/Gu.Xml" />

Are pretty short no?
But I agree that <Uri>https://gitter.im/GuOrg/Gu.Xml</Uri> feels most natural.

@jnm2
Copy link

jnm2 commented Sep 12, 2018

I am pretty sure absolute is the most common, so my mind jumps to making that the default:

<Uri AbsoluteUri="https://gitter.im/GuOrg/Gu.Xml" />
<Uri>https://gitter.im/GuOrg/Gu.Xml</Uri>

<Uri Relative="true">GuOrg/Gu.Xml</Uri>

...but yes, all options presented so far are pretty short.

@JohanLarsson
Copy link
Member Author

We also want new Uri("https://gitter.im/GuOrg/Gu.Xml", UriKind.Relative) to roundtrip. Not the business of a serialization library to fix bugs.

@JohanLarsson JohanLarsson changed the title How to serialize System.Uri How to serialize System.Uri? Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants