Skip to content

Commit 540f02b

Browse files
authored
Merge pull request #1367 from SimonCropp/elide-some-asyncs
elide some asyncs
2 parents 60b72fc + ed51df5 commit 540f02b

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

src/Microsoft.OpenApi.Hidi/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ namespace Microsoft.OpenApi.Hidi
1111
{
1212
static class Program
1313
{
14-
static async Task<int> Main(string[] args)
14+
static Task<int> Main(string[] args)
1515
{
1616
var rootCommand = CreateRootCommand();
1717

1818
// Parse the incoming args and invoke the handler
19-
return await rootCommand.InvokeAsync(args).ConfigureAwait(false);
19+
return rootCommand.InvokeAsync(args);
2020
}
2121

2222
internal static RootCommand CreateRootCommand()

src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ public async Task<ReadResult> ReadAsync(YamlDocument input, CancellationToken ca
139139
};
140140
}
141141

142-
private async Task<OpenApiDiagnostic> LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken = default)
142+
private Task<OpenApiDiagnostic> LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken = default)
143143
{
144144
// Create workspace for all documents to live in.
145145
var openApiWorkSpace = new OpenApiWorkspace();
146146

147147
// Load this root document into the workspace
148148
var streamLoader = new DefaultStreamLoader(_settings.BaseUrl);
149149
var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings);
150-
return await workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, null, cancellationToken);
150+
return workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, null, cancellationToken);
151151
}
152152

153153
private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document)

test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,25 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag
174174
}
175175

176176
[Fact]
177-
public async Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating()
177+
public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating()
178178
{
179-
await Assert.ThrowsAsync<ArgumentNullException>(async () =>
180-
await OpenApiService.ValidateOpenApiDocument("", _logger));
179+
return Assert.ThrowsAsync<ArgumentNullException>(() =>
180+
OpenApiService.ValidateOpenApiDocument("", _logger));
181181
}
182182

183183

184184
[Fact]
185-
public async Task ThrowIfURLIsNotResolvableWhenValidating()
185+
public Task ThrowIfURLIsNotResolvableWhenValidating()
186186
{
187-
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
188-
await OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger));
187+
return Assert.ThrowsAsync<InvalidOperationException>(() =>
188+
OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger));
189189
}
190190

191191
[Fact]
192-
public async Task ThrowIfFileDoesNotExistWhenValidating()
192+
public Task ThrowIfFileDoesNotExistWhenValidating()
193193
{
194-
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
195-
await OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger));
194+
return Assert.ThrowsAsync<InvalidOperationException>(() =>
195+
OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger));
196196
}
197197

198198
[Fact]
@@ -282,7 +282,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
282282
}
283283

284284
[Fact]
285-
public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
285+
public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
286286
{
287287
HidiOptions options = new HidiOptions
288288
{
@@ -291,9 +291,8 @@ public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
291291
InlineLocal = false,
292292
InlineExternal = false,
293293
};
294-
await Assert.ThrowsAsync<ArgumentException>(async () =>
295-
await OpenApiService.TransformOpenApiDocument(options, _logger));
296-
294+
return Assert.ThrowsAsync<ArgumentException>(() =>
295+
OpenApiService.TransformOpenApiDocument(options, _logger));
297296
}
298297

299298
[Fact]

0 commit comments

Comments
 (0)