From 028bd8591eb44bde0d8dfc596a503e44fdafe0e5 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 12 Dec 2023 13:15:01 -0800 Subject: [PATCH] Update the FileInfo Extensions (#14888) --- .../Utilities/FileInfoExtensions.cs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/OrchardCore.Tests/Utilities/FileInfoExtensions.cs b/test/OrchardCore.Tests/Utilities/FileInfoExtensions.cs index 5eab13e5f95..ec64d166a35 100644 --- a/test/OrchardCore.Tests/Utilities/FileInfoExtensions.cs +++ b/test/OrchardCore.Tests/Utilities/FileInfoExtensions.cs @@ -1,17 +1,22 @@ -namespace OrchardCore.Tests.Utilities +namespace OrchardCore.Tests.Utilities; + +public static class FileInfoExtensions { - public static class FileInfoExtensions + public static string ReadToEnd(this IFileInfo fileInfo) { - public static string ReadToEnd(this IFileInfo fileInfo) - => ReadToEndAsync(fileInfo).GetAwaiter().GetResult(); + using var stream = fileInfo.CreateReadStream(); + + using var streamReader = new StreamReader(stream); - public static async Task ReadToEndAsync(this IFileInfo fileInfo) - { - await using var stream = fileInfo.CreateReadStream(); + return streamReader.ReadToEnd(); + } + + public static async Task ReadToEndAsync(this IFileInfo fileInfo) + { + await using var stream = fileInfo.CreateReadStream(); - using var streamReader = new StreamReader(stream); + using var streamReader = new StreamReader(stream); - return await streamReader.ReadToEndAsync(); - } + return await streamReader.ReadToEndAsync(); } }