[CSHARP-834] Implementations of IConvertible.ToType should handle conversion to type object Created: 02/Oct/13  Updated: 02/Apr/15  Resolved: 03/Oct/13

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.8.3
Fix Version/s: 1.9

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CSHARP-835 Implement TypeConverter for ObjectId Backlog

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



 Comments   
Comment by auto [ 03/Oct/13 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-834: Implementations of IConvertible.ToType should support conversion to type object
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/87bb8e5320f32eeeadb854d236471970219ddf23

Generated at Wed Feb 07 21:37:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.