Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Rename JsonWriterUtf8 to JsonWriter (#2352)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsonkhan authored Jun 7, 2018
1 parent 73fec18 commit f801662
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions samples/LowAllocationWebServer/Shared/SampleServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void WriteResponseForGetJson(HttpRequest request, ReadOnlySequence<byte>
response.AppendEoh();

// write response JSON
var jsonWriter = new JsonWriterUtf8(response, true, prettyPrint: false);
var jsonWriter = new JsonWriter(response, true, prettyPrint: false);
jsonWriter.WriteObjectStart();
jsonWriter.WriteArrayStart("values");
for (int i = 0; i < 5; i++)
Expand Down Expand Up @@ -94,7 +94,7 @@ static void WriteResponseForPostJson(HttpRequest request, ReadOnlySequence<byte>
response.AppendEoh();

// write response JSON
var jsonWriter = new JsonWriterUtf8(response, true, prettyPrint: false);
var jsonWriter = new JsonWriter(response, true, prettyPrint: false);
jsonWriter.WriteObjectStart();
jsonWriter.WriteArrayStart("values");
for (int i = 0; i < requestedCount; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace System.Text.JsonLab
{
public struct JsonWriterUtf8
public struct JsonWriter
{
private static readonly byte[] s_newLineUtf8 = Encoding.UTF8.GetBytes(Environment.NewLine);
private static readonly char[] s_newLineUtf16 = Environment.NewLine.ToCharArray();
Expand All @@ -26,7 +26,7 @@ public struct JsonWriterUtf8
/// </summary>
/// <param name="bufferWriter">An instance of <see cref="ITextBufferWriter" /> used for writing bytes to an output channel.</param>
/// <param name="prettyPrint">Specifies whether to add whitespace to the output text for user readability.</param>
public JsonWriterUtf8(IBufferWriter<byte> bufferWriter, bool isUtf8, bool prettyPrint = false)
public JsonWriter(IBufferWriter<byte> bufferWriter, bool isUtf8, bool prettyPrint = false)
{
_bufferWriter = bufferWriter;
_prettyPrint = prettyPrint;
Expand Down
2 changes: 1 addition & 1 deletion tests/Benchmarks/System.IO.Pipelines/E2E.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void TechEmpowerJsonNoIO(int numberOfRequests, int concurrentConnections)
formatter.Append("\r\n\r\n");

// write body
var writer = new JsonWriterUtf8(formatter, true);
var writer = new JsonWriter(formatter, true);
writer.WriteObjectStart();
writer.WriteAttribute("message", "Hello, World!");
writer.WriteObjectEnd();
Expand Down
8 changes: 4 additions & 4 deletions tests/Benchmarks/System.Text.JsonLab/JsonWriterPerf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private TextWriter GetWriter()

private static void WriterSystemTextJsonBasicUtf8(bool formatted, ArrayFormatter output, int[] data)
{
var json = new JsonWriterUtf8(output, true, formatted);
var json = new JsonWriter(output, true, formatted);

json.WriteObjectStart();
json.WriteAttribute("age", 42);
Expand Down Expand Up @@ -131,7 +131,7 @@ private static void WriterSystemTextJsonBasicUtf8(bool formatted, ArrayFormatter

private static void WriterSystemTextJsonBasicUtf16(bool formatted, ArrayFormatter output, int[] data)
{
var json = new JsonWriterUtf8(output, false, formatted);
var json = new JsonWriter(output, false, formatted);

json.WriteObjectStart();
json.WriteAttribute("age", 42);
Expand Down Expand Up @@ -201,7 +201,7 @@ private static void WriterNewtonsoftBasic(bool formatted, TextWriter writer, int

private static void WriterSystemTextJsonHelloWorldUtf8(bool formatted, ArrayFormatter output)
{
var json = new JsonWriterUtf8(output, true, formatted);
var json = new JsonWriter(output, true, formatted);

json.WriteObjectStart();
json.WriteAttribute("message", "Hello, World!");
Expand All @@ -210,7 +210,7 @@ private static void WriterSystemTextJsonHelloWorldUtf8(bool formatted, ArrayForm

private static void WriterSystemTextJsonHelloWorldUtf16(bool formatted, ArrayFormatter output)
{
var json = new JsonWriterUtf8(output, false, formatted);
var json = new JsonWriter(output, false, formatted);

json.WriteObjectStart();
json.WriteAttribute("message", "Hello, World!");
Expand Down
18 changes: 9 additions & 9 deletions tests/System.Text.JsonLab.Tests/JsonWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public class JsonWriterTests
public void WriteJsonUtf8()
{
var formatter = new ArrayFormatter(1024, SymbolTable.InvariantUtf8);
var json = new JsonWriterUtf8(formatter, true, prettyPrint: false);
var json = new JsonWriter(formatter, true, prettyPrint: false);
Write(ref json);

var formatted = formatter.Formatted;
var str = Encoding.UTF8.GetString(formatted.Array, formatted.Offset, formatted.Count);
Assert.Equal(expected, str.Replace(" ", ""));

formatter.Clear();
json = new JsonWriterUtf8(formatter, true, prettyPrint: true);
json = new JsonWriter(formatter, true, prettyPrint: true);
Write(ref json);

formatted = formatter.Formatted;
Expand All @@ -37,15 +37,15 @@ public void WriteJsonUtf8()
public void WriteJsonUtf16()
{
var formatter = new ArrayFormatter(1024, SymbolTable.InvariantUtf16);
var json = new JsonWriterUtf8(formatter, false, prettyPrint: false);
var json = new JsonWriter(formatter, false, prettyPrint: false);
Write(ref json);

var formatted = formatter.Formatted;
var str = Encoding.Unicode.GetString(formatted.Array, formatted.Offset, formatted.Count);
Assert.Equal(expected, str.Replace(" ", ""));

formatter.Clear();
json = new JsonWriterUtf8(formatter, false, prettyPrint: true);
json = new JsonWriter(formatter, false, prettyPrint: true);
Write(ref json);

formatted = formatter.Formatted;
Expand All @@ -54,7 +54,7 @@ public void WriteJsonUtf16()
}

static string expected = "{\"age\":30,\"first\":\"John\",\"last\":\"Smith\",\"phoneNumbers\":[\"425-000-1212\",\"425-000-1213\",null],\"address\":{\"street\":\"1MicrosoftWay\",\"city\":\"Redmond\",\"zip\":98052},\"values\":[425121,-425122,425123]}";
static void Write(ref JsonWriterUtf8 json)
static void Write(ref JsonWriter json)
{
json.WriteObjectStart();
json.WriteAttribute("age", 30);
Expand Down Expand Up @@ -86,7 +86,7 @@ public void WriteHelloWorldJsonUtf16(bool prettyPrint)
string expectedStr = GetHelloWorldExpectedString(prettyPrint, isUtf8: false);

var output = new ArrayFormatter(1024, SymbolTable.InvariantUtf16);
var jsonUtf16 = new JsonWriterUtf8(output, false, prettyPrint);
var jsonUtf16 = new JsonWriter(output, false, prettyPrint);

jsonUtf16.WriteObjectStart();
jsonUtf16.WriteAttribute("message", "Hello, World!");
Expand All @@ -106,7 +106,7 @@ public void WriteHelloWorldJsonUtf8(bool prettyPrint)
string expectedStr = GetHelloWorldExpectedString(prettyPrint, isUtf8: true);

var output = new ArrayFormatter(1024, SymbolTable.InvariantUtf8);
var jsonUtf8 = new JsonWriterUtf8(output, true, prettyPrint);
var jsonUtf8 = new JsonWriter(output, true, prettyPrint);

jsonUtf8.WriteObjectStart();
jsonUtf8.WriteAttribute("message", "Hello, World!");
Expand All @@ -128,7 +128,7 @@ public void WriteBasicJsonUtf16(bool prettyPrint)
string expectedStr = GetExpectedString(prettyPrint, isUtf8: false, data);

var output = new ArrayFormatter(1024, SymbolTable.InvariantUtf16);
var jsonUtf16 = new JsonWriterUtf8(output, false, prettyPrint);
var jsonUtf16 = new JsonWriter(output, false, prettyPrint);

jsonUtf16.WriteObjectStart();
jsonUtf16.WriteAttribute("age", 42);
Expand Down Expand Up @@ -170,7 +170,7 @@ public void WriteBasicJsonUtf8(bool prettyPrint)
string expectedStr = GetExpectedString(prettyPrint, isUtf8: true, data);

var output = new ArrayFormatter(1024, SymbolTable.InvariantUtf8);
var jsonUtf8 = new JsonWriterUtf8(output, true, prettyPrint);
var jsonUtf8 = new JsonWriter(output, true, prettyPrint);

jsonUtf8.WriteObjectStart();
jsonUtf8.WriteAttribute("age", 42);
Expand Down

0 comments on commit f801662

Please sign in to comment.