From 1f3c1dc544d615accc724a5bbe42072193db5451 Mon Sep 17 00:00:00 2001
From: Ivan Maximov <sungam3r@yandex.ru>
Date: Mon, 11 Dec 2023 11:44:48 +0300
Subject: [PATCH] Cosmetic changes

---
 README.md                                     | 11 +++---
 .../Visitors/SDLPrinterSkipDirectivesTests.cs |  2 +-
 .../Visitors/SDLPrinterTests.cs               | 34 +++++++++----------
 .../SDLPrinterVerticalIndentationTests.cs     |  2 +-
 .../Visitors/StructurePrinterTests.cs         |  6 ++--
 5 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/README.md b/README.md
index 3e72b4b8..2f8b7e08 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ Preview versions of this package are available on [GitHub Packages](https://gith
 Generates token based on input text. Lexer takes advantage of `ReadOnlyMemory<char>` and in most cases
 does not allocate memory on the managed heap at all.
 
-### Usage
+Usage:
 
 ```csharp
 var token = Lexer.Lex("\"str\"");
@@ -36,7 +36,7 @@ Lex method always returns the first token it finds. In this case case the result
 Parses provided GraphQL expression into AST (abstract syntax tree). Parser also takes advantage of
 `ReadOnlyMemory<char>` but still allocates memory for AST.
 
-### Usage
+Usage:
 
 ```csharp
 var ast1 = Parser.Parse(@"
@@ -84,7 +84,8 @@ new SDLPrinter().Print(document, sb);
 
 // print to a string with some options
 var sdlPrinter = new SDLPrinter(
-    new SDLPrinterOptions {
+    new SDLPrinterOptions
+    {
         PrintComments = true,
         EachDirectiveLocationOnNewLine = true,
         EachUnionMemberOnNewLine = true,
@@ -111,8 +112,8 @@ query {
 ### SDLSorter
 
 An AST document can be sorted with the `SDLSorter` using a predefined
-sort order.  You can specify the string comparison; by default it uses
-a culture-invariant case-insensitive comparison.  Any futher customization
+sort order. You can specify the string comparison; by default it uses
+a culture-invariant case-insensitive comparison. Any futher customization
 is possible by deriving from `SDLSorterOptions` and overriding the `Compare`
 methods.
 
diff --git a/src/GraphQLParser.Tests/Visitors/SDLPrinterSkipDirectivesTests.cs b/src/GraphQLParser.Tests/Visitors/SDLPrinterSkipDirectivesTests.cs
index 63958bcd..5cf016af 100644
--- a/src/GraphQLParser.Tests/Visitors/SDLPrinterSkipDirectivesTests.cs
+++ b/src/GraphQLParser.Tests/Visitors/SDLPrinterSkipDirectivesTests.cs
@@ -51,7 +51,7 @@ public async Task Printer_Should_Print_Pretty_If_Directives_Skipped(
 string expected)
     {
         var printer = new MyPrinter();
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var document = text.Parse();
 
         await printer.PrintAsync(document, writer);
diff --git a/src/GraphQLParser.Tests/Visitors/SDLPrinterTests.cs b/src/GraphQLParser.Tests/Visitors/SDLPrinterTests.cs
index 27a445f0..f3314a1a 100644
--- a/src/GraphQLParser.Tests/Visitors/SDLPrinterTests.cs
+++ b/src/GraphQLParser.Tests/Visitors/SDLPrinterTests.cs
@@ -10,7 +10,7 @@ public async Task Print_Matches_PrintAsync_String()
     {
         var query = "KitchenSink".ReadGraphQLFile().Parse();
         var writer = new SDLPrinter();
-        var sw = new StringWriter();
+        using var sw = new StringWriter();
         await writer.PrintAsync(query, sw);
         sw.Flush();
         var txt = sw.ToString();
@@ -580,7 +580,7 @@ public async Task SDLPrinter_Should_Print_Document(
             EachDirectiveLocationOnNewLine = eachDirectiveLocationOnNewLine,
             EachUnionMemberOnNewLine = eachUnionMemberOnNewLine
         });
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var document = text.Parse();
 
         await printer.PrintAsync(document, writer);
@@ -636,7 +636,7 @@ public async Task SDLPrinter_Should_Print_BlockStrings(int number, string input,
             ? "\"\"\"" + expected + "\"\"\""
             : "\"" + expected + "\"";
 
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
 
         var document = (input + " scalar a").Parse();
 
@@ -667,7 +667,7 @@ public async Task SDLPrinter_Should_Print_EscapedStrings(string stringValue)
         string expected = @$"{{
   a(p: {stringValue})
 }}";
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
 
         var document = query.Parse();
 
@@ -683,16 +683,16 @@ public async Task SDLPrinter_Should_Print_EscapedStrings(string stringValue)
     public async Task SelectionSet_Without_Parent_Should_Be_Printed_On_New_Line()
     {
         var selectionSet = new GraphQLSelectionSetWithComment { Selections = new List<ASTNode>() };
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var printer = new SDLPrinter(new SDLPrinterOptions { PrintComments = true });
         await printer.PrintAsync(selectionSet, writer);
         writer.ToString().ShouldBe(@"{
 }
 ");
         selectionSet.Comments = new List<GraphQLComment> { new GraphQLComment("comment") };
-        writer = new StringWriter();
-        await printer.PrintAsync(selectionSet, writer);
-        writer.ToString().ShouldBe(@"#comment
+        using var writer2 = new StringWriter();
+        await printer.PrintAsync(selectionSet, writer2);
+        writer2.ToString().ShouldBe(@"#comment
 {
 }
 ");
@@ -705,15 +705,15 @@ public async Task SelectionSet_Under_Operation_With_Null_Name_Should_Be_Printed_
         {
             SelectionSet = new GraphQLSelectionSetWithComment { Selections = new List<ASTNode>() }
         };
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var printer = new SDLPrinter(new SDLPrinterOptions { PrintComments = true });
         await printer.PrintAsync(def, writer);
         writer.ToString().ShouldBe(@"{
 }");
         def.SelectionSet.Comments = new List<GraphQLComment> { new GraphQLComment("comment") };
-        writer = new StringWriter();
-        await printer.PrintAsync(def, writer);
-        writer.ToString().ShouldBe(@"#comment
+        using var writer2 = new StringWriter();
+        await printer.PrintAsync(def, writer2);
+        writer2.ToString().ShouldBe(@"#comment
 {
 }");
     }
@@ -734,7 +734,7 @@ public async Task SelectionSet_Under_Operation_With_Null_Name_Should_Be_Printed_
     public async Task Description_Without_Parent_Should_Be_Printed(string text, string expected)
     {
         var description = new GraphQLDescription(text);
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var printer = new SDLPrinter();
         await printer.PrintAsync(description, writer);
         writer.ToString().ShouldBe(expected);
@@ -761,7 +761,7 @@ Line 4
     public async Task Description_With_Escaped_Unicode_Should_Be_Printed(string text, string expected)
     {
         var description = new GraphQLDescription(text);
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var printer = new SDLPrinter();
         await printer.PrintAsync(description, writer);
         writer.ToString().ShouldBe(expected);
@@ -777,7 +777,7 @@ public async Task InputValueDefinition_Without_Parent_Should_Be_Printed()
             DefaultValue = new GraphQLStringValue("abc")
         };
 
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var printer = new SDLPrinter();
         await printer.PrintAsync(def, writer);
         writer.ToString().ShouldBe("field: String = \"abc\"");
@@ -787,7 +787,7 @@ public async Task InputValueDefinition_Without_Parent_Should_Be_Printed()
     public async Task Directive_Without_Parent_Should_Be_Printed()
     {
         var directive = new GraphQLDirective { Name = new GraphQLName("upper") };
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var printer = new SDLPrinter();
         await printer.PrintAsync(directive, writer);
         writer.ToString().ShouldBe("@upper");
@@ -818,7 +818,7 @@ public void UTF8_MemoryStream_Runs_Synchronously()
     [InlineData("directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT")]
     public async Task SDLPrinter_Should_Throw_On_Unknown_Values(string text)
     {
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var document = text.Parse();
 
         await new DoBadThingsVisitor().VisitAsync(document, new Context());
diff --git a/src/GraphQLParser.Tests/Visitors/SDLPrinterVerticalIndentationTests.cs b/src/GraphQLParser.Tests/Visitors/SDLPrinterVerticalIndentationTests.cs
index 9c24adad..43a3db60 100644
--- a/src/GraphQLParser.Tests/Visitors/SDLPrinterVerticalIndentationTests.cs
+++ b/src/GraphQLParser.Tests/Visitors/SDLPrinterVerticalIndentationTests.cs
@@ -183,7 +183,7 @@ public async Task Printer_Should_Print_Pretty_If_Definitions_Skipped(
 string expected)
     {
         var printer = new MyPrinter();
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var document = text.Parse();
 
         await printer.PrintAsync(document, writer);
diff --git a/src/GraphQLParser.Tests/Visitors/StructurePrinterTests.cs b/src/GraphQLParser.Tests/Visitors/StructurePrinterTests.cs
index fd1eabcd..5ecb3fc2 100644
--- a/src/GraphQLParser.Tests/Visitors/StructurePrinterTests.cs
+++ b/src/GraphQLParser.Tests/Visitors/StructurePrinterTests.cs
@@ -283,7 +283,7 @@ Name [dir]
 ")]
     public async Task StructurePrinter_Should_Print_Tree(string text, string expected)
     {
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var document = text.Parse();
         await _structPrinter1.PrintAsync(document, writer);
         var actual = writer.ToString();
@@ -302,7 +302,7 @@ public async Task StructurePrinter_Should_Print_Tree(string text, string expecte
 ")]
     public async Task StructurePrinter_Should_Print_Tree_Without_Names(string text, string expected)
     {
-        var writer = new StringWriter();
+        using var writer = new StringWriter();
         var document = text.Parse();
         await _structPrinter2.PrintAsync(document, writer);
         var actual = writer.ToString();
@@ -547,7 +547,7 @@ public async Task StructurePrinter_Should_Print_Tree_With_Locations(string text,
             if (option == IgnoreOptions.Comments && !ignoreComments)
                 continue;
 
-            var writer = new StringWriter();
+            using var writer = new StringWriter();
 
             var document = text.Parse(new ParserOptions { Ignore = option });
             await _structPrinter3.PrintAsync(document, writer);