Skip to content

Port JsonIsomorphism from Newtonsoft variant - #40

Merged
bartelink merged 6 commits into
stjfrom
jsonisomorphism
Mar 18, 2020
Merged

bartelink merged 6 commits into
stjfrom
jsonisomorphism

Conversation

@bartelink

@bartelink bartelink commented Mar 8, 2020 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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
Copy Markdown
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 Mar 18, 2020 •

Copy link
Copy Markdown
Contributor Author

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 done
@bartelink
bartelink requested a review from ylibrach March 8, 2020 19:33

@ylibrach ylibrach left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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