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

fix Newtonsoft.Json.JsonSerializationException unable to find constru… #331

Closed
wants to merge 1 commit into from

Conversation

mdemmers
Copy link

when deserializing mailkit searchquery (in use with hangfire job) the error "Newtonsoft.Json.JsonSerializationException cannot find default public constructor" is thrown.
Adding the default constructor fixes the deserialization error.

@jstedfast
Copy link
Owner

There's a reason I don't provide a default .ctor, though, which is that it needs a SearchTerm or you end up with a SearchQuery object with an invalid state.

@mdemmers
Copy link
Author

Could fix that by using a private class variable SearchTerm initialised from default ctor.

@jstedfast
Copy link
Owner

Initialized to what? What would be the default expectation of the type of search if someone writes:

var query = new SearchQuery ();

This is why I don't want a public .ctor. It makes the API confusing.

@mdemmers
Copy link
Author

Alright valid point. You could initialize with SearchTerm.All and provide a public ctor overload with SearchTerm param.

jstedfast added a commit that referenced this pull request Apr 30, 2016
@jstedfast jstedfast closed this Apr 30, 2016
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