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

Correct types in ArgumentException message

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor - P4 Minor - P4
    • 2.11.0
    • None
    • Builders
    • None
    • Minor Change

    Description

      Contributor description:

      Fixing expectation message whereby the wrong type is contained within the exception making it confusing to the end-user.

      Take for example the following test:

      [Fact]
      public void Test1()
      {
          PipelineDefinition<BsonDocument, MyType>.Create(new IPipelineStageDefinition[]
          {
              new JsonPipelineStageDefinition<BsonDocument, BsonDocument>(
                  @"{ project: { } } "),
          });
      }
       
      public class MyType { }
      

      This throws the following exception

       
      System.ArgumentException : The output type to the last stage was expected to be MongoDB.Bson.BsonDocument, but was MongoDB.Bson.BsonDocument. (Parameter 'stages')
      

      instead of

       
      System.ArgumentException : The output type to the last stage was expected to be SomeExample.MyType, but was MongoDB.Bson.BsonDocument. (Parameter 'stages')
      

      Contributor PR:
      https://github.com/mongodb/mongo-csharp-driver/pull/392

      Attachments

        Activity

          People

            vincent.kam@mongodb.com Vincent Kam (Inactive)
            vincent.kam@mongodb.com Vincent Kam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: