Support extending NEST types by deriving and implementing properties
See original GitHub issueWith 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:
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()
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:
- Created 4 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
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
Hi again. The solution you suggested seems to work for us at this point. Thank you very much!