Use await using in async methods

This commit is contained in:
Bogdan
2023-05-11 17:47:19 +03:00
parent d38f2614d3
commit 34fbb3e135
2 changed files with 6 additions and 15 deletions

View File

@@ -322,7 +322,7 @@ namespace NzbDrone.Common.Http
_logger.Debug("Downloading [{0}] to [{1}]", url, fileName);
var stopWatch = Stopwatch.StartNew();
using (var fileStream = new FileStream(fileNamePart, FileMode.Create, FileAccess.ReadWrite))
await using (var fileStream = new FileStream(fileNamePart, FileMode.Create, FileAccess.ReadWrite))
{
var request = new HttpRequest(url);
request.AllowAutoRedirect = true;

View File

@@ -179,21 +179,12 @@ namespace NzbDrone.Core.Localization
return;
}
using (var fs = File.OpenRead(resourcePath))
{
if (fs != null)
{
var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(fs);
await using var fs = File.OpenRead(resourcePath);
var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(fs);
foreach (var key in dict.Keys)
{
dictionary[key] = dict[key];
}
}
else
{
_logger.Error("Missing translation/culture resource: {0}", resourcePath);
}
foreach (var key in dict.Keys)
{
dictionary[key] = dict[key];
}
}