Skip to content

Honour DataMember and DataContract attributes #3304

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

Merged
merged 2 commits into from
Jun 25, 2018
Merged

Honour DataMember and DataContract attributes #3304

merged 2 commits into from
Jun 25, 2018

Conversation

russcam
Copy link
Contributor

@russcam russcam commented Jun 25, 2018

This commit updates the behaviour of TypeNameResolver and
PropertyMapping to respect the usage of DataMember and
DataContract attributes for all requests.

Prior behaviour to this commit was that indexing would honour
DataMember attributes on a document due to the internal implementation of
JSON.Net honouring them. With other requests such as Search however,
where a Field type is used, the the resolution of the Field string name did
not honour the attributes.

Closes #3107

@russcam russcam requested a review from codebrain June 25, 2018 02:19
Copy link
Contributor

@codebrain codebrain left a comment

Choose a reason for hiding this comment

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

  • Update docs with resolve ordering information
  • Split test into type name / property name

LGTM though.

russcam added 2 commits June 25, 2018 13:37
This commit updates the behaviour of TypeNameResolver and
PropertyMapping to respect the usage of DataMember and
DataContract attributes for all requests.

Prior behaviour to this commit was that indexing would honour
DataMember attributes on a document due to the internal implementation of
JSON.Net honouring them. With other requests such as Search however,
where a Field type is used, the the resolution of the Field string name did
not honour the attributes.

Closes #3107
@russcam russcam merged commit 97455b8 into 6.x Jun 25, 2018
russcam added a commit that referenced this pull request Jun 25, 2018
* Honour DataMember and DataContract attributes

This commit updates the behaviour of TypeNameResolver and
PropertyMapping to respect the usage of DataMember and
DataContract attributes for all requests.

Prior behaviour to this commit was that indexing would honour
DataMember attributes on a document due to the internal implementation of
JSON.Net honouring them. With other requests such as Search however,
where a Field type is used, the resolution of the Field string name did
not honour the attributes.

Include behaviour in documentation

Closes #3107

(cherry picked from commit 97455b8)
russcam added a commit that referenced this pull request Jun 25, 2018
* Honour DataMember and DataContract attributes

This commit updates the behaviour of TypeNameResolver and
PropertyMapping to respect the usage of DataMember and
DataContract attributes for all requests.

Prior behaviour to this commit was that indexing would honour
DataMember attributes on a document due to the internal implementation of
JSON.Net honouring them. With other requests such as Search however,
where a Field type is used, the resolution of the Field string name did
not honour the attributes.

Include behaviour in documentation

Closes #3107

(cherry picked from commit 97455b8)
@russcam russcam deleted the fix/3107 branch August 24, 2018 06:47
@D9001
Copy link

D9001 commented Aug 1, 2019

I'm using .NET Core 2.2 with NEST 7.0.1, and whenever I have a class with DataContract and DataMember on a nested property, the objects in the nested property array are created as [{},{}] (if I have 3 properties, there would be 3 empty objects inside). When I take DataContract and DataMember attributes off, everything is serialized just fine.. Is this a known issue?

Is there any way around this? I'd like to avoid creating extra classes with the same properties but different attributes.

@russcam
Copy link
Contributor Author

russcam commented Aug 2, 2019

@D9001 It's best to open a separate issue about this and link to this PR; a comment is likely to end up being lost as it's not as visible as an issue. Please open an issue an provide as much detail as you can, ideally with a reproducible example, so that it helps understand more quickly.

@niemyjski
Copy link
Contributor

We have our own json.net serializer defined in NEST 7.5.1 and we are doing our own naming strategy that ignores DataMember Attributes (on purpose) and we are hitting our break points as expected. But we noticed that the models that are being serialized that have the data member name are preserved even though our naming strategy is hit.. Any idea why this would be happening in NEST 7, was working as expected in NEST 5.

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.

4 participants