[CSHARP-1708] Add Support For GUID in ToString representation of a cursor Created: 12/Jul/16  Updated: 13/Jul/16  Resolved: 13/Jul/16

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

Type: Improvement Priority: Major - P3
Reporter: Peter Garafano (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-3153 The mongo shell needs better support ... Closed

 Description   

Currently, when calling ToString() on a cursor, if it includes a Guid, the resulting output looks something like:

CSUUID("f7402520-3018-4b8e-9414-4d93a244f9b0")

We should add a shell friendly version of this output. At its most basic it is as simple as converting to a byte array then to a base64 encoded string.

var str = $"new BinData(3, \"{Convert.ToBase64String(guid.ToByteArray())}\")";



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

We output UUIDs this way on purpose. For two reasons:

1. It is important to know the UUID representation being used (CSUUID, JUUID or PYUUID)
2. It is important for developers to be able to read the UUIDs, and UUIDs are represented in hex not in base 64

There is a long standing SERVER-3153 ticket requesting better support for UUID constants in the shell. In the meantime, shell users can use the helper functions in uuidhelpers.js (see the SERVER ticket) to work with UUIDs represented in this manner.

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