Return values of SingleOrDefaultAsync incorrect when nullable reference types are enabled

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: LINQ
    • None
    • Dotnet Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      In my project I have nullable reference types enabled.
      <Nullable>enable</Nullable>

      I believe the return type is incorrect for the following methods 

      • FirstOrDefaultAsync
      • LastOrDefaultAsync
      • SingleOrDefaultAsync

      According to documentation and understanding of "OrDefault" return value should be nullable. But now it's not.

       

      Example file: IFindFluentExtensions.cs

       

      https://github.com/mongodb/mongo-csharp-driver/blob/main/src/MongoDB.Driver/IFindFluentExtensions.cs#L298

            Assignee:
            Oleksandr Poliakov
            Reporter:
            Дмитрий Цибань
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: