[CSHARP-751] Legacy Conventions Are Not Handled Properly. Created: 05/Jun/13  Updated: 14/May/14  Resolved: 05/Jun/13

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.8
Fix Version/s: 1.8.2

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

Issue Links:
Duplicate
Backwards Compatibility: Minor Change

 Description   

I was using driver version 1.8 and used conventions in a following way:

var cp = new ConventionProfile();
cp.SetIgnoreIfNullConvention(new AlwaysIgnoreIfNullConvention());
cp.SetIgnoreExtraElementsConvention(new AlwaysIgnoreExtraElementsConvention());
BsonClassMap.RegisterConventions(cp, t => true);

This worked fine. Then I've updated driver to 1.8.1, and I found that strong typed version of IndexKeysBuilder do not work anymore.
A code similar to IndexKeys<JsonArticleUniversal>.Ascending(x => x.insertTime);
failed with exception "JsonArticleUniversal does not have insertTime property".
Of course it have this property, the code is compiling.

I looked through the driver sources and found how classmap works. Then I've updated conventions to use new classes and everything began to work.

I see, that legacy version are marked as obsolete, but they should either still work or be totally removed.
I think the best and easiest way to close this bug, it to make constructors for legacy convention classes private. This will break the code and draw attention to the spot, then developers will be able to quickly find new classes and fix the problem. Otherwise, you should fix and support legacy classes.



 Comments   
Comment by Robert Stam [ 22/Jul/13 ]

The commit comment for:

https://github.com/mongodb/mongo-csharp-driver/commit/619e56445d973338cfac04ed665fb52547e9b6d4

references CSHARP-728. That ticket no longer exists.

CSHARP-751 is the same issue that CSHARP-728 originally referred to.

Comment by Craig Wilson [ 05/Jun/13 ]

Hi Max,
Sorry for the trouble. Yes, we had this bug report already and this should be fixed in master, but that ticket apparently got moved to a private ticket so you can't see it. We can use this ticket to track this. The intent was to have these be fully compatible, but unfortunately this regression was not caught before release. The old classes will likely be removed in 2.0.

This was fixed in this commit: https://github.com/mongodb/mongo-csharp-driver/commit/619e56445d973338cfac04ed665fb52547e9b6d4. It is in master, but hasn't been released. The fix for this will be in 1.9.

Craig

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