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

Support standard byte order when serializing Guids

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.1
    • Affects Version/s: 1.0
    • Component/s: None
    • None
    • Minor Change

      Sadly, all existing C# drivers, including this official one, have been serializing Guids with the wrong byte order all along. This is because the byte array returned by Guid.ToByteArray returns an array where the first three groups (of 4, 2 and 2 bytes respectively) are reversed, as in little endian format.

      This is not a problem as long as only C# drivers are reading and writing the Guids. However, all other drivers are storing UUIDs with the standard byte order, so it becomes difficult to interoperate between the C# and other drivers when using Guids.

      This feature request is for a mechanism to allow C# applications to indicate when they would like Guids to be serialized using the standard byte order instead of Microsoft's internal byte order. For historical reasons everything will continue to default to Microsoft's byte order (so as not to break backward compatibility with existing code and data).

      There will be a new enum:

      public enum GuidByteOrder

      { Microsoft, Standard }

      To see all the changes involved in implementing this feature start by searching for occurrences of "GuidByteOrder" and follow the code changes from there (or look at the commit).

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: