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

Could we de-serialize arrays as ArrayList or List<object>?

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None
    • .Net
    • Major Change

    Description

      Could we de-serialize arrays as ArrayList or List? In Javascript, an "Array" behaves like a .Net ArrayList or List. Furthermore, the behavior of deserialization is somewhat non-deterministic as the programmer can really only count on getting an IEnumerable as opposed to a working collection. This is especially the case with mixed types, where the programmer would usually get an object[], but might get an int[] or string[].

      This would be a breaking change, but it would be worth it.

      ------------

      A potential way to do it is (in BsonReader.cs):

      private Object ConvertToArray (Document doc)

      { List<object> ret = new List<object>(); foreach (String key in doc.Keys) ret.Add(doc[key]); return ret; }

      --------------

      (Note: I'm trying to keep my local branch as close as possible to the master, so I'm keeping this out of my local branch.)

      Attachments

        Activity

          People

            sam Sam Corder
            gwbasic Andrew Rondeau
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: