Browse Source

[bcl] Sync recent NS2.1 changes (#15696)

1) Copied changes from corefx for System.Data (also https://github.com/mono/corefx/pull/310)
2) New Tracing api is left empty (because the current API is empty too)
3) New AES types throw PNSE

Bump netstandard.dll AssemblyVersion to 2.1 (fixes https://github.com/mono/mono/issues/13412)
Egor Bogatov 6 years ago
parent
commit
4febac951e

+ 1 - 1
external/api-snapshot

@@ -1 +1 @@
-Subproject commit e5adaddf527dfc4b0d5f44bf0b6e3c19b78c169e
+Subproject commit 5989f244c0dc41a8894bcb5a7bdceeb2c9c8bb56

+ 1 - 1
external/corefx

@@ -1 +1 @@
-Subproject commit 17dd540969d8a5a0e19c99dccc31293080f735d2
+Subproject commit 15b2cedee19ae823c6aa9f66a4e7fce8070f75ff

+ 3 - 3
mcs/class/Facades/netstandard/AssemblyInfo.cs

@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Mono development team")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("(c) Various Mono authors")]
-[assembly: AssemblyVersion ("2.0.0.0")]
-[assembly: AssemblyInformationalVersion ("2.0.0.0")]
-[assembly: AssemblyFileVersion ("2.0.0.0")]
+[assembly: AssemblyVersion ("2.1.0.0")]
+[assembly: AssemblyInformationalVersion ("2.1.0.0")]
+[assembly: AssemblyFileVersion ("2.1.0.0")]

+ 8 - 0
mcs/class/Facades/netstandard/TypeForwarders.cs

@@ -2444,8 +2444,13 @@
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.Text.Utf8Parser))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.CollectionExtensions))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.KeyValuePair))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Tracing.DiagnosticCounter))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Tracing.EventSourceCreatedEventArgs))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Tracing.IncrementingEventCounter))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Tracing.IncrementingPollingCounter))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Tracing.PollingCounter))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.KnownColor))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.DataReaderExtensions))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.Common.DbProviderFactories))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.ColorConverter))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.PointConverter))]
@@ -2508,6 +2513,7 @@
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.SignatureToken))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.StringToken))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.TypeToken))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.AmbiguousImplementationException))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AsyncMethodBuilderAttribute))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder<>))]
@@ -2534,6 +2540,8 @@
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.TypeLibVersionAttribute))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.Serialization.Formatters.IFieldInfo))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.SequencePosition))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.AesCcm))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.AesGcm))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.CryptographicOperations))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.ECDiffieHellman))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.PbeParameters))]

+ 1 - 0
mcs/class/System.Data/System.Data.csproj

@@ -525,6 +525,7 @@
     <Compile Include="Assembly\AssemblyInfo.cs" />
     <Compile Include="System.Data.SqlClient\SQLDebugging.cs" />
     <Compile Include="System.Data.SqlClient\SqlCredential.cs" />
+    <Compile Include="corefx\DataReaderExtensions.cs" />
     <Compile Include="corefx\DbConnectionOptions.cs" />
     <Compile Include="corefx\DbProviderFactories.mobile.cs" />
     <Compile Include="corefx\DiagnosticListener.cs" />

+ 1 - 0
mcs/class/System.Data/corefx.common.sources

@@ -24,6 +24,7 @@ corefx/SqlParameterCollection.cs
 corefx/TdsEnums.cs
 corefx/SR.cs
 corefx/SqlDependencyUtils.cs
+corefx/DataReaderExtensions.cs
 ../referencesource/System.Data/System/Data/Sql/SqlDataSourceEnumerator.cs
 ../referencesource/System.Data/System/Data/CodeGen/StrongTypingException.cs
 ../referencesource/System.Data/System/Data/OleDb/PropertyAttributes.cs

+ 183 - 0
mcs/class/System.Data/corefx/DataReaderExtensions.cs

@@ -0,0 +1,183 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.ComponentModel;
+using System.Data.Common;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace System.Data
+{
+    // copied from CoreFX (NS2.1)
+    public static class DataReaderExtensions
+    {
+        public static bool GetBoolean(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetBoolean(reader.GetOrdinal(name));
+        }
+
+        public static byte GetByte(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetByte(reader.GetOrdinal(name));
+        }
+
+        public static long GetBytes(this DbDataReader reader, string name, long dataOffset, byte[] buffer, int bufferOffset, int length)
+        {
+            AssertNotNull(reader);
+            return reader.GetBytes(reader.GetOrdinal(name), dataOffset, buffer, bufferOffset, length);
+        }
+
+        public static char GetChar(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetChar(reader.GetOrdinal(name));
+        }
+
+        public static long GetChars(this DbDataReader reader, string name, long dataOffset, char[] buffer, int bufferOffset, int length)
+        {
+            AssertNotNull(reader);
+            return reader.GetChars(reader.GetOrdinal(name), dataOffset, buffer, bufferOffset, length);
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static DbDataReader GetData(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetData(reader.GetOrdinal(name));
+        }
+
+        public static string GetDataTypeName(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetDataTypeName(reader.GetOrdinal(name));
+        }
+
+        public static DateTime GetDateTime(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetDateTime(reader.GetOrdinal(name));
+        }
+
+        public static decimal GetDecimal(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetDecimal(reader.GetOrdinal(name));
+        }
+
+        public static double GetDouble(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetDouble(reader.GetOrdinal(name));
+        }
+
+        public static Type GetFieldType(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetFieldType(reader.GetOrdinal(name));
+        }
+
+        public static T GetFieldValue<T>(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetFieldValue<T>(reader.GetOrdinal(name));
+        }
+
+        public static Task<T> GetFieldValueAsync<T>(this DbDataReader reader, string name, CancellationToken cancellationToken = default(CancellationToken))
+        {
+            AssertNotNull(reader);
+            return reader.GetFieldValueAsync<T>(reader.GetOrdinal(name), cancellationToken);
+        }
+
+        public static float GetFloat(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetFloat(reader.GetOrdinal(name));
+        }
+
+        public static Guid GetGuid(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetGuid(reader.GetOrdinal(name));
+        }
+
+        public static short GetInt16(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetInt16(reader.GetOrdinal(name));
+        }
+
+        public static int GetInt32(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetInt32(reader.GetOrdinal(name));
+        }
+
+        public static long GetInt64(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetInt64(reader.GetOrdinal(name));
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static Type GetProviderSpecificFieldType(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetProviderSpecificFieldType(reader.GetOrdinal(name));
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static object GetProviderSpecificValue(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetProviderSpecificValue(reader.GetOrdinal(name));
+        }
+
+        public static Stream GetStream(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetStream(reader.GetOrdinal(name));
+        }
+
+        public static string GetString(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetString(reader.GetOrdinal(name));
+        }
+
+        public static TextReader GetTextReader(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetTextReader(reader.GetOrdinal(name));
+        }
+
+        public static object GetValue(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.GetValue(reader.GetOrdinal(name));
+        }
+
+        public static bool IsDBNull(this DbDataReader reader, string name)
+        {
+            AssertNotNull(reader);
+            return reader.IsDBNull(reader.GetOrdinal(name));
+        }
+
+        public static Task<bool> IsDBNullAsync(this DbDataReader reader, string name, CancellationToken cancellationToken = default(CancellationToken))
+        {
+            AssertNotNull(reader);
+            return reader.IsDBNullAsync(reader.GetOrdinal(name), cancellationToken);
+        }
+
+        private static void AssertNotNull(DbDataReader reader)
+        {
+            if (reader == null)
+            {
+                throw new ArgumentNullException(nameof(reader));
+            }
+        }
+    }
+}

+ 10 - 0
mcs/class/System.Net.Http/System.Net.Http/HttpResponseMessage.cs

@@ -34,6 +34,7 @@ namespace System.Net.Http
 	public class HttpResponseMessage : IDisposable
 	{
 		HttpResponseHeaders headers;
+		HttpResponseHeaders trailingHeaders;
 		string reasonPhrase;
 		HttpStatusCode statusCode;
 		Version version;
@@ -137,5 +138,14 @@ namespace System.Net.Http
 			
 			return sb.ToString ();
 		}
+
+		public HttpResponseHeaders TrailingHeaders {
+			get {
+				if (trailingHeaders == null)
+					trailingHeaders = new HttpResponseHeaders ();
+
+				return trailingHeaders;
+			}
+		}
 	}
 }

+ 3 - 3
mcs/class/corlib/System.Diagnostics.Tracing/EventCounter.cs

@@ -28,9 +28,9 @@
 
 namespace System.Diagnostics.Tracing
 {
-	public class EventCounter : IDisposable
+	public class EventCounter : DiagnosticCounter
 	{
-		public EventCounter (string name, EventSource eventSource)
+		public EventCounter (string name, EventSource eventSource) : base (name, eventSource)
 		{
 		}
 
@@ -38,7 +38,7 @@ namespace System.Diagnostics.Tracing
 		{
 		}
 
-		public void Dispose ()
+		public void WriteMetric (double value)
 		{
 		}
 	}

+ 4 - 0
mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs

@@ -174,6 +174,10 @@ namespace System.Diagnostics.Tracing
 		{
 		}
 
+		internal void ReportOutOfBandMessage (string msg, bool flush)
+		{
+		}
+
 		protected void WriteEvent (int eventId)
 		{
 			WriteEvent (eventId, new object[] { } );

+ 12 - 0
mcs/class/corlib/System.Diagnostics.Tracing/EventWrittenEventArgs.cs

@@ -54,6 +54,18 @@ namespace System.Diagnostics.Tracing
 			internal set;
 		}
 
+		public long OSThreadId
+		{
+			get;
+			internal set;
+		}
+
+		public DateTime TimeStamp
+		{
+			get;
+			internal set;
+		}
+
 		public string EventName
 		{
 			get;

+ 19 - 0
mcs/class/corlib/corefx/AesCcm.cs

@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Security.Cryptography
+{
+    public sealed partial class AesCcm : System.IDisposable
+    {
+        public AesCcm (byte[] key) => throw new PlatformNotSupportedException ();
+        public AesCcm (System.ReadOnlySpan<byte> key) => throw new PlatformNotSupportedException ();
+        public static System.Security.Cryptography.KeySizes NonceByteSizes => throw new PlatformNotSupportedException ();
+        public static System.Security.Cryptography.KeySizes TagByteSizes => throw new PlatformNotSupportedException ();
+        public void Decrypt (byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintext, byte[] associatedData = null) => throw new PlatformNotSupportedException ();
+        public void Decrypt (System.ReadOnlySpan<byte> nonce, System.ReadOnlySpan<byte> ciphertext, System.ReadOnlySpan<byte> tag, System.Span<byte> plaintext, System.ReadOnlySpan<byte> associatedData = default(System.ReadOnlySpan<byte>)) => throw new PlatformNotSupportedException ();
+        public void Dispose () {}
+        public void Encrypt (byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[] associatedData = null) => throw new PlatformNotSupportedException ();
+        public void Encrypt (System.ReadOnlySpan<byte> nonce, System.ReadOnlySpan<byte> plaintext, System.Span<byte> ciphertext, System.Span<byte> tag, System.ReadOnlySpan<byte> associatedData = default(System.ReadOnlySpan<byte>)) => throw new PlatformNotSupportedException ();
+    }
+}

+ 19 - 0
mcs/class/corlib/corefx/AesGcm.cs

@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Security.Cryptography
+{
+    public sealed partial class AesGcm : System.IDisposable
+    {
+        public AesGcm (byte[] key) => throw new PlatformNotSupportedException ();
+        public AesGcm (System.ReadOnlySpan<byte> key) => throw new PlatformNotSupportedException ();
+        public static System.Security.Cryptography.KeySizes NonceByteSizes => throw new PlatformNotSupportedException ();
+        public static System.Security.Cryptography.KeySizes TagByteSizes => throw new PlatformNotSupportedException ();
+        public void Decrypt (byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintext, byte[] associatedData = null) => throw new PlatformNotSupportedException ();
+        public void Decrypt (System.ReadOnlySpan<byte> nonce, System.ReadOnlySpan<byte> ciphertext, System.ReadOnlySpan<byte> tag, System.Span<byte> plaintext, System.ReadOnlySpan<byte> associatedData = default(System.ReadOnlySpan<byte>)) => throw new PlatformNotSupportedException ();
+        public void Dispose () {}
+        public void Encrypt (byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[] associatedData = null) => throw new PlatformNotSupportedException ();
+        public void Encrypt (System.ReadOnlySpan<byte> nonce, System.ReadOnlySpan<byte> plaintext, System.Span<byte> ciphertext, System.Span<byte> tag, System.ReadOnlySpan<byte> associatedData = default(System.ReadOnlySpan<byte>)) => throw new PlatformNotSupportedException ();
+    }
+}

+ 18 - 0
mcs/class/corlib/corefx/DiagnosticCounter.cs

@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Diagnostics.Tracing
+{
+    public abstract partial class DiagnosticCounter : IDisposable
+    {
+        internal DiagnosticCounter (string name, EventSource eventSource) { }
+        internal DiagnosticCounter () { }
+        public string DisplayName { get; set; }
+        public string DisplayUnits { get; set; }
+        public EventSource EventSource { get; }
+        public string Name { get; }
+        public void AddMetadata (string key, string value) { }
+        public void Dispose () { }
+    }
+}

+ 13 - 0
mcs/class/corlib/corefx/IncrementingEventCounter.cs

@@ -0,0 +1,13 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Diagnostics.Tracing
+{
+    public partial class IncrementingEventCounter : DiagnosticCounter
+    {
+        public IncrementingEventCounter (string name, EventSource eventSource) : base (name, eventSource) {}
+        public void Increment (double increment = 1) {}
+        public TimeSpan DisplayRateTimeScale { get; set; }
+    }
+}

+ 12 - 0
mcs/class/corlib/corefx/IncrementingPollingCounter.cs

@@ -0,0 +1,12 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Diagnostics.Tracing
+{
+    public partial class IncrementingPollingCounter : DiagnosticCounter
+    {
+        public IncrementingPollingCounter (string name, EventSource eventSource, Func<double> totalValueProvider) : base (name, eventSource) {}
+        public TimeSpan DisplayRateTimeScale { get; set; }
+    }
+}

+ 11 - 0
mcs/class/corlib/corefx/PollingCounter.cs

@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Diagnostics.Tracing
+{
+    public partial class PollingCounter : DiagnosticCounter
+    {
+        public PollingCounter (string name, EventSource eventSource, Func<double> metricProvider) : base (name, eventSource) {}
+    }
+}

+ 6 - 0
mcs/class/corlib/corlib.csproj

@@ -1859,6 +1859,8 @@
     <Compile Include="coreclr\Math.CoreCLR.cs" />
     <Compile Include="coreclr\MemberInfo.cs" />
     <Compile Include="coreclr\SorterArray.cs" />
+    <Compile Include="corefx\AesCcm.cs" />
+    <Compile Include="corefx\AesGcm.cs" />
     <Compile Include="corefx\AwaitTaskContinuation.cs" />
     <Compile Include="corefx\BinaryEnums.cs" />
     <Compile Include="corefx\CompareInfo.cs" />
@@ -1866,16 +1868,20 @@
     <Compile Include="corefx\CurrentSystemTimeZone.cs" />
     <Compile Include="corefx\DateTime.cs" />
     <Compile Include="corefx\DefaultBinder.cs" />
+    <Compile Include="corefx\DiagnosticCounter.cs" />
     <Compile Include="corefx\Directory.cs" />
     <Compile Include="corefx\DirectoryInfo.cs" />
     <Compile Include="corefx\EnumeratorCancellationAttribute.cs" />
     <Compile Include="corefx\File.cs" />
     <Compile Include="corefx\FileInfo.cs" />
     <Compile Include="corefx\GlobalizationMode.cs" />
+    <Compile Include="corefx\IncrementingEventCounter.cs" />
+    <Compile Include="corefx\IncrementingPollingCounter.cs" />
     <Compile Include="corefx\MethodInfo.cs" />
     <Compile Include="corefx\MonoLinqHelper.cs" />
     <Compile Include="corefx\PbeEncryptionAlgorithm.cs" />
     <Compile Include="corefx\PbeParameters.cs" />
+    <Compile Include="corefx\PollingCounter.cs" />
     <Compile Include="corefx\RandomNumberGenerator.cs" />
     <Compile Include="corefx\RuntimeFeature.cs" />
     <Compile Include="corefx\RuntimeImports.cs" />

+ 6 - 0
mcs/class/corlib/corlib.dll.sources

@@ -1625,6 +1625,12 @@ corefx/RandomNumberGenerator.cs
 corefx/RuntimeFeature.cs
 corefx/RuntimeImports.cs
 corefx/TimeSpanParse.cs
+corefx/DiagnosticCounter.cs
+corefx/AesCcm.cs
+corefx/AesGcm.cs
+corefx/IncrementingEventCounter.cs
+corefx/IncrementingPollingCounter.cs
+corefx/PollingCounter.cs
 
 corert/DependencyReductionRootAttribute.cs
 corert/AddrofIntrinsics.cs