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

Implementations of IConvertible.ToType should handle conversion to type object

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.8.3
    • Fix Version/s: 1.9
    • Component/s: None
    • Labels:
      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

          Issue Links

            Activity

              People

              Assignee:
              rstam Robert Stam
              Reporter:
              rstam Robert Stam
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: