Skip to content

Conversation

@russcam
Copy link
Contributor

@russcam russcam commented Jun 27, 2017

When converting a LazyDocument to type T, use the JsonNetSerializer configured, along with all registered contract resolvers.

Fixes #2788

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LgTM with one q? Maybe add a comment there explaining why we need to write null?

var d = value as LazyDocument;
if (d?._Value == null)
{
writer.WriteNull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change needed?

Copy link
Contributor Author

@russcam russcam Jun 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an oversight in the implementation; if d is null or d.Value is null and a value is not written to the writer for it, invalid json can be emitted e.g. if LazyDocument is assigned to the property of an object and that object serialized, the property name could be written to the writer (depending on serialization settings) so a value must also be written in this case

@Mpdreamz
Copy link
Member

Can we also add an ovlerload to fix #2408 as part of this PR.

Two for one :)

@russcam
Copy link
Contributor Author

russcam commented Jun 28, 2017

What overload were you thinking of for #2408, @Mpdreamz?

@Mpdreamz
Copy link
Member

@russcam
Copy link
Contributor Author

russcam commented Jun 28, 2017

Gotcha

russcam and others added 3 commits June 29, 2017 13:08
When converting a LazyDocument to type T, use the JsonNetSerializer configured, along with all registered contract resolvers.

Fixes #2788
@russcam russcam merged commit 109bcb0 into 5.x Jun 29, 2017
russcam added a commit that referenced this pull request Jun 29, 2017
* Use serializer when deserializing LazyDocument to T

When converting a LazyDocument to type T, use the JsonNetSerializer configured, along with all registered contract resolvers.

Fixes #2788

* Direct cast

* Add non-generic overload for As()

Relates #2408

(cherry picked from commit 109bcb0)
russcam added a commit that referenced this pull request Jun 29, 2017
* Use serializer when deserializing LazyDocument to T

When converting a LazyDocument to type T, use the JsonNetSerializer configured, along with all registered contract resolvers.

Fixes #2788

* Direct cast

* Add non-generic overload for As()

Relates #2408

(cherry picked from commit 109bcb0)
@russcam
Copy link
Contributor Author

russcam commented Jun 29, 2017

ported to 2.x in c77ee31
ported to master in bd71ff8

@russcam russcam deleted the fix/2788 branch June 29, 2017 03:14
awelburn pushed a commit to Artesian/elasticsearch-net that referenced this pull request Nov 6, 2017
* Use serializer when deserializing LazyDocument to T

When converting a LazyDocument to type T, use the JsonNetSerializer configured, along with all registered contract resolvers.

Fixes elastic#2788

* Direct cast

* Add non-generic overload for As()

Relates elastic#2408

(cherry picked from commit 109bcb0)
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.

3 participants