diff --git a/api_list.include.md b/api_list.include.md index 303c2444..bd5127d0 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -1680,7 +1680,7 @@ * `Task ExtractToFileAsync(string, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfileextensions.extracttofileasync?view=net-11.0#system-io-compression-zipfileextensions-extracttofileasync(system-io-compression-ziparchiveentry-system-string-system-threading-cancellationtoken)) * `Stream Open(FileAccess)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.open?view=net-11.0) * `Task OpenAsync(CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.openasync?view=net-11.0#system-io-compression-ziparchiveentry-openasync(system-threading-cancellationtoken)) - * `ValueTask OpenAsync(FileAccess, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.openasync?view=net-11.0#system-io-compression-ziparchiveentry-openasync(system-io-fileaccess-system-threading-cancellationtoken)) + * `Task OpenAsync(FileAccess, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.openasync?view=net-11.0#system-io-compression-ziparchiveentry-openasync(system-io-fileaccess-system-threading-cancellationtoken)) * `int ExternalAttributes` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.externalattributes?view=net-11.0) diff --git a/readme.md b/readme.md index 256f15cb..5b337e5b 100644 --- a/readme.md +++ b/readme.md @@ -2393,7 +2393,7 @@ The class `Polyfill` includes the following extension methods: * `Task ExtractToFileAsync(string, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfileextensions.extracttofileasync?view=net-11.0#system-io-compression-zipfileextensions-extracttofileasync(system-io-compression-ziparchiveentry-system-string-system-threading-cancellationtoken)) * `Stream Open(FileAccess)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.open?view=net-11.0) * `Task OpenAsync(CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.openasync?view=net-11.0#system-io-compression-ziparchiveentry-openasync(system-threading-cancellationtoken)) - * `ValueTask OpenAsync(FileAccess, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.openasync?view=net-11.0#system-io-compression-ziparchiveentry-openasync(system-io-fileaccess-system-threading-cancellationtoken)) + * `Task OpenAsync(FileAccess, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.openasync?view=net-11.0#system-io-compression-ziparchiveentry-openasync(system-io-fileaccess-system-threading-cancellationtoken)) * `int ExternalAttributes` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.externalattributes?view=net-11.0) diff --git a/src/Consume/Consume.cs b/src/Consume/Consume.cs index c64f3da5..cdcb0d4a 100644 --- a/src/Consume/Consume.cs +++ b/src/Consume/Consume.cs @@ -2298,9 +2298,7 @@ void XCData_Methods(XCData cdata) => void ZipArchiveEntry_Methods(ZipArchive zip, ZipArchiveEntry entry) { entry.Open(FileAccess.Read); -#if FeatureValueTask entry.OpenAsync(FileAccess.Read); -#endif entry.OpenAsync(); zip.CreateEntryFromFile("file.txt", "entry.txt"); zip.CreateEntryFromFile("file.txt", "entry.txt", CompressionLevel.Optimal); diff --git a/src/Polyfill/Polyfill_Compression.cs b/src/Polyfill/Polyfill_Compression.cs index 4c2cedbd..7d6c8652 100644 --- a/src/Polyfill/Polyfill_Compression.cs +++ b/src/Polyfill/Polyfill_Compression.cs @@ -92,18 +92,16 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.openasync?view=net-11.0#system-io-compression-ziparchiveentry-openasync(system-io-fileaccess-system-threading-cancellationtoken) - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } #endif -#endif #if !NETSTANDARD2_1_OR_GREATER && !NETCOREAPP2_0_OR_GREATER diff --git a/src/Split/net10.0/Polyfill_Compression.cs b/src/Split/net10.0/Polyfill_Compression.cs index 70ca5171..3a42a56e 100644 --- a/src/Split/net10.0/Polyfill_Compression.cs +++ b/src/Split/net10.0/Polyfill_Compression.cs @@ -14,15 +14,13 @@ static partial class Polyfill /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/net461/Polyfill_Compression.cs b/src/Split/net461/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/net461/Polyfill_Compression.cs +++ b/src/Split/net461/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/net462/Polyfill_Compression.cs b/src/Split/net462/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/net462/Polyfill_Compression.cs +++ b/src/Split/net462/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/net47/Polyfill_Compression.cs b/src/Split/net47/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/net47/Polyfill_Compression.cs +++ b/src/Split/net47/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/net471/Polyfill_Compression.cs b/src/Split/net471/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/net471/Polyfill_Compression.cs +++ b/src/Split/net471/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/net472/Polyfill_Compression.cs b/src/Split/net472/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/net472/Polyfill_Compression.cs +++ b/src/Split/net472/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/net48/Polyfill_Compression.cs b/src/Split/net48/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/net48/Polyfill_Compression.cs +++ b/src/Split/net48/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/net481/Polyfill_Compression.cs b/src/Split/net481/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/net481/Polyfill_Compression.cs +++ b/src/Split/net481/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/net5.0/Polyfill_Compression.cs b/src/Split/net5.0/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/net5.0/Polyfill_Compression.cs +++ b/src/Split/net5.0/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/net6.0/Polyfill_Compression.cs b/src/Split/net6.0/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/net6.0/Polyfill_Compression.cs +++ b/src/Split/net6.0/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/net7.0/Polyfill_Compression.cs b/src/Split/net7.0/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/net7.0/Polyfill_Compression.cs +++ b/src/Split/net7.0/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/net8.0/Polyfill_Compression.cs b/src/Split/net8.0/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/net8.0/Polyfill_Compression.cs +++ b/src/Split/net8.0/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/net9.0/Polyfill_Compression.cs b/src/Split/net9.0/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/net9.0/Polyfill_Compression.cs +++ b/src/Split/net9.0/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/netcoreapp2.0/Polyfill_Compression.cs b/src/Split/netcoreapp2.0/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/netcoreapp2.0/Polyfill_Compression.cs +++ b/src/Split/netcoreapp2.0/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/netcoreapp2.1/Polyfill_Compression.cs b/src/Split/netcoreapp2.1/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/netcoreapp2.1/Polyfill_Compression.cs +++ b/src/Split/netcoreapp2.1/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/netcoreapp2.2/Polyfill_Compression.cs b/src/Split/netcoreapp2.2/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/netcoreapp2.2/Polyfill_Compression.cs +++ b/src/Split/netcoreapp2.2/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/netcoreapp3.0/Polyfill_Compression.cs b/src/Split/netcoreapp3.0/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/netcoreapp3.0/Polyfill_Compression.cs +++ b/src/Split/netcoreapp3.0/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/netcoreapp3.1/Polyfill_Compression.cs b/src/Split/netcoreapp3.1/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/netcoreapp3.1/Polyfill_Compression.cs +++ b/src/Split/netcoreapp3.1/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/netstandard2.0/Polyfill_Compression.cs b/src/Split/netstandard2.0/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/netstandard2.0/Polyfill_Compression.cs +++ b/src/Split/netstandard2.0/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Split/netstandard2.1/Polyfill_Compression.cs b/src/Split/netstandard2.1/Polyfill_Compression.cs index 5f1c8b45..208c619d 100644 --- a/src/Split/netstandard2.1/Polyfill_Compression.cs +++ b/src/Split/netstandard2.1/Polyfill_Compression.cs @@ -71,15 +71,13 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif } #endif diff --git a/src/Split/uap10.0/Polyfill_Compression.cs b/src/Split/uap10.0/Polyfill_Compression.cs index 906bd662..1b6133a8 100644 --- a/src/Split/uap10.0/Polyfill_Compression.cs +++ b/src/Split/uap10.0/Polyfill_Compression.cs @@ -71,16 +71,14 @@ public static Task ExtractToFileAsync(this ZipArchiveEntry source, string destin /// public static Stream Open(this ZipArchiveEntry target, FileAccess access) => target.Open(); -#if FeatureValueTask /// /// Asynchronously opens the entry from the zip archive with the specified access mode. /// - public static ValueTask OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) + public static Task OpenAsync(this ZipArchiveEntry target, FileAccess access, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - return new ValueTask(target.Open()); + return Task.FromResult(target.Open()); } -#endif /// /// Extracts all the files in the zip archive to a directory on the file system. /// diff --git a/src/Tests/PolyfillTests_Compression.cs b/src/Tests/PolyfillTests_Compression.cs index 441a856f..a69b039b 100644 --- a/src/Tests/PolyfillTests_Compression.cs +++ b/src/Tests/PolyfillTests_Compression.cs @@ -95,7 +95,6 @@ public async Task ZipArchiveEntry_Open_WithFileAccess() await Assert.That(result).IsEqualTo("content"); } -#if FeatureValueTask [Test] public async Task ZipArchiveEntry_OpenAsync_WithFileAccess() { @@ -114,12 +113,13 @@ public async Task ZipArchiveEntry_OpenAsync_WithFileAccess() using var readArchive = new ZipArchive(memStream, ZipArchiveMode.Read); var readEntry = readArchive.Entries[0]; - using var readStream = await readEntry.OpenAsync(FileAccess.Read); + // typed as Task so the test fails to compile if the polyfill drifts from the BCL return type + Task openTask = readEntry.OpenAsync(FileAccess.Read); + using var readStream = await openTask; using var reader = new StreamReader(readStream); var result = await reader.ReadToEndAsync(); await Assert.That(result).IsEqualTo("content"); } -#endif [Test] public async Task ExtractToDirectory_Extracts_All_Entries()