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

Guid Serialization Bug?

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.11
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows 7, mongod 1.6.5

      Maybe I'm doing something wrong here, but the Guid serialization in the C# driver seems very odd.

      I save a Guid with a normal windows represenation of "53E32701-9863-DE11-BD66-0015178A5E3C".

      I get that Guid back out of mongo from the shell as:

      ASfjU2OYEd69ZgAVF4pePA==

      If I call hex():

      127e353639811debd66015178a5e3c

      If I use a little function I wrote in Powershell as follows:

      function base64toguid
      {
      param($str);
      $b = [System.Convert]::FromBase64String($str);
      $hex = "";
      $idx = 0;
      foreach ($x in $b)

      { $hex += $x.ToString("x2"); }

      $g = new-object -TypeName System.Guid -ArgumentList $hex;
      return $g;
      }

      I get: 0127e353-6398-11de-bd66-0015178a5e3c, which is the same as hex() from the shell.

      So to compare them closely:

      53E32701-9863-DE11-BD66-0015178A5E3C
      0127e353-6398-11de-bd66-0015178a5e3c

      The first three sets look like they are reversed as if it's some sort of endian issue, but the last two are not reversed. Since the dashes are totally arbitrary, if it was an endian issue it seems like the whole thing would be reversed.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            ericzbeard Eric Z. Beard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: