Commit 97b30e5c authored by Jesse McGrew's avatar Jesse McGrew
Browse files

Clean up AsyncFixer warnings.

parent 49e8bc0f9629
......@@ -68,9 +68,9 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="language">The language the source classes are in</param>
/// <param name="analyzer">The analyzer to be run on the sources</param>
/// <returns>An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location</returns>
private static async Task<Diagnostic[]> GetSortedDiagnosticsAsync(string[] sources, string language, DiagnosticAnalyzer analyzer)
private static Task<Diagnostic[]> GetSortedDiagnosticsAsync(string[] sources, string language, DiagnosticAnalyzer analyzer)
{
return await GetSortedDiagnosticsFromDocumentsAsync(analyzer, GetDocuments(sources, language)).ConfigureAwait(false);
return GetSortedDiagnosticsFromDocumentsAsync(analyzer, GetDocuments(sources, language));
}
/// <summary>
......
......@@ -38,16 +38,15 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
protected async Task VerifyCSharpFixAsync(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false)
protected Task VerifyCSharpFixAsync(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false)
{
await VerifyFixAsync(LanguageNames.CSharp,
return VerifyFixAsync(LanguageNames.CSharp,
GetCSharpDiagnosticAnalyzer(),
GetCSharpCodeFixProvider(),
oldSource,
newSource,
codeFixIndex,
allowNewCompilerDiagnostics)
.ConfigureAwait(false);
allowNewCompilerDiagnostics);
}
/// <summary>
......@@ -57,16 +56,15 @@ namespace ZilfAnalyzers.Test.Helpers
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
protected async Task VerifyBasicFixAsync(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false)
protected Task VerifyBasicFixAsync(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false)
{
await VerifyFixAsync(LanguageNames.VisualBasic,
return VerifyFixAsync(LanguageNames.VisualBasic,
GetBasicDiagnosticAnalyzer(),
GetBasicCodeFixProvider(),
oldSource,
newSource,
codeFixIndex,
allowNewCompilerDiagnostics)
.ConfigureAwait(false);
allowNewCompilerDiagnostics);
}
/// <summary>
......
......@@ -35,9 +35,9 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary>
/// <param name="source">A class in the form of a string to run the analyzer on</param>
/// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source</param>
protected async Task VerifyCSharpDiagnosticAsync(string source, params DiagnosticResult[] expected)
protected Task VerifyCSharpDiagnosticAsync(string source, params DiagnosticResult[] expected)
{
await VerifyDiagnosticsAsync(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
return VerifyDiagnosticsAsync(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
}
/// <summary>
......@@ -46,9 +46,9 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary>
/// <param name="source">A class in the form of a string to run the analyzer on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the source</param>
protected async Task VerifyBasicDiagnosticAsync(string source, params DiagnosticResult[] expected)
protected Task VerifyBasicDiagnosticAsync(string source, params DiagnosticResult[] expected)
{
await VerifyDiagnosticsAsync(new[] { source }, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
return VerifyDiagnosticsAsync(new[] { source }, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
}
/// <summary>
......@@ -57,9 +57,9 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
protected async Task VerifyCSharpDiagnosticAsync(string[] sources, params DiagnosticResult[] expected)
protected Task VerifyCSharpDiagnosticAsync(string[] sources, params DiagnosticResult[] expected)
{
await VerifyDiagnosticsAsync(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
return VerifyDiagnosticsAsync(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
}
/// <summary>
......@@ -68,9 +68,9 @@ namespace ZilfAnalyzers.Test.Helpers
/// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
protected async Task VerifyBasicDiagnosticAsync(string[] sources, params DiagnosticResult[] expected)
protected Task VerifyBasicDiagnosticAsync(string[] sources, params DiagnosticResult[] expected)
{
await VerifyDiagnosticsAsync(sources, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
return VerifyDiagnosticsAsync(sources, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
}
/// <summary>
......
......@@ -76,10 +76,10 @@ namespace ZilfAnalyzers
IEnumerable<ExpressionSyntax> NewMessageArgs,
Func<int, FieldDeclarationSyntax> GetConstantDeclarationSyntax);
static async Task<Solution> ConvertMessagesToConstantsAsync(Document document, LiteralCreation[] creations, string severity, CancellationToken cancellationToken)
static Task<Solution> ConvertMessagesToConstantsAsync(Document document, LiteralCreation[] creations, string severity, CancellationToken cancellationToken)
{
var invocations = PlanInvocations(creations, severity);
return await ApplyInvocationsAsync(
return ApplyInvocationsAsync(
document.Project.Solution,
Enumerable.Repeat(new KeyValuePair<DocumentId, Invocation[]>(document.Id, invocations), 1),
cancellationToken);
......
......@@ -158,6 +158,7 @@ namespace Zilf.Common
/// <returns>A task representing the asynchronous write operation.</returns>
/// <exception cref="NotSupportedException">The file system does not support writing.</exception>
/// <exception cref="IOException">The file could not be written.</exception>
[SuppressMessage("AsyncUsage", "AsyncFixer01:Unnecessary async/await usage", Justification = "await using")]
async Task SetTextAsync(string path, string content)
{
var output = OpenForWriting(path);
......
......@@ -24,19 +24,19 @@ namespace Zilf.Playground
jsu.InvokeUnmarshalled<string, string, byte[], bool>("ZilfJsInterop.BlazorDownloadFileFast", filename, contentType, bytes);
}
public async Task ScrollToBottomAsync(ElementReference element)
public ValueTask ScrollToBottomAsync(ElementReference element)
{
await js.InvokeVoidAsync("ZilfJsInterop.scrollToBottom", element);
return js.InvokeVoidAsync("ZilfJsInterop.scrollToBottom", element);
}
public async Task<string> PromptAsync(string prompt, string value)
public ValueTask<string> PromptAsync(string prompt, string value)
{
return await js.InvokeAsync<string>("prompt", prompt, value);
return js.InvokeAsync<string>("prompt", prompt, value);
}
public async Task AddEventListenerAsync(ElementReference element, string eventName, string jsHandler, params object[] extraHandlerArgs)
public ValueTask AddEventListenerAsync(ElementReference element, string eventName, string jsHandler, params object[] extraHandlerArgs)
{
await js.InvokeVoidAsync("ZilfJsInterop.addEventListener", element, eventName, jsHandler, extraHandlerArgs);
return js.InvokeVoidAsync("ZilfJsInterop.addEventListener", element, eventName, jsHandler, extraHandlerArgs);
}
}
}
......@@ -18,7 +18,7 @@ namespace Zilf.Playground
{
public class Program
{
public static async Task Main(string[] args)
public static Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Logging.SetMinimumLevel(LogLevel.Debug);
......@@ -35,7 +35,7 @@ namespace Zilf.Playground
builder.Services.AddWorkerFactory();
await builder.Build().RunAsync();
return builder.Build().RunAsync();
}
}
}
......@@ -88,7 +88,7 @@ namespace Zilf.Playground.Services.Templates
return project;
}
private async Task CacheFileAsync(string path)
private Task CacheFileAsync(string path)
{
if (!content.TryGetValue(path, out var httpTask))
{
......@@ -96,7 +96,7 @@ namespace Zilf.Playground.Services.Templates
content.Add(path, httpTask);
}
await httpTask.ConfigureAwait(false);
return httpTask;
}
public void Dispose()
......
......@@ -244,23 +244,23 @@ namespace Zilf.Tests.Integration
{
protected abstract string Expression();
public async Task GivesNumberAsync(string expectedValue)
public Task GivesNumberAsync(string expectedValue)
{
var testCode = $"{GlobalCode()}\r\n" +
$"<ROUTINE GO () <PRINTN {Expression()}>>";
await ZlrHelper.RunAndAssertAsync(testCode, input.ToString(), expectedValue, warningChecks);
return ZlrHelper.RunAndAssertAsync(testCode, input.ToString(), expectedValue, warningChecks);
}
public async Task OutputsAsync(string expectedValue)
public Task OutputsAsync(string expectedValue)
{
var testCode = $"{GlobalCode()}\r\n" +
$"<ROUTINE GO () {Expression()}>";
await ZlrHelper.RunAndAssertAsync(testCode, input.ToString(), expectedValue, warningChecks, wantCompileOutput);
return ZlrHelper.RunAndAssertAsync(testCode, input.ToString(), expectedValue, warningChecks, wantCompileOutput);
}
public async Task ImpliesAsync(params string[] conditions)
public Task ImpliesAsync(params string[] conditions)
{
var sb = new StringBuilder();
foreach (var c in conditions)
......@@ -276,7 +276,7 @@ namespace Zilf.Tests.Integration
$"<ROUTINE TEST-IMPLIES (\"AUX\" FAILS) {sb} .FAILS>\r\n" +
"<ROUTINE GO () <OR <TEST-IMPLIES> <PRINTI \"PASS\">>>";
await ZlrHelper.RunAndAssertAsync(testCode, input.ToString(), "PASS", warningChecks);
return ZlrHelper.RunAndAssertAsync(testCode, input.ToString(), "PASS", warningChecks);
}
public async Task DoesNotCompileAsync(Predicate<ZlrHelperRunResult>? resultFilter = null,
......@@ -300,13 +300,13 @@ namespace Zilf.Tests.Integration
}
}
public async Task DoesNotCompileAsync(string diagnosticCode, Predicate<Diagnostic>? diagFilter = null)
public Task DoesNotCompileAsync(string diagnosticCode, Predicate<Diagnostic>? diagFilter = null)
{
await DoesNotCompileAsync(res =>
{
var diag = res.Diagnostics.FirstOrDefault(d => d.Code == diagnosticCode);
return diag != null && (diagFilter == null || diagFilter(diag));
},
return DoesNotCompileAsync(res =>
{
var diag = res.Diagnostics.FirstOrDefault(d => d.Code == diagnosticCode);
return diag != null && (diagFilter == null || diagFilter(diag));
},
$"Expected diagnostic {diagnosticCode} was not produced");
}
......@@ -326,9 +326,9 @@ namespace Zilf.Tests.Integration
CheckWarnings(result);
}
public async Task<CodeMatchingResult> GeneratesCodeMatchingAsync(string pattern)
public Task<CodeMatchingResult> GeneratesCodeMatchingAsync(string pattern)
{
return await GeneratesCodeMatchingAsync(output => CheckOutputMatches(output, pattern));
return GeneratesCodeMatchingAsync(output => CheckOutputMatches(output, pattern));
}
public static void CheckOutputMatches(string output, string pattern)
......@@ -338,9 +338,9 @@ namespace Zilf.Tests.Integration
"Output did not match. Expected pattern: " + pattern);
}
public async Task<CodeMatchingResult> GeneratesCodeNotMatchingAsync(string pattern)
public Task<CodeMatchingResult> GeneratesCodeNotMatchingAsync(string pattern)
{
return await GeneratesCodeMatchingAsync(output => CheckOutputDoesNotMatch(output, pattern));
return GeneratesCodeMatchingAsync(output => CheckOutputDoesNotMatch(output, pattern));
}
public static void CheckOutputDoesNotMatch(string output, string pattern)
......@@ -473,9 +473,9 @@ namespace Zilf.Tests.Integration
this.code = code;
}
public async Task OutputsAsync(string expectedValue)
public Task OutputsAsync(string expectedValue)
{
await ZlrHelper.RunAndAssertAsync(code, null, expectedValue);
return ZlrHelper.RunAndAssertAsync(code, null, expectedValue);
}
}
}
......@@ -106,7 +106,7 @@ namespace Zilf.Tests.Integration
var actualOutput = await helper.ExecuteAsync();
var massagedActual = MassageText(actualOutput);
var massagedExpected = MassageText(File.ReadAllText(outputFile));
var massagedExpected = MassageText(await File.ReadAllTextAsync(outputFile));
if (massagedActual != massagedExpected)
{
var expectedLines = SplitLines(massagedExpected);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment