From db7b5dfb685ab128150ad6026c49b074c3eb07aa Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:52:45 -0700 Subject: [PATCH 1/3] Improve docs for BinaryData.ToString() --- src/libraries/System.Memory.Data/src/System/BinaryData.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libraries/System.Memory.Data/src/System/BinaryData.cs b/src/libraries/System.Memory.Data/src/System/BinaryData.cs index 2e5dfbfacfb688..205ef1d39cf139 100644 --- a/src/libraries/System.Memory.Data/src/System/BinaryData.cs +++ b/src/libraries/System.Memory.Data/src/System/BinaryData.cs @@ -192,6 +192,11 @@ public static BinaryData FromObjectAsJson(T jsonSerializable, JsonSerializerO /// /// Converts the value of this instance to a string using UTF-8. /// + /// + /// If the underlying object is a JSON string, calling will retain the wrapping double quotes in the + /// resulting string. If you want to deserialize the JSON string to a string, thereby removing the wrapping double quotes, + /// call instead. + /// /// /// A string from the value of this instance, using UTF-8 to decode the bytes. /// From 7450d3fc2f4247315d156475c36d2015523af977 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 11 Aug 2021 14:42:45 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Jeremy Barton --- src/libraries/System.Memory.Data/src/System/BinaryData.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Memory.Data/src/System/BinaryData.cs b/src/libraries/System.Memory.Data/src/System/BinaryData.cs index 205ef1d39cf139..98219330f1a9cc 100644 --- a/src/libraries/System.Memory.Data/src/System/BinaryData.cs +++ b/src/libraries/System.Memory.Data/src/System/BinaryData.cs @@ -193,9 +193,10 @@ public static BinaryData FromObjectAsJson(T jsonSerializable, JsonSerializerO /// Converts the value of this instance to a string using UTF-8. /// /// - /// If the underlying object is a JSON string, calling will retain the wrapping double quotes in the - /// resulting string. If you want to deserialize the JSON string to a string, thereby removing the wrapping double quotes, - /// call instead. + /// No special treatment is given to the contents of the data, it is merely decoded as a UTF-8 string. + /// For a JPEG or other binary file format the string will largely be nonsense with many embedded NUL characters, + /// and UTF-8 JSON values will look like their file/network representation, + /// including starting and stopping quotes on a string. /// /// /// A string from the value of this instance, using UTF-8 to decode the bytes. From 5b38f0ca7ff7d447183d5053f66722e7c51693d9 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 11 Aug 2021 14:43:25 +0200 Subject: [PATCH 3/3] Apply suggestion from Jeremy --- src/libraries/System.Memory.Data/src/System/BinaryData.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Memory.Data/src/System/BinaryData.cs b/src/libraries/System.Memory.Data/src/System/BinaryData.cs index 98219330f1a9cc..b13232f49f0ff1 100644 --- a/src/libraries/System.Memory.Data/src/System/BinaryData.cs +++ b/src/libraries/System.Memory.Data/src/System/BinaryData.cs @@ -201,6 +201,7 @@ public static BinaryData FromObjectAsJson(T jsonSerializable, JsonSerializerO /// /// A string from the value of this instance, using UTF-8 to decode the bytes. /// + /// public override unsafe string ToString() { ReadOnlySpan span = _bytes.Span;