applejag/Newtonsoft.Json-for-Unity

Suggestion: Backport to Json.NET 11.x.x, 10.x.x, 9.x.x, and 8.x.x

applejag opened this issue ยท 11 comments

Description

This project is lacking for the users who do not want to update their projects to target a Json..NET 12.0.1. Suggesting to downgrade all the way down to 8.0.3. Of course all provided as the usual UPM provider and others.

This includes:

Edit: Will not backport 8.0.1 nor 8.0.2 in favor of instead only supporting 8.0.3, as they are only minor patches of the same version, and are fully backwards compatible. Same goes for 10.0.1, 10.0.2, and 11.0.1.

Edit 2: Will not do 9.0.x nor 8.0.x at all. See comments.

Why we need this

To gain more users. More users equals more bug reports. More bug reports equals more bugfixes. More bugfixes equals better repository.

Suggested solution

For each old version, create a new release, and revert the changes made from for example 11.0.2 to 12.0.1. Important to keep track of the conflicting changes.

Deployment can perhaps be automated with making a backport branch with deployment jobs of the CI/CD enabled. Or just doing it manually.

Thank you for your hard work.

I have problem with this package when I try to plug google.apis.sheets.v4 with Unity 2019.2.13.
Error: Could not load signature of Google.Apis.Auth.GoogleJsonWebSignature+<>c:<GetGoogleCertsFromJson>b__16_0 due to: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. assembly:Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed type:<unknown type> member:(null) signature:<none>

  • google.apis.sheets.v4 is latest v4.1.42.0.1791 with proper dependencies acquired via nuget.
    its dependency chain includes newtonsoft.json >= 10.0.0.2
    (And this is the point I don't get it why higher version is not working)
  • Api Compatibility Level - unfortunately both 4.x / 2.0 fails with your package
  • IDE reports zero problem, confirmed References, even build was succeeded
  • But in Unity, same error occurs and unloads broken Google.Apis.Core and Google.Apis.Auth

The only solution that worked I found was;

  • Use .NET 2.0 for every google DLLs
  • Use Newtonsoft.Json.10.0.2 for .Net 2.0 from NuGet
  • At least Unity Editor working flawlessly
  • Both Api Compatibility Level 2.0 and 4.x are working

Since working dll is untouched, I guess I would face AOT problem later.
I wonder if there's any workaround or backport / net2.0 support may solve this problem.

Thanks again for your time and effort.

@tsweeper Big thank you for too wanting to put time into finding solutions for this :) I'm glad to see others even try to debug these things.

Due to being somewhat unrelated to this issue #16, I've therefore moved your comment into a issue of its own, #26, where conversation can continue.

Change of mind, will not some versions. Note added to description:

"Will not backport 8.0.1 nor 8.0.2 in favor of instead only supporting 8.0.3, as they are only minor patches of the same version, and are fully backwards compatible. Same goes for 10.0.1, 10.0.2, and 11.0.1."

Hi, your marked the comment from tsweeper as off-topic , but would porting to newtonsoft json 10.0.x solve the issue ? (We're encountering this same issue on Google but also Jira, both dll can't load the forked json dll)

@Nanorock

Yes it would! Actually it's just the version number that's the problem. I've not found the time to start backporting. Hopefully soon.

xabio commented

@jilleJr Please keep us informed, as SinglaR is using Newtonsoft

Assembly 'Assets/Plugins/Microsoft.AspNetCore.SignalR.Common.dll' will not be loaded due to errors:
Microsoft.AspNetCore.SignalR.Common references strong named Newtonsoft.Json in a different folder, versions has to match. Assembly references: 11.0.0.0 Found in project: 12.0.0.0.

We could offer you beer to boost your deliveries ;)

@xabio Ooo nice that you're using SignalR :o

I must though counter with my list of excuses:

  1. This is a "boring" task, just tedious and I personally don't expect it to be fun.

That being said, I did actually kind of expect Unity's fork of my repo to add backporting, but I must've misunderstood them. Seems like they never will add backports.

I'll take a closer look at this, see if it's really that difficult and tedious.

Side note: I currently don't take beer as a payment ;) I am accepting donations for coffee, though I'm currently getting more money than I'm spending on coffee (OpenCollective ensures I only spend money on stuff I'm accepting donations for). Odd problem to have.

xabio commented

@jilleJr and is there some way to tell Unity to take that Newtonsoft you have created, as it was the 11.0.0 version ?
Some kind of binding redirect ? Many thanks, you job is really awesome , cannot understand how you got to that degree of knowledge about Newtonsoft internal side

@xabio sorry to say that binding redirections are not supported in Unity. Which also means you can only use 1 version of Newtonsoft.Json at a time.

@xabio I tried and backporting to 11.0.2 was not that difficult actually. I think mostly because 11.0.2 and 12.0.3 are differenciating in more or less bug fixes only. I'm honestly quite scared of attempting this for 10.0.3, but as Json .NET 10.x has been so frequently requested, I will at least make an honest attempt on it.

I didn't think about the upm branch that I have set up, so I kind of messed that one up. The latest version on the upm branch is currently the 11.0.202, which is misleading as 12.x is the latest. I will probably set up some new branch, like upm-11.0.2 or something. Don't think I can add upm/11.0.2 though due to Git restrictions.

Newtonsoft.Json-for-Unity 11.0.202 (based on Newtonsoft.Json 11.0.2) has just been released and is available via the Cloudsmith and OpenUPM registries already

2021-02-25-210022_928x723_scrot

Happy news!

Now the package has both a Json .NET v11.0.2 and a v10.0.3 backports!

@tsweeper It is 473 days later, so I assume you may have moved on to a different project like 3 consecutive times by now, but as they say: Better late than never ๐Ÿ˜… You should now be able to use google.apis.sheets.v4 with this package :)

It's much less relevant nowadays as since their Google.Apis.Core v1.44.0 they switched to using Newtonsoft.Json 12.0.x.

I'm pulling the breaks here on the backporting. I'm not going to backport any further unless someone really needs it. It was since Json .NET 10.0.x that they started using the new SDK styled csproj format, and the older format is such an extreme headache to work with.

If anyone needs Json.NET v9.0.x or lower, then open a new issue

To be extra clear: It's not planned, but I will consider it if anyone needs it. I want to get to work on other stuff for this repo. This issue has been dragging my mind for too long.