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

Legacy Conventions Are Not Handled Properly.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8.2
    • Affects Version/s: 1.8
    • Component/s: None
    • Labels:
      None
    • Minor Change

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            maxbl4 Vladimir Perevalov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: