diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index ff5ea29d8..d5846dca9 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -11,12 +11,12 @@ namespace Microsoft.OpenApi.Hidi { static class Program { - static async Task Main(string[] args) + static Task Main(string[] args) { var rootCommand = CreateRootCommand(); // Parse the incoming args and invoke the handler - return await rootCommand.InvokeAsync(args).ConfigureAwait(false); + return rootCommand.InvokeAsync(args); } internal static RootCommand CreateRootCommand() diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 7388254c3..5053cbc7b 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -139,7 +139,7 @@ public async Task ReadAsync(YamlDocument input, CancellationToken ca }; } - private async Task LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken = default) + private Task LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken = default) { // Create workspace for all documents to live in. var openApiWorkSpace = new OpenApiWorkspace(); @@ -147,7 +147,7 @@ private async Task LoadExternalRefs(OpenApiDocument document, // Load this root document into the workspace var streamLoader = new DefaultStreamLoader(_settings.BaseUrl); var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings); - return await workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, null, cancellationToken); + return workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, null, cancellationToken); } private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 7e360bdfe..764d6903d 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -176,25 +176,25 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag } [Fact] - public async Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating() + public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating() { - await Assert.ThrowsAsync(async () => - await OpenApiService.ValidateOpenApiDocument("", _logger)); + return Assert.ThrowsAsync(() => + OpenApiService.ValidateOpenApiDocument("", _logger)); } [Fact] - public async Task ThrowIfURLIsNotResolvableWhenValidating() + public Task ThrowIfURLIsNotResolvableWhenValidating() { - await Assert.ThrowsAsync(async () => - await OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger)); + return Assert.ThrowsAsync(() => + OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger)); } [Fact] - public async Task ThrowIfFileDoesNotExistWhenValidating() + public Task ThrowIfFileDoesNotExistWhenValidating() { - await Assert.ThrowsAsync(async () => - await OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger)); + return Assert.ThrowsAsync(() => + OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger)); } [Fact] @@ -284,7 +284,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF } [Fact] - public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() + public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() { HidiOptions options = new HidiOptions { @@ -293,9 +293,8 @@ public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() InlineLocal = false, InlineExternal = false, }; - await Assert.ThrowsAsync(async () => - await OpenApiService.TransformOpenApiDocument(options, _logger)); - + return Assert.ThrowsAsync(() => + OpenApiService.TransformOpenApiDocument(options, _logger)); } [Fact]