question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support extending NEST types by deriving and implementing properties

See original GitHub issue

With the move to utf8json in #3493, the serialization of NEST types is strict, serializing only those properties specified on implemented interfaces in many places. For example, PropertyFormatter only serializes the I*Property interface members:

https://github.com/elastic/elasticsearch-net/blob/f3ec7198a979da2fe11ef8e14fbe69b072c92a43/src/Nest/Mapping/Types/PropertyFormatter.cs#L97-L192

With such strictness, it is not currently possible to derive a type from a NEST type, add additional properties, and have those properties serialized by the internal serializer. This is demonstrated in InjectACustomIPropertyImplementation()

https://github.com/elastic/elasticsearch-net/blob/e2b7f7529976d8a47a8db37d9dbb6b6bbcd8d253/src/Tests/Tests/ClientConcepts/HighLevel/Serialization/ExtendingNestTypes.doc.cs#L53-L97

utf8json is able to support this feature through using the fallback formatter, DynamicObjectTypeFallbackFormatter ,exposed by resolving a IJsonFormatter<object>, which internally inspects the type and generates a custom serialization method for it, caching it in a ThreadsafeTypeKeyHashTable<KeyValuePair<object, SerializeMethod>>. This path looks like it would be a plausible way to support extending NEST types but requires some guarding when serializing Attribute types; when a type to serialize is an Attribute type, the walking of properties performed by MetaType traverses down to a framework enum type with multiple members with the same undelying value, which trips up the EnumFormatter. For an Attribute type, this walking should not be performed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
russcamcommented, Jan 24, 2020

I’m going to close this issue and open a new specifically to track extending token filters https://github.com/elastic/elasticsearch-net/issues/3655#issuecomment-512823453

1reaction
bonny-bonevcommented, Jan 23, 2020

Hi again. The solution you suggested seems to work for us at this point. Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending NEST types | Elasticsearch .NET Clients [7.17]
NEST allows extending its types in some scenarios, discussed here. Creating your own property mappingedit. As an example, let's imagine we're using a...
Read more >
JEP 371: Hidden Classes
Support extending an access control nest with non-discoverable classes. Support aggressive unloading of non-discoverable classes, ...
Read more >
clap::_derive - Rust
This allows users to access the raw behavior of an attribute via <attr>(<value>) syntax. NOTE: Some attributes are inferred from Arg Types and...
Read more >
Is it possible to nest property wrappers in Swift when using ...
Ordering the wrappers in this way, I receive: "Property type 'MyModalViewModel' does not match that of the 'wrappedValue' property of its ...
Read more >
File upload | NestJS - A progressive Node.js framework
To handle file uploading, Nest provides a built-in module based on the multer ... By default, multer derives file type from file extension...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found