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

MissingMethodException when running on mono with newer Newtonsoft.Json #118

Closed
slang25 opened this issue Jul 4, 2019 · 13 comments · Fixed by #127
Closed

MissingMethodException when running on mono with newer Newtonsoft.Json #118

slang25 opened this issue Jul 4, 2019 · 13 comments · Fixed by #127
Assignees
Labels
bug A defect in the code or documentation.
Milestone

Comments

@slang25
Copy link
Member

slang25 commented Jul 4, 2019

This is quite an exotic setup I know, but this has my tests failing in CI, so I'll be looking into this too.

I have an example here:
a776327#diff-ad2944e2db1bf6a75b8602f406da7846R13

When running under mono, if I call .WithJsonContent(... then it pops with a runtime exception:

Error Message:
   System.MissingMethodException : Method not found: JustEat.HttpClientInterception.HttpRequestInterceptionBuilder JustEat.HttpClientInterception.HttpRequestInterceptionBuilderExtensions.WithJsonContent(JustEat.HttpClientInterception.HttpRequestInterceptionBuilder,object,Newtonsoft.Json.JsonSerializerSettings)

In recreating this, I discovered that it's not an issue if you are referencing Newtonsoft.Json 9.0.1, but if you reference a higher version such as 12.x then this issue pops up.

@martincostello
Copy link
Member

Yay, breaking changes are fun! 😭

@martincostello
Copy link
Member

This is particularly weird as we're happily using 12.0.2 internally in our apps' tests.

@martincostello
Copy link
Member

Though we're not using the overload that takes a JsonSerializerSettings.

@slang25
Copy link
Member Author

slang25 commented Jul 4, 2019

Also, I've not tried it on windows with Full Framework, it might be a mono only quirk, not sure yet.
Edit: Works on netcoreapp2.x

@martincostello
Copy link
Member

@martincostello
Copy link
Member

martincostello commented Jul 4, 2019

If this is a blocker it'll have to wait until .NET Core 3.0 ships in September, because then we can ship a 3.0.0 of this as a breaking change and remove the dependency on Netwonsoft.Json to give people the option to use System.Text.Json instead.

(And it would be tidier to ship a 3.0 to go with 3.0 😄)

@slang25
Copy link
Member Author

slang25 commented Jul 4, 2019

I ideally need a fix soonish, my workaround would be running this on core, but we want mono cause it's the closest thing to xamarin iOS/Android which is our target platform.

That exception tells me it can't find WithJsonContent, so I don't get why the version of newtonsoft has anything to do with it, surely the exception message is wrong and it means some other method?

@martincostello
Copy link
Member

Yeah, it's a weird one. Something about optional parameters and/or a change somewhere in 12.x with JsonSerializerSettings?

@martincostello
Copy link
Member

I'd be happy to look at doing a beta of a 3.0.0 with changes to decouple Newtonsoft.Json in the soon-ish future (within a week?) and pushing it to NuGet to unblock you though.

@slang25
Copy link
Member Author

slang25 commented Jul 4, 2019

That would be amazing, in the meantime if I figure out anything more I'll let you know 😃

@martincostello martincostello added this to the v3.0.0 milestone Jul 4, 2019
@martincostello martincostello added the bug A defect in the code or documentation. label Jul 4, 2019
@martincostello martincostello self-assigned this Jul 4, 2019
@martincostello
Copy link
Member

I'll see if I can pick up the above this week.

@martincostello
Copy link
Member

See #127 for a fix candidate.

@slang25
Copy link
Member Author

slang25 commented Aug 4, 2019

Pulled it down and can confirm this has fixed it 😄 Nice one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect in the code or documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants