-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 1.8.3
-
Component/s: None
-
None
My application analyses various documents created by the driver, including query and update documents from builders. I noticed the following problem. I was assuming that if BsonValue.BsonType is Document then it is valid to call AsBsonDocument on it. This is not true for BsonDocumentWrapper - its type is Document (set in the constructor) but AsBsonDocument is not overridden and throws "Cannot cast ...". Update builder Pull(query) creates such a wrapper, for example.
If BsonDocumentWrapper wraps a document then AsBsonDocument should get this document. Otherwise it should not set its BsonType to Document or even be called a document wrapper.
Currently an application dealing with generic documents, including created by the driver, has to perform checks for BsonDocumentWrapper type explicitly and unwrap it. This is neither effective nor natural, especially taking into account that BsonDocumentWrapper, I think, is mostly designed for internal driver needs.