Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions PolyShim/NetCore30/Stream.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER)
#nullable enable
// ReSharper disable RedundantUsingDirective
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
// ReSharper disable PartialTypeWithSinglePart

using System;
using System.IO;
using System.Threading.Tasks;

internal static partial class PolyfillExtensions
{
extension(Stream stream)
{
#if FEATURE_TASK
// https://learn.microsoft.com/dotnet/api/system.io.stream.disposeasync
public async Task DisposeAsync()
{
#if FEATURE_ASYNCINTERFACES
if (stream is IAsyncDisposable asyncDisposable)
{
await asyncDisposable.DisposeAsync();
return;
}
#endif

await Task.Run(stream.Dispose);
}
#endif
}
}
#endif
33 changes: 33 additions & 0 deletions PolyShim/NetCore30/TextReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER)
#nullable enable
// ReSharper disable RedundantUsingDirective
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
// ReSharper disable PartialTypeWithSinglePart

using System;
using System.IO;
using System.Threading.Tasks;

internal static partial class PolyfillExtensions
{
extension(TextReader reader)
{
#if FEATURE_TASK
// https://learn.microsoft.com/dotnet/api/system.io.textreader.disposeasync
public async Task DisposeAsync()
{
#if FEATURE_ASYNCINTERFACES
if (reader is IAsyncDisposable asyncDisposable)
{
await asyncDisposable.DisposeAsync();
return;
}
#endif

await Task.Run(reader.Dispose);
}
#endif
}
}
#endif
33 changes: 33 additions & 0 deletions PolyShim/NetCore30/TextWriter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER)
#nullable enable
// ReSharper disable RedundantUsingDirective
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
// ReSharper disable PartialTypeWithSinglePart

using System;
using System.IO;
using System.Threading.Tasks;

internal static partial class PolyfillExtensions
{
extension(TextWriter writer)
{
#if FEATURE_TASK
// https://learn.microsoft.com/dotnet/api/system.io.textwriter.disposeasync
public async Task DisposeAsync()
{
#if FEATURE_ASYNCINTERFACES
if (writer is IAsyncDisposable asyncDisposable)
{
await asyncDisposable.DisposeAsync();
return;
}
#endif

await Task.Run(writer.Dispose);
}
#endif
}
}
#endif
9 changes: 7 additions & 2 deletions PolyShim/Signatures.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Signatures

- **Total:** 333
- **Total:** 336
- **Types:** 74
- **Members:** 259
- **Members:** 262

___

Expand Down Expand Up @@ -318,6 +318,7 @@ ___
- [`int Read(Span<byte>)`](https://learn.microsoft.com/dotnet/api/system.io.stream.read#system-io-stream-read(system-span((system-byte)))) <sup><sub>.NET Core 2.1</sub></sup>
- [`int ReadAtLeast(Span<byte>, int, bool)`](https://learn.microsoft.com/dotnet/api/system.io.stream.readatleast) <sup><sub>.NET 7.0</sub></sup>
- [`Task CopyToAsync(Stream, CancellationToken)`](https://learn.microsoft.com/dotnet/api/system.io.stream.copytoasync#system-io-stream-copytoasync(system-io-stream-system-threading-cancellationtoken)) <sup><sub>.NET Core 2.1</sub></sup>
- [`Task DisposeAsync()`](https://learn.microsoft.com/dotnet/api/system.io.stream.disposeasync) <sup><sub>.NET Core 3.0</sub></sup>
- [`Task ReadExactlyAsync(byte[], int, int, CancellationToken)`](https://learn.microsoft.com/dotnet/api/system.io.stream.readexactlyasync#system-io-stream-readexactlyasync(system-byte()-system-int32-system-int32-system-threading-cancellationtoken)) <sup><sub>.NET 7.0</sub></sup>
- [`Task ReadExactlyAsync(Memory<byte>, CancellationToken)`](https://learn.microsoft.com/dotnet/api/system.io.stream.readexactlyasync#system-io-stream-readexactlyasync(system-memory((system-byte))-system-threading-cancellationtoken)) <sup><sub>.NET 7.0</sub></sup>
- [`Task WriteAsync(ReadOnlyMemory<byte>, CancellationToken)`](https://learn.microsoft.com/dotnet/api/system.io.stream.writeasync#system-io-stream-writeasync(system-readonlymemory((system-byte))-system-threading-cancellationtoken)) <sup><sub>.NET Core 2.1</sub></sup>
Expand Down Expand Up @@ -415,6 +416,10 @@ ___
- `TaskCompletionSource<T>`
- [`bool TrySetCanceled(CancellationToken)`](https://learn.microsoft.com/dotnet/api/system.threading.tasks.taskcompletionsource-1.trysetcanceled#system-threading-tasks-taskcompletionsource-1-trysetcanceled(system-threading-cancellationtoken)) <sup><sub>.NET Core 1.0</sub></sup>
- [`void SetCanceled(CancellationToken)`](https://learn.microsoft.com/dotnet/api/system.threading.tasks.taskcompletionsource-1.setcanceled#system-threading-tasks-taskcompletionsource-1-setcanceled(system-threading-cancellationtoken)) <sup><sub>.NET 5.0</sub></sup>
- `TextReader`
- [`Task DisposeAsync()`](https://learn.microsoft.com/dotnet/api/system.io.textreader.disposeasync) <sup><sub>.NET Core 3.0</sub></sup>
- `TextWriter`
- [`Task DisposeAsync()`](https://learn.microsoft.com/dotnet/api/system.io.textwriter.disposeasync) <sup><sub>.NET Core 3.0</sub></sup>
- `ThreadAbortException`
- [**[class]**](https://learn.microsoft.com/dotnet/api/system.threading.threadabortexception) <sup><sub>.NET Core 2.0</sub></sup>
- `TimeSpan`
Expand Down
Loading