Skip to content

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

Closed
mdemmers wants to merge 1 commit into
jstedfast:masterfrom
mdemmers:master
Closed

mdemmers wants to merge 1 commit into
jstedfast:masterfrom
mdemmers:master

Conversation

@mdemmers

Copy link
Copy Markdown

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

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

@jstedfast

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