Enable netfx testing. (#588)

* Enable netfx testing.

* Skip impacted tests and re-enable netfx testing.

* Remove redundant comment.

* Remove unnecessary project configuration.

* Simplify test server copying.
This commit is contained in:
Eirik Tsarpalis 2025-07-08 18:50:37 +03:00 • committed by GitHub
commit aa75f6f37e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1940 additions and 53 deletions

View file

@ -1,6 +1,7 @@
using ModelContextProtocol;
using System.Buffers;
using System.Runtime.InteropServices;
using System.Text;
namespace System.IO;
@ -33,4 +34,31 @@ internal static class StreamExtensions
}
}
}
public static ValueTask<int> ReadAsync(this Stream stream, Memory<byte> buffer, CancellationToken cancellationToken)
{
Throw.IfNull(stream);
if (MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> segment))
{
return new ValueTask<int>(stream.ReadAsync(segment.Array, segment.Offset, segment.Count, cancellationToken));
}
else
{
return ReadAsyncCore(stream, buffer, cancellationToken);
static async ValueTask<int> ReadAsyncCore(Stream stream, Memory<byte> buffer, CancellationToken cancellationToken)
{
byte[] array = ArrayPool<byte>.Shared.Rent(buffer.Length);
try
{
int bytesRead = await stream.ReadAsync(array, 0, buffer.Length, cancellationToken).ConfigureAwait(false);
array.AsSpan(0, bytesRead).CopyTo(buffer.Span);
return bytesRead;
}
finally
{
ArrayPool<byte>.Shared.Return(array);
}
}
}
}
}

View file

@ -1,10 +0,0 @@
namespace System.IO;
internal static class TextReaderExtensions
{
public static Task<string> ReadLineAsync(this TextReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
return reader.ReadLineAsync();
}
}