|
This behavior is as expected.
In `GuidRepresentationMode.V2` all Guids are converted on output to the configured representation for the JsonWriter, which by default is `CSharpLegacy` (or whatever `BsonDefaults.GuidRepresentation` is set to if it has been changed).
If you don't want the JSON representation to reflect the default `GuidRepresentation` you can configure the JSON writer to not convert all Guids on output by setting the writer's `GuidRepresentation` to `Unspecified`
var stringDocument = bsonDocument.ToJson(new JsonWriterSettings { GuidRepresentation = Unspecified });
|
Also, the string form in `CSUUID("...")` reflects the actual Guid value, not the byte order in the underlying byte array, so the last test should be:
stringDocument.Should().Contain("3fdabe71-f829-4469-9c5c-15cc4881c50c"); // instead of NotContain
|
As an alternative to setting the `JsonWriterSettings.GuidRepresentation` to `Unspecified` you could instead set `BsonDefaults.GuidRepresentationMode` to `V3` (but not that that's a global setting).
|