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

Library should include both Json.Net and System.Text.Json serialziers #420

Closed
abatishchev opened this issue Jun 19, 2022 · 10 comments · Fixed by #433
Closed

Library should include both Json.Net and System.Text.Json serialziers #420

abatishchev opened this issue Jun 19, 2022 · 10 comments · Fixed by #433
Labels

Comments

@abatishchev
Copy link
Member

abatishchev commented Jun 19, 2022

After the recent changes, it includes one or another.

@hartmark we've made it too opinionated: either one or another. How about somehow allow both options on the platform whether that's possible?

@hartmark
Copy link
Contributor

System.Text.Json is supported for .net fw 4.6.2 up to .net 6

So you mean for those versions there should be an option to use either that or Json.net?

@abatishchev
Copy link
Member Author

Yes, I'm thinking if we should include both serialziers into the assembly and the user would have a choice. Tests must be updated to test everything against both serialziers too, that might be the most tedious change of all

@hartmark
Copy link
Contributor

Alright, the tests can use some kind of parameterized test where the input is which serializer to use so we get everything tested twice.

Question is what should be used per default, one idea could be to use System.Text.Json where it is supported and Json.Net where it's not supported.

@abatishchev
Copy link
Member Author

abatishchev commented Jun 20, 2022

Yes, I was also thinking about a parameterized tests. However it might not work for those which are already parameterized, and iirc there are already few of them.

Another option might be a base class. But again iirc MSTest doesn't like them and ignore the attributes when they aren't declared at a leaf of the inheritance tree.

I think the new serialzier must the default option but the other option should still be available. In next version we can move it to a separate project, effectively decreasing the number of dependencies. To finally fullfil #76.

@hartmark
Copy link
Contributor

Yeah, having subclasses with MSTest is a pain I have experienced it myself firsthand :)

Perhaps we can migrate to Xunit for the tests so we easier can have subclasses for the tests.

We can use Microsoft.Extensions.DependencyInjection and just have the DI resolve the injection of the correct serializer the user have choosen.

Microsoft.Extensions.DependencyInjection supports .net 4.6.2 the same as system.text.json so if we are on lower .net we just use JSON.net.

@abatishchev
Copy link
Member Author

Yeah, having subclasses with MSTest is a pain I have experienced it myself firsthand :)

Yes :(

Perhaps we can migrate to Xunit for the tests so we easier can have subclasses for the tests.

Let's don't. I don't think it's worth the effort, plus I've already migrated to it and then from it. Don't want to go through this exercise all over again.

We can use Microsoft.Extensions.DependencyInjection and just have the DI resolve the injection of the correct serializer the user have chosen.

Yes, I like this idea!

@hartmark
Copy link
Contributor

I'm going on vacation tomorrow so I don't think I'll have to much time to look into getting some DI.

What made you leave xunit? I have only good experiences with it

@abatishchev
Copy link
Member Author

Ping on this idea.

@hartmark
Copy link
Contributor

I got back from vacation this week so I'll take a look in a few days.

What made you abandon xunit btw?

@abatishchev
Copy link
Member Author

tbh, I don't remember what was the exact trigger.

I always liked MSTest but back then it didn't support dynamic test data, xUnit did so I've switched. But then MSTest added the support and I've switched back. Plus a better VS and ADO integration and native support, if you will.

Also I work for Microsoft so don't mind using Microsoft own tools whenever possible :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants