Imported Upstream version 5.20.0.184

Former-commit-id: 2513cc2d3116bd4f324e8da1afc305445d2ae665
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-02-05 08:22:04 +00:00
parent 0510252385
commit 97f8185566
49 changed files with 76 additions and 44 deletions

View File

@@ -89,8 +89,12 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(nameof(year), SR.ArgumentOutOfRange_Year);
}
int P(int y) => (y + (y / 4) - (y / 100) + (y / 400)) % 7;
#if __MonoCS__ // mcs doesn't support local functions
Func<int, int> P = y =>
#else
int P(int y) =>
#endif
(y + (y / 4) - (y / 100) + (y / 400)) % 7;
if (P(year) == 4 || P(year - 1) == 3)
{

View File

@@ -25,6 +25,9 @@ using System.Threading.Tasks;
namespace System.IO
{
#if MONO
[Serializable]
#endif
public abstract partial class Stream : MarshalByRefObject, IDisposable
{
public static readonly Stream Null = new NullStream();
@@ -35,8 +38,14 @@ namespace System.IO
private const int DefaultCopyBufferSize = 81920;
// To implement Async IO operations on streams that don't support async IO
#if MONO
[NonSerialized]
#endif
private ReadWriteTask _activeReadWriteTask;
#if MONO
[NonSerialized]
#endif
private SemaphoreSlim _asyncActiveSemaphore;
internal SemaphoreSlim EnsureAsyncActiveSemaphoreInitialized()
@@ -372,8 +381,9 @@ namespace System.IO
else
{
byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
return FinishReadAsync(ReadAsync(sharedBuffer, 0, buffer.Length, cancellationToken), sharedBuffer, buffer);
#if !__MonoCS__
return FinishReadAsync(ReadAsync(sharedBuffer, 0, buffer.Length, cancellationToken), sharedBuffer, buffer);
async ValueTask<int> FinishReadAsync(Task<int> readTask, byte[] localBuffer, Memory<byte> localDestination)
{
try
@@ -387,9 +397,27 @@ namespace System.IO
ArrayPool<byte>.Shared.Return(localBuffer);
}
}
#else
return new ValueTask<int> (FinishReadAsync(ReadAsync(sharedBuffer, 0, buffer.Length, cancellationToken), sharedBuffer, buffer));
#endif
}
}
#if __MonoCS__
internal async Task<int> FinishReadAsync(Task<int> readTask, byte[] localBuffer, Memory<byte> localDestination)
{
try
{
int result = await readTask.ConfigureAwait(false);
new Span<byte>(localBuffer, 0, result).CopyTo(localDestination.Span);
return result;
}
finally
{
ArrayPool<byte>.Shared.Return(localBuffer);
}
}
#endif
private Task<int> BeginEndReadAsync(byte[] buffer, int offset, int count)
{
if (!HasOverriddenBeginEndRead())

View File

@@ -33,7 +33,7 @@ namespace System
number.sign = double.IsNegative(value);
*dst = '\0';
if (value == 0.0)
if (BitConverter.DoubleToInt64Bits (value) == 0)
{
for (int j = 0; j < precision; j++)
{