[msbuild] Dispose a few streams when done with them in the unzip/decompress logic. (#18410)

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1829715.
This commit is contained in:
Rolf Bjarne Kvinge 2023-06-08 16:51:10 +02:00 коммит произвёл GitHub
Родитель 3feddf30eb
Коммит 50c5ae57f2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -130,7 +130,7 @@ namespace Xamarin.MacDev {
static bool TryDecompressUsingUnzip (TaskLoggingHelper log, string zip, string resource, string decompressionDir)
{
var archive = ZipFile.OpenRead (zip);
using var archive = ZipFile.OpenRead (zip);
resource = resource.Replace ('\\', zipDirectorySeparator);
var entry = archive.GetEntry (resource);
if (entry is null) {
@ -165,7 +165,7 @@ namespace Xamarin.MacDev {
resource = resource.Replace ('\\', zipDirectorySeparator);
var resourceAsDir = resource + zipDirectorySeparator;
var archive = ZipFile.OpenRead (zip);
using var archive = ZipFile.OpenRead (zip);
foreach (var entry in archive.Entries) {
var entryPath = entry.FullName;
if (entryPath.Length == 0)

Просмотреть файл

@ -252,7 +252,7 @@ namespace Xamarin.MacDev.Tasks {
static bool TryGetInfoPlist (TaskLoggingHelper log, string resourcePath, string xcframework, [NotNullWhen (true)] out PDictionary? plist)
{
var manifestPath = Path.Combine (xcframework, "Info.plist");
var stream = CompressionHelper.TryGetPotentiallyCompressedFile (log, resourcePath, manifestPath);
using var stream = CompressionHelper.TryGetPotentiallyCompressedFile (log, resourcePath, manifestPath);
if (stream is null) {
plist = null;
return false;