From e1a05a1b9bc93dacf0b668fab88e54b40902776c Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 12 Dec 2023 13:07:54 -0800 Subject: [PATCH] Update the FileInfo Extensions --- .../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(); } }