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

Implementations of IConvertible.ToType should handle conversion to type object

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.9
    • Affects Version/s: 1.8.3
    • Component/s: None
    • None

      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);
      

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

              Created:
              Updated:
              Resolved: