Skip to content

Commit ab79ea8

Browse files
authored
Use AsTask() (#349)
1 parent 21f6295 commit ab79ea8

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/GraphQLParser/Visitors/SDLPrinterExtensions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ public static string Print(this SDLPrinter printer, ASTNode node)
2222
/// Prints the specified AST into the specified <see cref="StringBuilder"/> as a SDL document.
2323
/// </summary>
2424
public static void Print(this SDLPrinter printer, ASTNode node, StringBuilder stringBuilder)
25-
#pragma warning disable CA2012 // Use ValueTasks correctly
26-
=> printer.PrintAsync(node, new StringWriter(stringBuilder), default).GetAwaiter().GetResult();
27-
#pragma warning restore CA2012 // Use ValueTasks correctly
25+
=> printer.PrintAsync(node, new StringWriter(stringBuilder), default).AsTask().GetAwaiter().GetResult();
2826

2927
/// <summary>
3028
/// Prints the specified AST into the specified <see cref="MemoryStream"/> as a SDL document.
@@ -33,9 +31,7 @@ public static void Print(this SDLPrinter printer, ASTNode node, StringBuilder st
3331
public static void Print(this SDLPrinter printer, ASTNode node, MemoryStream memoryStream, Encoding? encoding = null)
3432
{
3533
using var streamWriter = new StreamWriter(memoryStream, encoding, -1 /* default */, true);
36-
#pragma warning disable CA2012 // Use ValueTasks correctly
37-
printer.PrintAsync(node, streamWriter, default).GetAwaiter().GetResult();
38-
#pragma warning restore CA2012 // Use ValueTasks correctly
34+
printer.PrintAsync(node, streamWriter, default).AsTask().GetAwaiter().GetResult();
3935
// flush encoder state to stream
4036
streamWriter.Flush();
4137
}

src/GraphQLParser/Visitors/SDLSorter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ private SDLSorter()
1818
/// Nodes that have the same sort order will be retain their relative position.
1919
/// </summary>
2020
public static void Sort(ASTNode node, SDLSorterOptions? options = null)
21-
#pragma warning disable CA2012 // Use ValueTasks correctly
22-
=> _sorter.VisitAsync(node, options ?? SDLSorterOptions.Default).GetAwaiter().GetResult();
23-
#pragma warning restore CA2012 // Use ValueTasks correctly
21+
=> _sorter.VisitAsync(node, options ?? SDLSorterOptions.Default).AsTask().GetAwaiter().GetResult();
2422

2523
/// <inheritdoc/>
2624
protected override ValueTask VisitAsync<T>(List<T>? nodes, SDLSorterOptions context)

0 commit comments

Comments
 (0)