Details
-
Bug
-
Resolution: Won't Fix
-
Major
-
2.2.8
-
None
Description
When using a custom ITypeSerializer, for example in order to add a custom JSON converter, it may not be used by certain methods of CouchbaseBucket, like GetAsync<T>(key) .
So, while the method QueryAsync<T>(queryRequest) ends up using the correct, configured ITypeSerializer, this is ignored by the method GetAsync<T>(key).
In my codebase I horribly solved this with reflection after every creation of a bucket instance:
var bucket = _cluster.OpenBucket(bucketName);
|
var transcoder = bucket.GetType().GetField("_transcoder", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(bucket);
|
var serializer = (DefaultSerializer)((DefaultTranscoder)transcoder).Serializer;
|
serializer.DeserializationSettings.Converters.Add(new SerializableAbstractTypeConverter());
|