From: Anirudh Agnihotry Date: Fri, 24 May 2019 15:50:13 +0000 (-0700) Subject: rename ToBytes to ToUtf8Bytes (dotnet/corefx#37912) X-Git-Tag: submit/tizen/20210909.063632~11031^2~1500 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84aa86c5875b809426876ced182144329aa668c8;p=platform%2Fupstream%2Fdotnet%2Fruntime.git rename ToBytes to ToUtf8Bytes (dotnet/corefx#37912) Commit migrated from https://github.com/dotnet/corefx/commit/4e342b94a06e21604cd805d0340ef871adc47c43 --- diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.cs b/src/libraries/System.Text.Json/ref/System.Text.Json.cs index 935efd7..fd42e29 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.cs +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.cs @@ -382,8 +382,8 @@ namespace System.Text.Json.Serialization public static TValue Parse(string json, System.Text.Json.Serialization.JsonSerializerOptions options = null) { throw null; } public static System.Threading.Tasks.ValueTask ReadAsync(System.IO.Stream utf8Json, System.Type returnType, System.Text.Json.Serialization.JsonSerializerOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.ValueTask ReadAsync(System.IO.Stream utf8Json, System.Text.Json.Serialization.JsonSerializerOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public static byte[] ToBytes(object value, System.Type type, System.Text.Json.Serialization.JsonSerializerOptions options = null) { throw null; } - public static byte[] ToBytes(TValue value, System.Text.Json.Serialization.JsonSerializerOptions options = null) { throw null; } + public static byte[] ToUtf8Bytes(object value, System.Type type, System.Text.Json.Serialization.JsonSerializerOptions options = null) { throw null; } + public static byte[] ToUtf8Bytes(TValue value, System.Text.Json.Serialization.JsonSerializerOptions options = null) { throw null; } public static string ToString(object value, System.Type type, System.Text.Json.Serialization.JsonSerializerOptions options = null) { throw null; } public static string ToString(TValue value, System.Text.Json.Serialization.JsonSerializerOptions options = null) { throw null; } public static System.Threading.Tasks.Task WriteAsync(object value, System.Type type, System.IO.Stream utf8Json, System.Text.Json.Serialization.JsonSerializerOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.ByteArray.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.ByteArray.cs index 595bac8..7769842 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.ByteArray.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.ByteArray.cs @@ -12,7 +12,7 @@ namespace System.Text.Json.Serialization /// A UTF-8 representation of the value. /// The value to convert. /// Options to control the conversion behavior. - public static byte[] ToBytes(TValue value, JsonSerializerOptions options = null) + public static byte[] ToUtf8Bytes(TValue value, JsonSerializerOptions options = null) { return WriteCoreBytes(value, typeof(TValue), options); } @@ -24,7 +24,7 @@ namespace System.Text.Json.Serialization /// The value to convert. /// The type of the to convert. /// Options to control the conversion behavior. - public static byte[] ToBytes(object value, Type type, JsonSerializerOptions options = null) + public static byte[] ToUtf8Bytes(object value, Type type, JsonSerializerOptions options = null) { VerifyValueAndType(value, type); return WriteCoreBytes(value, type, options); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.String.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.String.cs index 48c53aa..3a408a8 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.String.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.String.cs @@ -13,7 +13,7 @@ namespace System.Text.Json.Serialization /// The value to convert. /// Options to control the conversion behavior. /// Using a is not as efficient as using UTF-8 - /// encoding since the implementation internally uses UTF-8. See also + /// encoding since the implementation internally uses UTF-8. See also /// and . /// public static string ToString(TValue value, JsonSerializerOptions options = null) @@ -29,7 +29,7 @@ namespace System.Text.Json.Serialization /// The type of the to convert. /// Options to control the conversion behavior. /// Using a is not as efficient as using UTF-8 - /// encoding since the implementation internally uses UTF-8. See also + /// encoding since the implementation internally uses UTF-8. See also /// and . /// public static string ToString(object value, Type type, JsonSerializerOptions options = null) diff --git a/src/libraries/System.Text.Json/tests/Serialization/SpanTests.cs b/src/libraries/System.Text.Json/tests/Serialization/SpanTests.cs index b8ef567..2dd50b7 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/SpanTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/SpanTests.cs @@ -60,12 +60,12 @@ namespace System.Text.Json.Serialization.Tests byte[] encodedNull = Encoding.UTF8.GetBytes(@"null"); { - byte[] output = JsonSerializer.ToBytes(null, null); + byte[] output = JsonSerializer.ToUtf8Bytes(null, null); Assert.Equal(encodedNull, output); } { - byte[] output = JsonSerializer.ToBytes(null, typeof(NullTests)); + byte[] output = JsonSerializer.ToUtf8Bytes(null, typeof(NullTests)); Assert.Equal(encodedNull, output); } } diff --git a/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.cs index 55f0643..eb557eb 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/Value.WriteTests.cs @@ -29,7 +29,7 @@ namespace System.Text.Json.Serialization.Tests } { - Span json = JsonSerializer.ToBytes(1); + Span json = JsonSerializer.ToUtf8Bytes(1); Assert.Equal(Encoding.UTF8.GetBytes("1"), json.ToArray()); } @@ -39,7 +39,7 @@ namespace System.Text.Json.Serialization.Tests } { - Span json = JsonSerializer.ToBytes(long.MaxValue); + Span json = JsonSerializer.ToUtf8Bytes(long.MaxValue); Assert.Equal(Encoding.UTF8.GetBytes(long.MaxValue.ToString()), json.ToArray()); } @@ -49,7 +49,7 @@ namespace System.Text.Json.Serialization.Tests } { - Span json = JsonSerializer.ToBytes("Hello"); + Span json = JsonSerializer.ToUtf8Bytes("Hello"); Assert.Equal(Encoding.UTF8.GetBytes(@"""Hello"""), json.ToArray()); } } diff --git a/src/libraries/System.Text.Json/tests/Utf8JsonWriterTests.cs b/src/libraries/System.Text.Json/tests/Utf8JsonWriterTests.cs index 34f97e9..7eb66b6 100644 --- a/src/libraries/System.Text.Json/tests/Utf8JsonWriterTests.cs +++ b/src/libraries/System.Text.Json/tests/Utf8JsonWriterTests.cs @@ -3504,7 +3504,7 @@ namespace System.Text.Json.Tests public void WriteDateTime_TrimsFractionCorrectly_SerializerRoundtrip() { DateTime utcNow = DateTime.UtcNow; - Assert.Equal(utcNow, Serialization.JsonSerializer.Parse(Serialization.JsonSerializer.ToBytes(utcNow), typeof(DateTime))); + Assert.Equal(utcNow, Serialization.JsonSerializer.Parse(Serialization.JsonSerializer.ToUtf8Bytes(utcNow), typeof(DateTime))); } private static void WriteTooLargeHelper(JsonWriterOptions options, ReadOnlySpan key, ReadOnlySpan value, bool noThrow = false)