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

Implementations of IConvertible.ToType should handle conversion to type object

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 1.9
    • 1.8.3
    • None
    • None

    Description

      The current implementations of IConvertible.ToType do not handle conversion to type object. We were not expecting ToType to be called with a conversionType argument of type object (after all you can simply cast to object), but it turns out this is legal so we should support it.

      The following code snippet currently throws an InvalidCastException:

      var id = ObjectId.GenerateNewId();
      var obj = ((IConvertible)id).ToType(typeof(object), null);

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: