From 97f599b146734a46a37e4b1edd3a328829487645 Mon Sep 17 00:00:00 2001 From: Scott Bilas Date: Wed, 22 Nov 2023 11:31:41 +0100 Subject: [PATCH] dotnet 8 test fixes --- src/Core/EnumerableExtensions.cs | 2 ++ src/Core/FileStreamNativeExtensions.t.cs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Core/EnumerableExtensions.cs b/src/Core/EnumerableExtensions.cs index a35d608..289951e 100644 --- a/src/Core/EnumerableExtensions.cs +++ b/src/Core/EnumerableExtensions.cs @@ -131,8 +131,10 @@ public static IEnumerable Flatten(this IEnumerable @this) => // copy to collection +# if !NET8_0_OR_GREATER public static Dictionary ToDictionary(this IEnumerable<(TKey key, TValue value)> @this) where TKey: notnull => @this.ToDictionary(item => item.key, item => item.value); +# endif public static Queue ToQueue(this IEnumerable @this) => new(@this); diff --git a/src/Core/FileStreamNativeExtensions.t.cs b/src/Core/FileStreamNativeExtensions.t.cs index 6ddc11f..e61924a 100644 --- a/src/Core/FileStreamNativeExtensions.t.cs +++ b/src/Core/FileStreamNativeExtensions.t.cs @@ -1,3 +1,5 @@ +using System.ComponentModel; + #pragma warning disable CA1001 class FileStreamNativeExtensionsTests : TestFileSystemFixture #pragma warning restore CA1001 @@ -58,6 +60,13 @@ public void WasFileDeleted_WithDeletedAndRecreatedFile_ReturnsTrue() public void WasFileDeleted_WithClosedFile_Throws() { _stream.Close(); + + #if NET8_0_OR_GREATER + Should + .Throw(() => _stream.WasFileDeleted()) + .Message.ShouldContain("GetFileInformationByHandleEx() failed"); + #else Should.Throw(() => _stream.WasFileDeleted()); + #endif } }