From 6a3c9774f651b2d5ab0b92a8987732f0a6643b25 Mon Sep 17 00:00:00 2001 From: Dexter Ajoku Date: Mon, 9 Dec 2024 01:54:24 +0100 Subject: [PATCH] Refactor: Use `await using` for `packageVersionStream` to ensure proper disposal of async resources (#2521) --- src/dotnet-grpc/Commands/CommandBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotnet-grpc/Commands/CommandBase.cs b/src/dotnet-grpc/Commands/CommandBase.cs index d0a400cfd..ce56115da 100644 --- a/src/dotnet-grpc/Commands/CommandBase.cs +++ b/src/dotnet-grpc/Commands/CommandBase.cs @@ -127,7 +127,7 @@ public async Task EnsureNugetPackagesAsync(Services services) }*/ try { - using var packageVersionStream = await _httpClient.GetStreamAsync(PackageVersionUrl); + await using var packageVersionStream = await _httpClient.GetStreamAsync(PackageVersionUrl); using var packageVersionDocument = await JsonDocument.ParseAsync(packageVersionStream); var packageVersionsElement = packageVersionDocument.RootElement.GetProperty("Packages"); var packageVersionsDictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);