Implementations of IConvertible.ToType should handle conversion to type object

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.9
    • Affects Version/s: 1.8.3
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 Stam
              Reporter:
              Robert Stam
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: