Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-1138

CouchbaseBucket holds its own non-configurable ITypeTranscoder with a DefaultSerializer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • backlog-2.0, .backlog
    • 2.2.8
    • library
    • 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());
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            jmorris Jeff Morris
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty