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

Port JsonIsomorphism from Newtonsoft variant #40

Merged
merged 6 commits into from
Mar 18, 2020
Merged

Conversation

bartelink
Copy link
Collaborator

@bartelink bartelink commented Mar 8, 2020

Port of original NewtonsoftJson impl by @eiriktsarpalis to work equivalently with System.Text.Json (separated for now for review purposes, part of #38)

if baseConverter |> isNull then
failwithf "Field %s is decorated with a JsonConverter attribute, but it does not implement a CreateConverter method." f.Name

let baseConverter =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I inferred this makes sense based on a) reading the xmldoc for JsonConverter in STJ b) the tests passing c) reading the converter authoring guide a bit
Seeking a review as its entirely possible I'm missing lots of obvious things...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would work, but the question is should this be something that is supported? If someone creates JsonConverterAttribute without implementing the CreateConverter method, then it's essentially an invalid use of the attribute. I don't know if we should go around that and try to create the converter anyways.

Copy link
Collaborator Author

@bartelink bartelink Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it was mandatory, surely it'd be abstract?
For me, it seems the docs and xmldocs suggest that they don't all need to be converter factories
And letting it work direct seems in some cases to avoid an allocation, which would be in line with the general STJ philosophy
I guess we'll leave this here so someone can like to it in a told-you-so comment when we discover its wrong!

@bartelink bartelink mentioned this pull request Mar 8, 2020
9 tasks
@bartelink bartelink requested a review from ylibrach March 8, 2020 19:33
Copy link
Contributor

@ylibrach ylibrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the one comment about the change in JsonRecordConverter, it LGTM!

if baseConverter |> isNull then
failwithf "Field %s is decorated with a JsonConverter attribute, but it does not implement a CreateConverter method." f.Name

let baseConverter =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would work, but the question is should this be something that is supported? If someone creates JsonConverterAttribute without implementing the CreateConverter method, then it's essentially an invalid use of the attribute. I don't know if we should go around that and try to create the converter anyways.

@bartelink bartelink merged commit c33f654 into stj Mar 18, 2020
@bartelink bartelink deleted the jsonisomorphism branch March 18, 2020 23:37
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

Successfully merging this pull request may close these issues.

2 participants