From fb921133a9227799fbc6d6c8e749c5d4346ebc5b Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 27 Apr 2023 14:58:12 -0400 Subject: [PATCH] [wasm] GenerateWasmBootJson - close file handles Close files opened with `File.OpenRead` by utilizing the `using` pattern. --- .../GenerateWasmBootJson.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs index 7cb776c236229..31ed093e9a202 100644 --- a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs +++ b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs @@ -290,7 +290,8 @@ public void WriteBootJson(Stream output, string entryAssemblyName) foreach (var configExtension in Extensions) { var key = configExtension.GetMetadata("key"); - var config = (Dictionary)configSerializer.ReadObject(File.OpenRead(configExtension.ItemSpec)); + using var fs = File.OpenRead(configExtension.ItemSpec); + var config = (Dictionary)configSerializer.ReadObject(fs); result.extensions[key] = config; } }