Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4057

LinqV3 Null Coalescing operator with empty string expression results in "Cannot find serializer for null"

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.17.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible

      Summary

      When doing an aggregate containing a projection expression like:

      .Project(
          augmentedProductType => new ProductTypeSearchResult
          {
              IsExternalUrl = string.IsNullOrEmpty(augmentedProductType.ShopUrl ?? "")
          }
      

       
      An InvalidOperationException occurs with message "Cannot find serializer for null."

      This happens with string.Empty as well.

      Driver version 2.14.1

      How to Reproduce

      Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

      This seems to occur in ConstantExpressionToAggregationExpressionTranslator when making the call to get the serializer.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            richard.collette@precisely.com Rich Collette
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: