2
0
Эх сурвалжийг харах

NS2.1: System.IO, System.Reflection.Emit, etc (#12854)

* System.IO, System.Data

* lots of small ns21 improvements

* More changes (System.Reflection.Emit)

* Add IEquatable to S.R.Emit types

* bump corefx

* fix unix build

* more NS21 changes

* more changes

* bump corefx

* Fix failing tests (Sockets)

* bump corefx

* tmp workaround

* move DispatchProxyGenerator to net_4_x

* Bump API snapshot submodule

* [csproj] Update project files
Egor Bogatov 6 жил өмнө
parent
commit
cf69b47259
71 өөрчлөгдсөн 1717 нэмэгдсэн , 114 устгасан
  1. 1 1
      external/api-snapshot
  2. 1 1
      external/corefx
  3. 2 3
      mcs/class/Facades/netstandard/Facades_netstandard.csproj
  4. 5 0
      mcs/class/Facades/netstandard/Makefile
  5. 27 14
      mcs/class/Facades/netstandard/TypeForwarders.cs
  6. 5 3
      mcs/class/Facades/netstandard/apicheck.sh
  7. 10 0
      mcs/class/System.Core/System.Core.csproj
  8. 6 0
      mcs/class/System.Core/System.Security.Cryptography.X509Certificates/ECDsaCertificateExtensions.cs
  9. 7 0
      mcs/class/System.Core/corefx/SR.missing.cs
  10. 3 0
      mcs/class/System.Core/net_4_x_System.Core.dll.sources
  11. 3 0
      mcs/class/System.Core/win32_net_4_x_System.Core.dll.sources
  12. 12 2
      mcs/class/System/System.Diagnostics/Process.cs
  13. 14 0
      mcs/class/System/System.Diagnostics/ProcessStartInfo.cs
  14. 1 0
      mcs/class/System/System.Net.Security/SslStream.cs
  15. 14 0
      mcs/class/System/System.Net.Sockets/Socket.cs
  16. 5 0
      mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs
  17. 4 0
      mcs/class/System/System.Net.Sockets/SocketTaskExtensions.cs
  18. 10 5
      mcs/class/System/System.csproj
  19. 4 4
      mcs/class/System/Test/System.Net.Sockets/MulticastOptionTest.cs
  20. 2 2
      mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
  21. 2 2
      mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs
  22. 1 1
      mcs/class/System/Test/System.Net/DnsTest.cs
  23. 1 14
      mcs/class/System/Test/System.Net/IPAddressTest.cs
  24. 14 5
      mcs/class/System/common.sources
  25. 319 0
      mcs/class/System/corefx/tmp/IPAddressParser.cs
  26. 415 0
      mcs/class/System/corefx/tmp/IPv6AddressHelper.Common.cs
  27. 2 1
      mcs/class/corlib/Makefile
  28. 1 1
      mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs
  29. 1 1
      mcs/class/corlib/System.IO/FileStream.cs
  30. 1 3
      mcs/class/corlib/System.IO/Path.cs
  31. 185 0
      mcs/class/corlib/System.IO/Path.ns21.cs
  32. 2 2
      mcs/class/corlib/System.Reflection.Emit/EventToken.cs
  33. 2 2
      mcs/class/corlib/System.Reflection.Emit/FieldToken.cs
  34. 2 2
      mcs/class/corlib/System.Reflection.Emit/Label.cs
  35. 2 2
      mcs/class/corlib/System.Reflection.Emit/MethodToken.cs
  36. 3 3
      mcs/class/corlib/System.Reflection.Emit/OpCode.cs
  37. 2 2
      mcs/class/corlib/System.Reflection.Emit/ParameterToken.cs
  38. 2 2
      mcs/class/corlib/System.Reflection.Emit/PropertyToken.cs
  39. 2 2
      mcs/class/corlib/System.Reflection.Emit/SignatureToken.cs
  40. 2 2
      mcs/class/corlib/System.Reflection.Emit/StringToken.cs
  41. 2 2
      mcs/class/corlib/System.Reflection.Emit/TypeToken.cs
  42. 2 0
      mcs/class/corlib/System.Reflection/Assembly.cs
  43. 24 0
      mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
  44. 2 0
      mcs/class/corlib/System.Threading/Interlocked.cs
  45. 2 2
      mcs/class/corlib/System/IntPtr.cs
  46. 2 2
      mcs/class/corlib/System/UIntPtr.cs
  47. 35 0
      mcs/class/corlib/corefx/RandomNumberGenerator.cs
  48. 35 0
      mcs/class/corlib/corefx/SR.cs
  49. 20 0
      mcs/class/corlib/corefx/Stream.cs
  50. 8 3
      mcs/class/corlib/corlib.csproj
  51. 8 3
      mcs/class/corlib/corlib.dll.sources
  52. 93 0
      mcs/class/referencesource/System.Core/System/Security/Cryptography/ECDsa.cs
  53. 14 3
      mcs/class/referencesource/System.Data/System/Data/Common/DbProviderFactories.cs
  54. 1 1
      mcs/class/referencesource/System.Data/System/Data/DataSysAttribute.cs
  55. 1 1
      mcs/class/referencesource/System.Xml/System/Xml/Core/XmlValidatingReader.cs
  56. 1 1
      mcs/class/referencesource/System.Xml/System/Xml/Schema/XmlSchemaCollection.cs
  57. 1 1
      mcs/class/referencesource/System.Xml/System/Xml/Serialization/XmlAnyAttributeAttribute.cs
  58. 1 1
      mcs/class/referencesource/System.Xml/System/Xml/Serialization/XmlNamespaceDeclarationsAttribute.cs
  59. 1 1
      mcs/class/referencesource/System/net/System/Net/GlobalProxySelection.cs
  60. 8 0
      mcs/class/referencesource/System/net/System/Net/SocketAddress.cs
  61. 13 1
      mcs/class/referencesource/System/net/System/Net/Sockets/UDPClient.cs
  62. 16 1
      mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs
  63. 1 1
      mcs/class/referencesource/System/sys/system/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs
  64. 14 0
      mcs/class/referencesource/mscorlib/system/io/binaryreader.cs
  65. 40 0
      mcs/class/referencesource/mscorlib/system/io/binarywriter.cs
  66. 1 1
      mcs/class/referencesource/mscorlib/system/reflection/emit/methodbuilder.cs
  67. 1 1
      mcs/class/referencesource/mscorlib/system/runtime/interopservices/attributes.cs
  68. 3 3
      mcs/class/referencesource/mscorlib/system/runtime/serialization/streamingcontext.cs
  69. 126 0
      mcs/class/referencesource/mscorlib/system/security/cryptography/dsa.cs
  70. 141 0
      mcs/class/referencesource/mscorlib/system/security/cryptography/rsa.cs
  71. 3 3
      mono/metadata/w32socket.c

+ 1 - 1
external/api-snapshot

@@ -1 +1 @@
-Subproject commit c264965ac8d5d83244ec5ddac863412eca0950f9
+Subproject commit b6f22e38fbf9146a01d004d7aa0298c69e181567

+ 1 - 1
external/corefx

@@ -1 +1 @@
-Subproject commit b340793442f8fcae92faa99bf21ecc5589f220e0
+Subproject commit ab2a57253ff9f2d75b29883d34563c280df84541

+ 2 - 3
mcs/class/Facades/netstandard/Facades_netstandard.csproj

@@ -6,7 +6,7 @@
     <Platform Condition=" '$(Platform)' == '' ">net_4_x</Platform>
     <ProjectGuid>{E4596A34-AFBC-4744-8352-E6996AC34C16}</ProjectGuid>
     <OutputType>Library</OutputType>
-    <NoWarn>1699,1616,1699,618</NoWarn>
+    <NoWarn>1699</NoWarn>
     <LangVersion>latest</LangVersion>
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Windows_NT'">win32</HostPlatform>
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix' and $([System.IO.File]::Exists('/usr/lib/libc.dylib'))">macos</HostPlatform>
@@ -17,7 +17,6 @@
     <AssemblyName>netstandard</AssemblyName>
     <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
     <SignAssembly>true</SignAssembly>
-    <DelaySign>true</DelaySign>
     <AssemblyOriginatorKeyFile>../../Open.snk</AssemblyOriginatorKeyFile>
   </PropertyGroup>
   <PropertyGroup>
@@ -29,7 +28,7 @@
   <PropertyGroup Condition=" '$(Platform)' == 'net_4_x' ">
     <OutputPath>./../../../class/lib/net_4_x-$(HostPlatform)/Facades</OutputPath>
     <IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
-    <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>
+    <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;NS21</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Platform)' == 'monodroid' ">
     <OutputPath>./../../../class/lib/monodroid/Facades</OutputPath>

+ 5 - 0
mcs/class/Facades/netstandard/Makefile

@@ -31,6 +31,11 @@ endif
 
 endif
 
+ifeq ($(PROFILE),net_4_x)
+# TODO: remove once mobile profile supports NS 2.1
+LIB_MCS_FLAGS := -d:NS21
+endif
+
 ifeq ($(PROFILE),monodroid)
 # XA implements System.Drawing API inside Mono.Android
 API_BIN_REFS := Mono.Android

+ 27 - 14
mcs/class/Facades/netstandard/TypeForwarders.cs

@@ -130,6 +130,7 @@
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Guid))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.HttpStyleUriParser))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IAsyncResult))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IAsyncDisposable))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ICloneable))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IComparable))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IComparable<>))]
@@ -1424,6 +1425,16 @@
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.TypeFilter))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.TypeInfo))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.FlowControl))]
+// [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.DynamicILInfo))]
+// [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.EventToken))]
+// [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.ExceptionHandler))]
+// [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.FieldToken))]
+// [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.MethodToken))]
+// [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.ParameterToken))]
+// [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.PropertyToken))]
+// [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.Reflection.Emit.OpCode))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.OpCodes))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.OpCodeType))]
@@ -2440,23 +2451,25 @@
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.RectangleConverter))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SizeConverter))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SizeFConverter))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Globalization.ISOWeek))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.EnumerationOptions))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.MatchCasing))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.MatchType))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.BrotliDecoder))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.BrotliEncoder))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.BrotliStream))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemEntry))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemEnumerable<>))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemEnumerator<>))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemName))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Globalization.ISOWeek))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.EnumerationOptions))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.MatchCasing))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.MatchType))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.BrotliDecoder))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.BrotliEncoder))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.BrotliStream))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemEntry))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemEnumerable<>))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemEnumerator<>))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Enumeration.FileSystemName))]
 //[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Http.ReadOnlyMemoryContent))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Security.ServerCertificateSelectionCallback))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Security.SslApplicationProtocol))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Security.SslClientAuthenticationOptions))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Security.SslServerAuthenticationOptions))]
+#if !BOOTSTRAP_BASIC
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Sockets.UnixDomainSocketEndPoint))]
+#endif
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.WebSockets.ValueWebSocketReceiveResult))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.Matrix3x2))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.Matrix4x4))]
@@ -2467,7 +2480,7 @@
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.Vector2))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.Vector3))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.Vector4))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.DispatchProxy))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.DispatchProxy))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.AssemblyBuilder))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.AssemblyBuilderAccess))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Reflection.Emit.ConstructorBuilder))]
@@ -2512,11 +2525,11 @@
 [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.CryptographicOperations))]
+[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.X509Certificates.CertificateRequest))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.X509Certificates.DSACertificateExtensions))]
-//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.X509Certificates.SubjectAlternativeNameBuilder))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.X509Certificates.SubjectAlternativeNameBuilder))]
 //[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.X509Certificates.X509SignatureGenerator))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Tasks.ValueTask))]
 [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Tasks.ValueTask<>))]

+ 5 - 3
mcs/class/Facades/netstandard/apicheck.sh

@@ -3,7 +3,9 @@
 # Cloned and Build location of https://github.com/dotnet/standard
 STANDARD=/Users/cloned-location-of/dotnet/standard
 
-APICOMPAT=$STANDARD/Tools/ApiCompat.exe
-NSAPI=$STANDARD/bin/ref/netstandard/2.0.0.0/netstandard.dll
+# Microsoft.DotNet.ApiCompat.exe can be built in https://github.com/dotnet/arcade
+APICOMPAT=Microsoft.DotNet.ApiCompat.exe
+NSAPI=$(STANDARD)/artifacts/bin/ref/netstandard/Debug/netstandard.dll
 
-dotnet $APICOMPAT $NSAPI -implDirs:../../lib/net_4_x/Facades/,../../lib/net_4_x/
+dotnet $APICOMPAT $NSAPI --impl-dirs "../../lib/net_4_x/Facades/,../../lib/net_4_x/" --exclude-non-browsable
+# --exclude-non-browsable ignores `EditorBrowsableAttribute` issues

+ 10 - 0
mcs/class/System.Core/System.Core.csproj

@@ -880,6 +880,10 @@
             <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\StackSpiller.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\VariableBinder.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Runtime\CompilerServices\RuntimeOps.ExpressionQuoter.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.Windows.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxy.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxyGenerator.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\AesManaged.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellman.cs" />
             <Compile Include="..\referencesource\System.Core\System\threading\ReaderWriterLockSlim\LockRecursionException.cs" />
@@ -958,6 +962,8 @@
             <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Runtime\CompilerServices\RuntimeOps.ExpressionQuoter.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxy.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxyGenerator.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\AesManaged.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellman.cs" />
             <Compile Include="..\referencesource\System.Core\System\threading\ReaderWriterLockSlim\LockRecursionException.cs" />
@@ -1036,6 +1042,8 @@
             <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Runtime\CompilerServices\RuntimeOps.ExpressionQuoter.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxy.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxyGenerator.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\AesManaged.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellman.cs" />
             <Compile Include="..\referencesource\System.Core\System\threading\ReaderWriterLockSlim\LockRecursionException.cs" />
@@ -1114,6 +1122,8 @@
             <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Runtime\CompilerServices\RuntimeOps.ExpressionQuoter.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs" />
             <Compile Include="..\..\..\external\corefx\src\System.Net.Sockets\src\System\Net\Sockets\UnixDomainSocketEndPoint.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxy.cs" />
+            <Compile Include="..\..\..\external\corefx\src\System.Reflection.DispatchProxy\src\System\Reflection\DispatchProxyGenerator.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\AesManaged.cs" />
             <Compile Include="..\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellman.cs" />
             <Compile Include="..\referencesource\System.Core\System\threading\ReaderWriterLockSlim\LockRecursionException.cs" />

+ 6 - 0
mcs/class/System.Core/System.Security.Cryptography.X509Certificates/ECDsaCertificateExtensions.cs

@@ -41,5 +41,11 @@ namespace System.Security.Cryptography.X509Certificates
 		{
 			throw new NotImplementedException ();
 		}
+
+		[MonoTODO]
+		public static X509Certificate2 CopyWithPrivateKey(this X509Certificate2 certificate, ECDsa privateKey)
+		{
+			throw new NotImplementedException ();
+		}
 	}
 }

+ 7 - 0
mcs/class/System.Core/corefx/SR.missing.cs

@@ -5,4 +5,11 @@ partial class SR
 	public const string InvalidOperation_ViewIsNull = "The underlying MemoryMappedView object is null.";
 	public const string ArgumentOutOfRange_InvalidPipeAccessRights = "Invalid PipeAccessRights flag.";
 	public const string ArgumentOutOfRange_AdditionalAccessLimited = "additionalAccessRights is limited to the PipeAccessRights.ChangePermissions, PipeAccessRights.TakeOwnership, and PipeAccessRights.AccessSystemSecurity flags when creating NamedPipeServerStreams.";
+	public const string InterfaceType_Must_Be_Interface = "The type '{0}' must be an interface, not a class.";
+	public const string BaseType_Cannot_Be_Sealed = "The base type '{0}' cannot be sealed.";
+	public const string BaseType_Cannot_Be_Abstract = "The base type '{0}' cannot be abstract.";
+	public const string BaseType_Must_Have_Default_Ctor = "The base type '{0}' must have a public parameterless constructor.";
+	public const string Cryptography_Cert_AlreadyHasPrivateKey = "The certificate already has an associated private key.";
+	public const string Cryptography_PrivateKey_WrongAlgorithm = "The provided key does not match the public key algorithm for this certificate.";
+	public const string Cryptography_PrivateKey_DoesNotMatch = "The provided key does not match the public key for this certificate.";
 }

+ 3 - 0
mcs/class/System.Core/net_4_x_System.Core.dll.sources

@@ -13,3 +13,6 @@ System.Security.Cryptography/SHA512Cng.cs
 ../referencesource/System.Core/System/Security/Cryptography/ECDiffieHellman.cs
 
 ../referencesource/System.Core/System/threading/ReaderWriterLockSlim/LockRecursionException.cs
+
+../../../external/corefx/src/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs
+../../../external/corefx/src/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs

+ 3 - 0
mcs/class/System.Core/win32_net_4_x_System.Core.dll.sources

@@ -37,6 +37,9 @@ System.IO.Pipes/AnonymousPipeServerStream.Windows.cs
 ../../../external/corefx/src/Common/src/Interop/Windows/advapi32/Interop.RevertToSelf.cs
 ../../../external/corefx/src/Common/src/Interop/Windows/advapi32/Interop.ImpersonateNamedPipeClient.cs
 
+../../../external/corefx/src/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.cs
+../../../external/corefx/src/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.Windows.cs
+
 ../../../external/corefx/src/System.IO.Pipes/src/Microsoft/Win32/SafeHandles/SafePipeHandle.Windows.cs
 ../../../external/corefx/src/System.IO.Pipes/src/System/IO/Pipes/AnonymousPipeServerStream.Windows.cs
 ../../../external/corefx/src/System.IO.Pipes/src/System/IO/Pipes/ConnectionCompletionSource.cs

+ 12 - 2
mcs/class/System/System.Diagnostics/Process.cs

@@ -42,6 +42,7 @@ using System.Runtime.InteropServices;
 using System.Runtime.Remoting.Messaging;
 using System.Security.Permissions;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Security;
 using System.Threading;
 using Microsoft.Win32;
@@ -127,6 +128,15 @@ namespace System.Diagnostics
 			}
 		}
 
+		private static void AppendArguments (StringBuilder stringBuilder, Collection<string> argumentList)
+		{
+			if (argumentList.Count > 0) {
+				foreach (string argument in argumentList) {
+					PasteArguments.AppendArgument (stringBuilder, argument);
+				}
+			}
+		}
+
 		/* Returns the list of process modules.  The main module is
 		 * element 0.
 		 */
@@ -782,9 +792,9 @@ namespace System.Diagnostics
 				MonoIO.Close (stdin_read, out error);
 
 #if MOBILE
-				var stdinEncoding = Encoding.Default;
+				var stdinEncoding = startInfo.StandardInputEncoding ?? Encoding.Default;
 #else
-				var stdinEncoding = Console.InputEncoding;
+				var stdinEncoding = startInfo.StandardInputEncoding ?? Console.InputEncoding;
 #endif
 				standardInput = new StreamWriter (new FileStream (stdin_write, FileAccess.Write, true, 8192), stdinEncoding) {
 					AutoFlush = true

+ 14 - 0
mcs/class/System/System.Diagnostics/ProcessStartInfo.cs

@@ -31,6 +31,7 @@
 
 using Microsoft.Win32;
 using System.Collections;
+using System.Collections.ObjectModel;
 using System.Collections.Specialized;
 using System.ComponentModel;
 using System.IO;
@@ -48,6 +49,19 @@ namespace System.Diagnostics
 			get { return (environmentVariables != null); }
 		}
 
+		Collection<string> _argumentList;
+
+		public Collection<string> ArgumentList {
+			get {
+				if (_argumentList == null) {
+					_argumentList = new Collection<string>();
+				}
+				return _argumentList;
+			}
+		}
+
+		public Encoding StandardInputEncoding { get; set; }
+
 		static readonly string [] empty = new string [0];
 
 		[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]

+ 1 - 0
mcs/class/System/System.Net.Security/SslStream.cs

@@ -721,5 +721,6 @@ namespace System.Net.Security
 			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
 		}
 #endif
+		public SslApplicationProtocol NegotiatedApplicationProtocol => throw new PlatformNotSupportedException();
 	}
 }

+ 14 - 0
mcs/class/System/System.Net.Sockets/Socket.cs

@@ -1383,6 +1383,20 @@ namespace System.Net.Sockets
 			return ret;
 		}
 
+		public int Receive(Span<byte> buffer, SocketFlags socketFlags, out SocketError errorCode)
+		{
+			byte[] tempBuffer = new byte[buffer.Length];
+			int result = Receive(tempBuffer, 0, tempBuffer.Length, socketFlags, out errorCode);
+			tempBuffer.CopyTo (buffer);
+			return result;
+		}
+
+		public int Send(ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out SocketError errorCode)
+		{
+			byte[] bufferBytes = buffer.ToArray();
+			return Send(bufferBytes, 0, bufferBytes.Length, socketFlags, out errorCode);
+		}
+
 		public int Receive (Span<byte> buffer, SocketFlags socketFlags)
 		{
 			byte[] tempBuffer = new byte[buffer.Length];

+ 5 - 0
mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs

@@ -238,6 +238,11 @@ namespace System.Net.Sockets
 			Buffer = buffer;
 		}
 
+		public void SetBuffer(Memory<byte> buffer)
+		{
+			SetBuffer(buffer.ToArray(), 0, buffer.Length);
+		}
+
 		internal void StartOperationCommon (Socket socket)
 		{
 			current_socket = socket;

+ 4 - 0
mcs/class/System/System.Net.Sockets/SocketTaskExtensions.cs

@@ -4,6 +4,7 @@
 
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using System.Threading;
 
 namespace System.Net.Sockets
 {
@@ -246,5 +247,8 @@ namespace System.Net.Sockets
                 remoteEP,
                 state: socket);
         }
+
+        public static ValueTask<int> SendAsync(this Socket socket, ReadOnlyMemory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken = default) =>
+            socket.SendAsync(buffer, socketFlags, cancellationToken);
     }
 }

+ 10 - 5
mcs/class/System/System.csproj

@@ -137,6 +137,8 @@
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\DebugSafeHandle.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\ExceptionCheck.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\HttpStatusDescription.cs" />
+    <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\IPAddressParserStatics.cs" />
+    <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\IPv4AddressHelper.Common.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\Logging\NetEventSource.Common.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\Mail\DomainLiteralReader.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\Mail\DotAtomReader.cs" />
@@ -158,6 +160,7 @@
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\WebSockets\ManagedWebSocket.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Net\WebSockets\WebSocketValidate.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\NotImplemented.cs" />
+    <Compile Include="..\..\..\external\corefx\src\Common\src\System\PasteArguments.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Security\Cryptography\DerEncoder.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Security\Cryptography\DerSequenceReader.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\StringExtensions.cs" />
@@ -407,7 +410,6 @@
     <Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\GZipStream.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\FileSystemWatcher.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\WaitForChangedResult.cs" />
-    <Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem\src\System\IO\Enumeration\FileSystemName.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.Mail\src\System\Net\Base64Stream.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.Mail\src\System\Net\BufferBuilder.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.Mail\src\System\Net\CloseableStream.cs" />
@@ -441,6 +443,7 @@
     <Compile Include="..\..\..\external\corefx\src\System.Net.Mail\src\System\Net\TrackingValidationObjectDictionary.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.Primitives\src\System\Net\HttpStatusCode.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.Primitives\src\System\Net\HttpVersion.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Net.Primitives\src\System\Net\IPAddress.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.Primitives\src\System\Net\IPEndPoint.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.ServicePoint\src\System\Net\SecurityProtocolType.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Net.WebClient\src\System\Net\WebClient.cs" />
@@ -470,6 +473,8 @@
     <Compile Include="..\..\..\external\corefx\src\System.ObjectModel\src\System\ComponentModel\PropertyChangedEventHandler.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.ObjectModel\src\System\ComponentModel\PropertyChangingEventArgs.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.ObjectModel\src\System\ComponentModel\PropertyChangingEventHandler.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Private.Uri\src\System\IPv4AddressHelper.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Private.Uri\src\System\IPv6AddressHelper.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Private.Uri\src\System\UriBuilder.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Runtime.Extensions\src\System\CodeDom\Compiler\IndentedTextWriter.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Runtime.Extensions\src\System\StringNormalizationExtensions.cs" />
@@ -482,12 +487,13 @@
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Encoding\src\System\Security\Cryptography\OidCollection.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Encoding\src\System\Security\Cryptography\OidEnumerator.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Encoding\src\System\Security\Cryptography\OidGroup.cs" />
-    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\CryptographicOperations.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Oids.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.OSX\CertificateData.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\GeneralNameEncoder.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\OpenFlags.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\StoreLocation.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\StoreName.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\SubjectAlternativeNameBuilder.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\X500DistinguishedNameFlags.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\X509ChainStatusFlags.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\X509FindType.cs" />
@@ -626,7 +632,6 @@
     <Compile Include="..\referencesource\System\net\System\Net\ICertificatePolicy.cs" />
     <Compile Include="..\referencesource\System\net\System\Net\ICredentials.cs" />
     <Compile Include="..\referencesource\System\net\System\Net\ICredentialsByHost.cs" />
-    <Compile Include="..\referencesource\System\net\System\Net\IPAddress.cs" />
     <Compile Include="..\referencesource\System\net\System\Net\IPHostEntry.cs" />
     <Compile Include="..\referencesource\System\net\System\Net\IWebProxyFinder.cs" />
     <Compile Include="..\referencesource\System\net\System\Net\IWebRequestCreate.cs" />
@@ -751,8 +756,6 @@
     <Compile Include="..\referencesource\System\net\System\UriParserTemplates.cs" />
     <Compile Include="..\referencesource\System\net\System\UriScheme.cs" />
     <Compile Include="..\referencesource\System\net\System\_DomainName.cs" />
-    <Compile Include="..\referencesource\System\net\System\_IPv4Address.cs" />
-    <Compile Include="..\referencesource\System\net\System\_IPv6Address.cs" />
     <Compile Include="..\referencesource\System\net\System\_UncName.cs" />
     <Compile Include="..\referencesource\System\net\System\_UriSyntax.cs" />
     <Compile Include="..\referencesource\System\security\system\security\Authentication\ExtendedProtection\ServiceNameCollection.cs" />
@@ -1010,6 +1013,8 @@
     <Compile Include="corefx\NameValueCollection.cs" />
     <Compile Include="corefx\StringDictionary.cs" />
     <Compile Include="corefx\ZLibNative.cs" />
+    <Compile Include="corefx\tmp\IPAddressParser.cs" />
+    <Compile Include="corefx\tmp\IPv6AddressHelper.Common.cs" />
   </ItemGroup>
   <!--End of common files-->
   <!--Per-profile files-->

+ 4 - 4
mcs/class/System/Test/System.Net.Sockets/MulticastOptionTest.cs

@@ -207,7 +207,7 @@ namespace MonoTests.System.Net.Sockets
 			IPAddress local;
 			MulticastOption option;
 
-			local = Dns.GetHostEntry (string.Empty).AddressList [0];
+			local = Dns.GetHostEntry ("localhost").AddressList [0];
 			group = IPAddress.Parse ("239.255.255.250");
 			option = new MulticastOption (group, local);
 			group = IPAddress.Parse ("224.0.0.23");
@@ -255,7 +255,7 @@ namespace MonoTests.System.Net.Sockets
 			Assert.AreEqual (0xFFFFFF, option.InterfaceIndex, "#C2");
 			Assert.IsNull (option.LocalAddress, "#C3");
 
-			local = Dns.GetHostEntry (string.Empty).AddressList [0];
+			local = Dns.GetHostEntry ("localhost").AddressList [0];
 			option = new MulticastOption (group, local);
 			option.InterfaceIndex = 10;
 			Assert.AreSame (group, option.Group, "#D1");
@@ -302,7 +302,7 @@ namespace MonoTests.System.Net.Sockets
 			IPAddress local;
 			MulticastOption option;
 
-			local = Dns.GetHostEntry (string.Empty).AddressList [0];
+			local = Dns.GetHostEntry ("localhost").AddressList [0];
 			group = IPAddress.Parse ("239.255.255.250");
 			option = new MulticastOption (group, local);
 			local = IPAddress.Loopback;
@@ -310,7 +310,7 @@ namespace MonoTests.System.Net.Sockets
 			Assert.AreSame (group, option.Group, "#A1");
 			Assert.AreEqual (0, option.InterfaceIndex, "#A2");
 			Assert.AreSame (local, option.LocalAddress, "#A3");
-			local = Dns.GetHostEntry (string.Empty).AddressList [0];
+			local = Dns.GetHostEntry ("localhost").AddressList [0];
 			option.LocalAddress = local;
 			Assert.AreSame (group, option.Group, "#B1");
 			Assert.AreEqual (0, option.InterfaceIndex, "#B2");

+ 2 - 2
mcs/class/System/Test/System.Net.Sockets/SocketTest.cs

@@ -1850,7 +1850,7 @@ namespace MonoTests.System.Net.Sockets
 						    ProtocolType.Tcp);
 
 			// Need at least two addresses.
-			var ips = Dns.GetHostAddresses (string.Empty);
+			var ips = Dns.GetHostAddresses ("localhost");
 			if (ips.Length < 1)
 				Assert.Ignore ("This test needs at least two IP addresses.");
 
@@ -2352,7 +2352,7 @@ namespace MonoTests.System.Net.Sockets
 						    ProtocolType.Tcp);
 
 			// Need at least two addresses.
-			var ips = Dns.GetHostAddresses (string.Empty);
+			var ips = Dns.GetHostAddresses ("localhost");
 			if (ips.Length < 1)
 				Assert.Ignore ("This test needs at least two IP addresses.");
 

+ 2 - 2
mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs

@@ -872,7 +872,7 @@ namespace MonoTests.System.Net.Sockets {
 		public void JoinMulticastGroup4_Socket_NotBound ()
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
-			IPAddress local_addr = Dns.GetHostEntry (string.Empty).AddressList [0];
+			IPAddress local_addr = Dns.GetHostEntry ("localhost").AddressList [0];
 
 			using (UdpClient client = new UdpClient (AddressFamily.InterNetwork)) {
 				client.JoinMulticastGroup (mcast_addr, local_addr);
@@ -980,7 +980,7 @@ namespace MonoTests.System.Net.Sockets {
 						 "BeginSend #4");
 			}
 
-			IPAddress[] addresses = Dns.GetHostEntry (string.Empty).AddressList;
+			IPAddress[] addresses = Dns.GetHostEntry ("localhost").AddressList;
 			IPEndPoint ep = null;
 			foreach (IPAddress a in addresses) {
 				if (a.AddressFamily == AddressFamily.InterNetwork) {

+ 1 - 1
mcs/class/System/Test/System.Net/DnsTest.cs

@@ -565,7 +565,7 @@ namespace MonoTests.System.Net
 		[Test]
 		public void GetHostEntry_StringEmpty ()
 		{
-			Dns.GetHostEntry (string.Empty);
+			Dns.GetHostEntry ("localhost");
 		}
 
 		/* This isn't used anymore, but could be useful for debugging

+ 1 - 14
mcs/class/System/Test/System.Net/IPAddressTest.cs

@@ -329,7 +329,7 @@ public class IPAddressTest
 				Assert.Fail ("#1:" + i + " (" + ipAddress + ")");
 			} catch (FormatException ex) {
 				Assert.AreEqual (typeof (FormatException), ex.GetType (), "#2:" + i);
-				Assert.IsNull (ex.InnerException, "#3:" + i);
+				Assert.IsNotNull (ex.InnerException, "#3:" + i);
 				Assert.IsNotNull (ex.Message, "#4:" + i);
 			}
 		}
@@ -667,19 +667,6 @@ public class IPAddressTest
 		}
 
 	}
-
-	[Test]
-	[Category ("NotDotNet")]
-	public void UnixInterfaceNameAsZoneIndex ()
-	{
-		var ip = IPAddress.Parse ("fe80::bae8:56ff:fe47:af7e%en0");
-
-		// Should be en0 but it's of long type!
-		Assert.AreEqual (0, ip.ScopeId);
-		
-		Assert.AreEqual ("fe80::bae8:56ff:fe47:af7e", ip.ToString ());
-	}
-
 }
 }
 

+ 14 - 5
mcs/class/System/common.sources

@@ -189,7 +189,8 @@ System.Security.Cryptography.X509Certificates/X509Store.cs
 System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs
 ../../../external/corefx/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509SubjectKeyIdentifierHashAlgorithm.cs
 ../../../external/corefx/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509VerificationFlags.cs
-../../../external/corefx/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptographicOperations.cs
+../../../external/corefx/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/SubjectAlternativeNameBuilder.cs
+../../../external/corefx/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/GeneralNameEncoder.cs
 
 System.Threading/ThreadExceptionEventArgs.cs
 System.Threading/ThreadExceptionEventHandler.cs
@@ -563,8 +564,6 @@ ReferenceSources/Win32Exception.cs
 ../referencesource/System/compmod/system/diagnostics/traceutils.cs
 
 ../referencesource/System/net/System/_DomainName.cs
-../referencesource/System/net/System/_IPv4Address.cs
-../referencesource/System/net/System/_IPv6Address.cs
 ../referencesource/System/net/System/_UncName.cs
 ../referencesource/System/net/System/_UriSyntax.cs
 ../referencesource/System/net/System/GenericUriParser.cs
@@ -622,7 +621,17 @@ ReferenceSources/Win32Exception.cs
 ../referencesource/System/net/System/Net/ICredentials.cs
 ../referencesource/System/net/System/Net/ICredentialsByHost.cs
 ../referencesource/System/net/System/Net/Internal.cs
-../referencesource/System/net/System/Net/IPAddress.cs
+../../../external/corefx/src/Common/src/System/Net/IPAddressParserStatics.cs
+#../../../external/corefx/src/System.Net.Primitives/src/System/Net/IPAddressParser.cs
+#../../../external/corefx/src/Common/src/System/Net/IPv6AddressHelper.Common.cs
+# remove tmp dir once https://github.com/mono/mono/pull/12841 is merged
+corefx/tmp/IPAddressParser.cs
+corefx/tmp/IPv6AddressHelper.Common.cs
+
+../../../external/corefx/src/Common/src/System/Net/IPv4AddressHelper.Common.cs
+../../../external/corefx/src/System.Net.Primitives/src/System/Net/IPAddress.cs
+../../../external/corefx/src/System.Private.Uri/src/System/IPv4AddressHelper.cs
+../../../external/corefx/src/System.Private.Uri/src/System/IPv6AddressHelper.cs
 ../../../external/corefx/src/System.Net.Primitives/src/System/Net/IPEndPoint.cs
 ../../../external/corefx/src/Common/src/System/Net/TcpValidationHelpers.cs
 ../referencesource/System/net/System/Net/IPHostEntry.cs
@@ -771,6 +780,7 @@ ReferenceSources/Win32Exception.cs
 
 ../referencesource/System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs
 ../referencesource/System/services/monitoring/system/diagnosticts/Process.cs
+../../../external/corefx/src/Common/src/System/PasteArguments.cs
 ../referencesource/System/services/monitoring/system/diagnosticts/ProcessModuleCollection.cs
 ../referencesource/System/services/monitoring/system/diagnosticts/ProcessStartInfo.cs
 ../referencesource/System/services/monitoring/system/diagnosticts/processwaithandle.cs
@@ -871,7 +881,6 @@ ReferenceSources/Win32Exception.cs
 ../../../external/corefx/src/System.Runtime.Extensions/src/System/StringNormalizationExtensions.cs
 ../../../external/corefx/src/System.Diagnostics.StackTrace/src/System/Diagnostics/StackFrameExtensions.cs
 
-../../../external/corefx/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemName.cs
 ../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs
 
 # Everything except compiled

+ 319 - 0
mcs/class/System/corefx/tmp/IPAddressParser.cs

@@ -0,0 +1,319 @@
+// 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.Diagnostics;
+using System.IO;
+using System.Net.Sockets;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace System.Net
+{
+    internal class IPAddressParser
+    {
+        private const int MaxIPv4StringLength = 15; // 4 numbers separated by 3 periods, with up to 3 digits per number
+
+        internal static unsafe IPAddress Parse(ReadOnlySpan<char> ipSpan, bool tryParse)
+        {
+            if (ipSpan.Contains(':'))
+            {
+                // The address is parsed as IPv6 if and only if it contains a colon. This is valid because
+                // we don't support/parse a port specification at the end of an IPv4 address.
+                ushort* numbers = stackalloc ushort[IPAddressParserStatics.IPv6AddressShorts];
+                new Span<ushort>(numbers, IPAddressParserStatics.IPv6AddressShorts).Clear();
+                if (Ipv6StringToAddress(ipSpan, numbers, IPAddressParserStatics.IPv6AddressShorts, out uint scope))
+                {
+                    return new IPAddress(numbers, IPAddressParserStatics.IPv6AddressShorts, scope);
+                }
+            }
+            else if (Ipv4StringToAddress(ipSpan, out long address))
+            {
+                return new IPAddress(address);
+            }
+
+            if (tryParse)
+            {
+                return null;
+            }
+
+            throw new FormatException(SR.dns_bad_ip_address, new SocketException(SocketError.InvalidArgument));
+        }
+
+        internal static unsafe string IPv4AddressToString(uint address)
+        {
+            char* addressString = stackalloc char[MaxIPv4StringLength];
+            int charsWritten = IPv4AddressToStringHelper(address, addressString);
+            return new string(addressString, 0, charsWritten);
+        }
+
+        internal static unsafe void IPv4AddressToString(uint address, StringBuilder destination)
+        {
+            char* addressString = stackalloc char[MaxIPv4StringLength];
+            int charsWritten = IPv4AddressToStringHelper(address, addressString);
+            destination.Append(addressString, charsWritten);
+        }
+
+        internal static unsafe bool IPv4AddressToString(uint address, Span<char> formatted, out int charsWritten)
+        {
+            if (formatted.Length < MaxIPv4StringLength)
+            {
+                charsWritten = 0;
+                return false;
+            }
+
+            fixed (char* formattedPtr = &MemoryMarshal.GetReference(formatted))
+            {
+                charsWritten = IPv4AddressToStringHelper(address, formattedPtr);
+            }
+
+            return true;
+        }
+
+        private static unsafe int IPv4AddressToStringHelper(uint address, char* addressString)
+        {
+            int offset = 0;
+
+            FormatIPv4AddressNumber((int)(address & 0xFF), addressString, ref offset);
+            addressString[offset++] = '.';
+            FormatIPv4AddressNumber((int)((address >> 8) & 0xFF), addressString, ref offset);
+            addressString[offset++] = '.';
+            FormatIPv4AddressNumber((int)((address >> 16) & 0xFF), addressString, ref offset);
+            addressString[offset++] = '.';
+            FormatIPv4AddressNumber((int)((address >> 24) & 0xFF), addressString, ref offset);
+
+            return offset;
+        }
+
+        internal static string IPv6AddressToString(ushort[] address, uint scopeId)
+        {
+            Debug.Assert(address != null);
+            Debug.Assert(address.Length == IPAddressParserStatics.IPv6AddressShorts);
+
+            StringBuilder buffer = IPv6AddressToStringHelper(address, scopeId);
+
+            return StringBuilderCache.GetStringAndRelease(buffer);
+        }
+
+        internal static bool IPv6AddressToString(ushort[] address, uint scopeId, Span<char> destination, out int charsWritten)
+        {
+            Debug.Assert(address != null);
+            Debug.Assert(address.Length == IPAddressParserStatics.IPv6AddressShorts);
+
+            StringBuilder buffer = IPv6AddressToStringHelper(address, scopeId);
+
+            if (destination.Length < buffer.Length)
+            {
+                StringBuilderCache.Release(buffer);
+                charsWritten = 0;
+                return false;
+            }
+
+            buffer.CopyTo(0, destination, buffer.Length);
+            charsWritten = buffer.Length;
+
+            StringBuilderCache.Release(buffer);
+
+            return true;
+        }
+
+        internal static StringBuilder IPv6AddressToStringHelper(ushort[] address, uint scopeId)
+        { 
+            const int INET6_ADDRSTRLEN = 65;
+            StringBuilder buffer = StringBuilderCache.Acquire(INET6_ADDRSTRLEN);
+
+            if (IPv6AddressHelper.ShouldHaveIpv4Embedded(address))
+            {
+                // We need to treat the last 2 ushorts as a 4-byte IPv4 address,
+                // so output the first 6 ushorts normally, followed by the IPv4 address.
+                AppendSections(address, 0, 6, buffer);
+                if (buffer[buffer.Length - 1] != ':')
+                {
+                    buffer.Append(':');
+                }
+                IPv4AddressToString(ExtractIPv4Address(address), buffer);
+            }
+            else
+            {
+                // No IPv4 address.  Output all 8 sections as part of the IPv6 address
+                // with normal formatting rules.
+                AppendSections(address, 0, 8, buffer);
+            }
+
+            // If there's a scope ID, append it.
+            if (scopeId != 0)
+            {
+                buffer.Append('%').Append(scopeId);
+            }
+
+            return buffer;
+        }
+
+        private static unsafe void FormatIPv4AddressNumber(int number, char* addressString, ref int offset)
+        {
+            // Math.DivRem has no overload for byte, assert here for safety
+            Debug.Assert(number < 256);
+
+            offset += number > 99 ? 3 : number > 9 ? 2 : 1;
+
+            int i = offset;
+            do
+            {
+                number = Math.DivRem(number, 10, out int rem);
+                addressString[--i] = (char)('0' + rem);
+            } while (number != 0);
+        }
+
+        public static unsafe bool Ipv4StringToAddress(ReadOnlySpan<char> ipSpan, out long address)
+        {
+            int end = ipSpan.Length;
+            long tmpAddr;
+
+            fixed (char* ipStringPtr = &MemoryMarshal.GetReference(ipSpan))
+            {
+                tmpAddr = IPv4AddressHelper.ParseNonCanonical(ipStringPtr, 0, ref end, notImplicitFile: true);
+            }
+
+            if (tmpAddr != IPv4AddressHelper.Invalid && end == ipSpan.Length)
+            {
+                // IPv4AddressHelper.ParseNonCanonical returns the bytes in the inverse order.
+                // Reverse them and return success.
+                address =
+                    ((0xFF000000 & tmpAddr) >> 24) |
+                    ((0x00FF0000 & tmpAddr) >> 8) |
+                    ((0x0000FF00 & tmpAddr) << 8) |
+                    ((0x000000FF & tmpAddr) << 24);
+                return true;
+            }
+            else
+            {
+                // Failed to parse the address.
+                address = 0;
+                return false;
+            }
+        }
+
+        public static unsafe bool Ipv6StringToAddress(ReadOnlySpan<char> ipSpan, ushort* numbers, int numbersLength, out uint scope)
+        {
+            Debug.Assert(numbers != null);
+            Debug.Assert(numbersLength >= IPAddressParserStatics.IPv6AddressShorts);
+
+            int end = ipSpan.Length;
+
+            bool isValid = false;
+            fixed (char* ipStringPtr = &MemoryMarshal.GetReference(ipSpan))
+            {
+                isValid = IPv6AddressHelper.IsValidStrict(ipStringPtr, 0, ref end);
+            }
+            if (isValid || (end != ipSpan.Length))
+            {
+                string scopeId = null;
+                IPv6AddressHelper.Parse(ipSpan, numbers, 0, ref scopeId);
+
+                long result = 0;
+                if (!string.IsNullOrEmpty(scopeId))
+                {
+                    if (scopeId.Length < 2)
+                    {
+                        scope = 0;
+                        return false;
+                    }
+
+                    for (int i = 1; i < scopeId.Length; i++)
+                    {
+                        char c = scopeId[i];
+                        if (c < '0' || c > '9')
+                        {
+                            scope = 0;
+#if MONO // zoneId can be a string, see https://github.com/dotnet/corefx/issues/27529
+                            return true;
+#else
+                            return false;
+#endif
+                        }
+                        result = (result * 10) + (c - '0');
+                        if (result > uint.MaxValue)
+                        {
+                            scope = 0;
+                            return false;
+                        }
+                    }
+                }
+
+                scope = (uint)result;
+                return true;
+            }
+
+            scope = 0;
+            return false;
+        }
+
+        /// <summary>
+        /// Appends each of the numbers in address in indexed range [fromInclusive, toExclusive),
+        /// while also replacing the longest sequence of 0s found in that range with "::", as long
+        /// as the sequence is more than one 0.
+        /// </summary>
+        private static void AppendSections(ushort[] address, int fromInclusive, int toExclusive, StringBuilder buffer)
+        {
+            // Find the longest sequence of zeros to be combined into a "::"
+            ReadOnlySpan<ushort> addressSpan = new ReadOnlySpan<ushort>(address, fromInclusive, toExclusive - fromInclusive);
+            (int zeroStart, int zeroEnd) = IPv6AddressHelper.FindCompressionRange(addressSpan);
+            bool needsColon = false;
+
+            // Output all of the numbers before the zero sequence
+            for (int i = fromInclusive; i < zeroStart; i++)
+            {
+                if (needsColon)
+                {
+                    buffer.Append(':');
+                }
+                needsColon = true;
+                AppendHex(address[i], buffer);
+            }
+
+            // Output the zero sequence if there is one
+            if (zeroStart >= 0)
+            {
+                buffer.Append("::");
+                needsColon = false;
+                fromInclusive = zeroEnd;
+            }
+
+            // Output everything after the zero sequence
+            for (int i = fromInclusive; i < toExclusive; i++)
+            {
+                if (needsColon)
+                {
+                    buffer.Append(':');
+                }
+                needsColon = true;
+                AppendHex(address[i], buffer);
+            }
+        }
+
+        /// <summary>Appends a number as hexadecimal (without the leading "0x") to the StringBuilder.</summary>
+        private static unsafe void AppendHex(ushort value, StringBuilder buffer)
+        {
+            const int MaxLength = sizeof(ushort) * 2; // two hex chars per byte
+            char* chars = stackalloc char[MaxLength];
+            int pos = MaxLength;
+
+            do
+            {
+                int rem = value % 16;
+                value /= 16;
+                chars[--pos] = rem < 10 ? (char)('0' + rem) : (char)('a' + (rem - 10));
+                Debug.Assert(pos >= 0);
+            }
+            while (value != 0);
+
+            buffer.Append(chars + pos, MaxLength - pos);
+        }
+
+        /// <summary>Extracts the IPv4 address from the end of the IPv6 address byte array.</summary>
+        private static uint ExtractIPv4Address(ushort[] address) => (uint)(Reverse(address[7]) << 16) | Reverse(address[6]);
+
+        /// <summary>Reverses the two bytes in the ushort.</summary>
+        private static ushort Reverse(ushort number) => (ushort)(((number >> 8) & 0xFF) | ((number << 8) & 0xFF00));
+    }
+}

+ 415 - 0
mcs/class/System/corefx/tmp/IPv6AddressHelper.Common.cs

@@ -0,0 +1,415 @@
+// 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
+{
+    internal static partial class IPv6AddressHelper
+    {
+        private const int NumberOfLabels = 8;
+
+        // RFC 5952 Section 4.2.3
+        // Longest consecutive sequence of zero segments, minimum 2.
+        // On equal, first sequence wins. <-1, -1> for no compression.
+        internal unsafe static (int longestSequenceStart, int longestSequenceLength) FindCompressionRange(
+            ReadOnlySpan<ushort> numbers)
+        {
+            int longestSequenceLength = 0, longestSequenceStart = -1, currentSequenceLength = 0;
+
+            for (int i = 0; i < numbers.Length; i++)
+            {
+                if (numbers[i] == 0)
+                {
+                    currentSequenceLength++;
+                    if (currentSequenceLength > longestSequenceLength)
+                    {
+                        longestSequenceLength = currentSequenceLength;
+                        longestSequenceStart = i - currentSequenceLength + 1;
+                    }
+                }
+                else
+                {
+                    currentSequenceLength = 0;
+                }
+            }
+
+            return longestSequenceLength > 1 ?
+                (longestSequenceStart, longestSequenceStart + longestSequenceLength) :
+                (-1, -1);
+        }
+
+        // Returns true if the IPv6 address should be formatted with an embedded IPv4 address:
+        // ::192.168.1.1
+        internal unsafe static bool ShouldHaveIpv4Embedded(ReadOnlySpan<ushort> numbers)
+        {
+            // 0:0 : 0:0 : x:x : x.x.x.x
+            if (numbers[0] == 0 && numbers[1] == 0 && numbers[2] == 0 && numbers[3] == 0 && numbers[6] != 0)
+            {
+                // RFC 5952 Section 5 - 0:0 : 0:0 : 0:[0 | FFFF] : x.x.x.x
+                if (numbers[4] == 0 && (numbers[5] == 0 || numbers[5] == 0xFFFF))
+                {
+                    return true;
+                }
+                // SIIT - 0:0 : 0:0 : FFFF:0 : x.x.x.x
+                else if (numbers[4] == 0xFFFF && numbers[5] == 0)
+                {
+                    return true;
+                }
+            }
+
+            // ISATAP
+            return numbers[4] == 0 && numbers[5] == 0x5EFE;
+        }
+
+        //
+        // IsValidStrict
+        //
+        //  Determine whether a name is a valid IPv6 address. Rules are:
+        //
+        //   *  8 groups of 16-bit hex numbers, separated by ':'
+        //   *  a *single* run of zeros can be compressed using the symbol '::'
+        //   *  an optional string of a ScopeID delimited by '%'
+        //   *  the last 32 bits in an address can be represented as an IPv4 address
+        //
+        //  Difference between IsValid() and IsValidStrict() is that IsValid() expects part of the string to 
+        //  be ipv6 address where as IsValidStrict() expects strict ipv6 address.
+        //
+        // Inputs:
+        //  <argument>  name
+        //      IPv6 address in string format
+        //
+        // Outputs:
+        //  Nothing
+        //
+        // Assumes:
+        //  the correct name is terminated by  ']' character
+        //
+        // Returns:
+        //  true if <name> is IPv6  address, else false
+        //
+        // Throws:
+        //  Nothing
+        //
+
+        //  Remarks: MUST NOT be used unless all input indexes are verified and trusted.
+        //           start must be next to '[' position, or error is reported
+        internal unsafe static bool IsValidStrict(char* name, int start, ref int end)
+        {
+            int sequenceCount = 0;
+            int sequenceLength = 0;
+            bool haveCompressor = false;
+            bool haveIPv4Address = false;
+            bool expectingNumber = true;
+            int lastSequence = 1;
+
+            bool needsClosingBracket = false;
+            if (start < end && name[start] == '[')
+            {
+                start++;
+                needsClosingBracket = true;
+            }
+
+            int i;
+            for (i = start; i < end; ++i)
+            {
+                if (Uri.IsHexDigit(name[i]))
+                {
+                    ++sequenceLength;
+                    expectingNumber = false;
+                }
+                else
+                {
+                    if (sequenceLength > 4)
+                    {
+                        return false;
+                    }
+                    if (sequenceLength != 0)
+                    {
+                        ++sequenceCount;
+                        lastSequence = i - sequenceLength;
+                        sequenceLength = 0;
+                    }
+                    switch (name[i])
+                    {
+                        case '%':
+                            while (i + 1 < end)
+                            {
+                                i++;
+                                if (name[i] == ']')
+                                {
+                                    goto case ']';
+                                }
+                                else if (name[i] == '/')
+                                {
+                                    goto case '/';
+                                }
+#if !MONO // zoneId can be a string, see https://github.com/dotnet/corefx/issues/27529
+                                else if (name[i] < '0' || name[i] > '9')
+                                {
+                                    // scope ID must only contain digits
+                                    return false;
+                                }
+#endif
+                            }
+                            break;
+                        case ']':
+                            if (!needsClosingBracket)
+                            {
+                                return false;
+                            }
+                            needsClosingBracket = false;
+
+                            // If there's more after the closing bracket, it must be a port.
+                            // We don't use the port, but we still validate it.
+                            if (i + 1 < end && name[i + 1] != ':')
+                            {
+                                return false;
+                            }
+
+                            // If there is a port, it must either be a hexadecimal or decimal number.
+                            if (i + 3 < end && name[i + 2] == '0' && name[i + 3] == 'x')
+                            {
+                                i += 4;
+                                for (; i < end; i++)
+                                {
+                                    if (!Uri.IsHexDigit(name[i]))
+                                    {
+                                        return false;
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                i += 2;
+                                for (; i < end; i++)
+                                {
+                                    if (name[i] < '0' || name[i] > '9')
+                                    {
+                                        return false;
+                                    }
+                                }
+                            }
+                            continue;
+                        case ':':
+                            if ((i > 0) && (name[i - 1] == ':'))
+                            {
+                                if (haveCompressor)
+                                {
+                                    // can only have one per IPv6 address
+                                    return false;
+                                }
+                                haveCompressor = true;
+                                expectingNumber = false;
+                            }
+                            else
+                            {
+                                expectingNumber = true;
+                            }
+                            break;
+
+                        case '/':
+                            return false;
+
+                        case '.':
+                            if (haveIPv4Address)
+                            {
+                                return false;
+                            }
+
+                            i = end;
+                            if (!IPv4AddressHelper.IsValid(name, lastSequence, ref i, true, false, false))
+                            {
+                                return false;
+                            }
+                            // ipv4 address takes 2 slots in ipv6 address, one was just counted meeting the '.'
+                            ++sequenceCount;
+                            lastSequence = i - sequenceLength;
+                            sequenceLength = 0;
+                            haveIPv4Address = true;
+                            --i;            // it will be incremented back on the next loop
+                            break;
+
+                        default:
+                            return false;
+                    }
+                    sequenceLength = 0;
+                }
+            }
+
+            if (sequenceLength != 0)
+            {
+                if (sequenceLength > 4)
+                {
+                    return false;
+                }
+
+                ++sequenceCount;
+            }
+
+            // these sequence counts are -1 because it is implied in end-of-sequence
+
+            const int ExpectedSequenceCount = 8;
+            return
+                !expectingNumber &&
+                (haveCompressor ? (sequenceCount < ExpectedSequenceCount) : (sequenceCount == ExpectedSequenceCount)) &&
+                !needsClosingBracket;
+        }
+
+        //
+        // Parse
+        //
+        //  Convert this IPv6 address into a sequence of 8 16-bit numbers
+        //
+        // Inputs:
+        //  <member>    Name
+        //      The validated IPv6 address
+        //
+        // Outputs:
+        //  <member>    numbers
+        //      Array filled in with the numbers in the IPv6 groups
+        //
+        //  <member>    PrefixLength
+        //      Set to the number after the prefix separator (/) if found
+        //
+        // Assumes:
+        //  <Name> has been validated and contains only hex digits in groups of
+        //  16-bit numbers, the characters ':' and '/', and a possible IPv4
+        //  address
+        //
+        // Throws:
+        //  Nothing
+        //
+
+        internal static unsafe void Parse(ReadOnlySpan<char> address, ushort* numbers, int start, ref string scopeId)
+        {
+            int number = 0;
+            int index = 0;
+            int compressorIndex = -1;
+            bool numberIsValid = true;
+
+            //This used to be a class instance member but have not been used so far
+            int PrefixLength = 0;
+            if (address[start] == '[')
+            {
+                ++start;
+            }
+
+            for (int i = start; i < address.Length && address[i] != ']';)
+            {
+                switch (address[i])
+                {
+                    case '%':
+                        if (numberIsValid)
+                        {
+                            numbers[index++] = (ushort)number;
+                            numberIsValid = false;
+                        }
+
+                        start = i;
+                        for (++i; i < address.Length && address[i] != ']' && address[i] != '/'; ++i)
+                        {
+                        }
+                        scopeId = new string(address.Slice(start, i - start));
+                        // ignore prefix if any
+                        for (; i < address.Length && address[i] != ']'; ++i)
+                        {
+                        }
+                        break;
+
+                    case ':':
+                        numbers[index++] = (ushort)number;
+                        number = 0;
+                        ++i;
+                        if (address[i] == ':')
+                        {
+                            compressorIndex = index;
+                            ++i;
+                        }
+                        else if ((compressorIndex < 0) && (index < 6))
+                        {
+                            // no point checking for IPv4 address if we don't
+                            // have a compressor or we haven't seen 6 16-bit
+                            // numbers yet
+                            break;
+                        }
+
+                        // check to see if the upcoming number is really an IPv4
+                        // address. If it is, convert it to 2 ushort numbers
+                        for (int j = i; j < address.Length &&
+                                        (address[j] != ']') &&
+                                        (address[j] != ':') &&
+                                        (address[j] != '%') &&
+                                        (address[j] != '/') &&
+                                        (j < i + 4); ++j)
+                        {
+
+                            if (address[j] == '.')
+                            {
+                                // we have an IPv4 address. Find the end of it:
+                                // we know that since we have a valid IPv6
+                                // address, the only things that will terminate
+                                // the IPv4 address are the prefix delimiter '/'
+                                // or the end-of-string (which we conveniently
+                                // delimited with ']')
+                                while (j < address.Length && (address[j] != ']') && (address[j] != '/') && (address[j] != '%'))
+                                {
+                                    ++j;
+                                }
+                                number = IPv4AddressHelper.ParseHostNumber(address, i, j);
+                                numbers[index++] = (ushort)(number >> 16);
+                                numbers[index++] = (ushort)number;
+                                i = j;
+
+                                // set this to avoid adding another number to
+                                // the array if there's a prefix
+                                number = 0;
+                                numberIsValid = false;
+                                break;
+                            }
+                        }
+                        break;
+
+                    case '/':
+                        if (numberIsValid)
+                        {
+                            numbers[index++] = (ushort)number;
+                            numberIsValid = false;
+                        }
+
+                        // since we have a valid IPv6 address string, the prefix
+                        // length is the last token in the string
+                        for (++i; address[i] != ']'; ++i)
+                        {
+                            PrefixLength = PrefixLength * 10 + (address[i] - '0');
+                        }
+                        break;
+
+                    default:
+                        number = number * 16 + Uri.FromHex(address[i++]);
+                        break;
+                }
+            }
+
+            // add number to the array if its not the prefix length or part of
+            // an IPv4 address that's already been handled
+            if (numberIsValid)
+            {
+                numbers[index++] = (ushort)number;
+            }
+
+            // if we had a compressor sequence ("::") then we need to expand the
+            // numbers array
+            if (compressorIndex > 0)
+            {
+                int toIndex = NumberOfLabels - 1;
+                int fromIndex = index - 1;
+
+                for (int i = index - compressorIndex; i > 0; --i)
+                {
+                    numbers[toIndex--] = numbers[fromIndex];
+                    numbers[fromIndex--] = 0;
+                }
+            }
+        }
+    }
+}

+ 2 - 1
mcs/class/corlib/Makefile

@@ -59,7 +59,8 @@ RESX_RESOURCE_STRING = \
 	../../../external/corefx/src/System.ObjectModel/src/Resources/Strings.resx \
 	../../../external/corert/src/System.Private.CoreLib/src/Resources/Strings.resx \
 	../../../external/corefx/src/System.Private.Uri/src/Resources/Strings.resx	\
-	../../../external/corefx/src/Microsoft.Win32.Registry/src/Resources/Strings.resx
+	../../../external/corefx/src/Microsoft.Win32.Registry/src/Resources/Strings.resx \
+	../../../external/corefx/src/System.Security.Cryptography.Algorithms/src/Resources/Strings.resx
 
 LIBRARY_COMPILE = $(BOOT_COMPILE)
 LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)

+ 1 - 1
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs

@@ -144,7 +144,7 @@ namespace System.IO.IsolatedStorage {
 		}
 
 		// Methods
-		protected abstract IsolatedStoragePermission GetPermission (PermissionSet ps);
+		protected virtual IsolatedStoragePermission GetPermission (PermissionSet ps) => null;
 
 		protected void InitStore (IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
 		{

+ 1 - 1
mcs/class/corlib/System.IO/FileStream.cs

@@ -343,7 +343,7 @@ namespace System.IO
 			}
 		}
 
-		public string Name {
+		public virtual string Name {
 			get {
 				return name;
 			}

+ 1 - 3
mcs/class/corlib/System.IO/Path.cs

@@ -51,7 +51,7 @@ using System.Diagnostics;
 namespace System.IO {
 
 	[ComVisible (true)]
-	public static class Path {
+	public static partial class Path {
 
 		[Obsolete ("see GetInvalidPathChars and GetInvalidFileNameChars methods.")]
 		public static readonly char[] InvalidPathChars;
@@ -278,7 +278,6 @@ namespace System.IO {
 
 			return path;
 		}
-
 		public static string GetFileNameWithoutExtension (string path)
 		{
 			return ChangeExtension (GetFileName (path), null);
@@ -434,7 +433,6 @@ namespace System.IO {
 		internal static bool IsDirectorySeparator (char c) {
 			return c == DirectorySeparatorChar || c == AltDirectorySeparatorChar;
 		}
-
 		public static string GetPathRoot (string path)
 		{
 			if (path == null)

+ 185 - 0
mcs/class/corlib/System.IO/Path.ns21.cs

@@ -0,0 +1,185 @@
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+using System.Diagnostics;
+
+namespace System.IO
+{
+	partial class Path
+	{
+		public static ReadOnlySpan<char> GetExtension (ReadOnlySpan<char> path) => GetExtension (path.ToString ()).AsSpan ();
+
+		public static ReadOnlySpan<char> GetFileNameWithoutExtension (ReadOnlySpan<char> path) => GetFileNameWithoutExtension (path.ToString ()).AsSpan ();
+
+		public static ReadOnlySpan<char> GetPathRoot (ReadOnlySpan<char> path) => GetPathRoot (path.ToString ()).AsSpan ();
+
+		public static bool HasExtension (ReadOnlySpan<char> path) => HasExtension (path.ToString ());
+
+		public static string GetRelativePath(string relativeTo, string path)
+		{
+			return GetRelativePath(relativeTo, path, StringComparison);
+		}
+
+		private static string GetRelativePath(string relativeTo, string path, StringComparison comparisonType)
+		{
+			if (string.IsNullOrEmpty(relativeTo)) throw new ArgumentNullException(nameof(relativeTo));
+			if (PathInternal.IsEffectivelyEmpty(path.AsSpan())) throw new ArgumentNullException(nameof(path));
+			Debug.Assert(comparisonType == StringComparison.Ordinal || comparisonType == StringComparison.OrdinalIgnoreCase);
+
+			relativeTo = GetFullPath(relativeTo);
+			path = GetFullPath(path);
+
+			// Need to check if the roots are different- if they are we need to return the "to" path.
+			if (!PathInternal.AreRootsEqual(relativeTo, path, comparisonType))
+				return path;
+
+			int commonLength = PathInternal.GetCommonPathLength(relativeTo, path, ignoreCase: comparisonType == StringComparison.OrdinalIgnoreCase);
+
+			// If there is nothing in common they can't share the same root, return the "to" path as is.
+			if (commonLength == 0)
+				return path;
+
+			// Trailing separators aren't significant for comparison
+			int relativeToLength = relativeTo.Length;
+			if (PathInternal.EndsInDirectorySeparator(relativeTo.AsSpan()))
+				relativeToLength--;
+
+			bool pathEndsInSeparator = PathInternal.EndsInDirectorySeparator(path.AsSpan());
+			int pathLength = path.Length;
+			if (pathEndsInSeparator)
+				pathLength--;
+
+			// If we have effectively the same path, return "."
+			if (relativeToLength == pathLength && commonLength >= relativeToLength) return ".";
+
+			// We have the same root, we need to calculate the difference now using the
+			// common Length and Segment count past the length.
+			//
+			// Some examples:
+			//
+			//  C:\Foo C:\Bar L3, S1 -> ..\Bar
+			//  C:\Foo C:\Foo\Bar L6, S0 -> Bar
+			//  C:\Foo\Bar C:\Bar\Bar L3, S2 -> ..\..\Bar\Bar
+			//  C:\Foo\Foo C:\Foo\Bar L7, S1 -> ..\Bar
+
+			StringBuilder sb = StringBuilderCache.Acquire(Math.Max(relativeTo.Length, path.Length));
+
+			// Add parent segments for segments past the common on the "from" path
+			if (commonLength < relativeToLength)
+			{
+				sb.Append("..");
+
+				for (int i = commonLength + 1; i < relativeToLength; i++)
+				{
+					if (PathInternal.IsDirectorySeparator(relativeTo[i]))
+					{
+						sb.Append(DirectorySeparatorChar);
+						sb.Append("..");
+					}
+				}
+			}
+			else if (PathInternal.IsDirectorySeparator(path[commonLength]))
+			{
+				// No parent segments and we need to eat the initial separator
+				//  (C:\Foo C:\Foo\Bar case)
+				commonLength++;
+			}
+
+			// Now add the rest of the "to" path, adding back the trailing separator
+			int differenceLength = pathLength - commonLength;
+			if (pathEndsInSeparator)
+				differenceLength++;
+
+			if (differenceLength > 0)
+			{
+				if (sb.Length > 0)
+				{
+					sb.Append(DirectorySeparatorChar);
+				}
+
+				sb.Append(path, commonLength, differenceLength);
+			}
+
+			return StringBuilderCache.GetStringAndRelease(sb);
+		}
+
+		/// <summary>Returns a comparison that can be used to compare file and directory names for equality.</summary>
+		internal static StringComparison StringComparison
+		{
+			get
+			{
+				return IsCaseSensitive ?
+					StringComparison.Ordinal :
+					StringComparison.OrdinalIgnoreCase;
+			}
+		}
+
+		internal static bool IsCaseSensitive => !IsWindows;
+
+		static bool IsWindows
+		{
+			get
+			{
+				PlatformID platform = Environment.OSVersion.Platform;
+				if (platform == PlatformID.Win32S ||
+					platform == PlatformID.Win32Windows ||
+					platform == PlatformID.Win32NT ||
+					platform == PlatformID.WinCE) {
+					return true;
+				}
+				return false;
+			}
+		}
+
+		public static bool IsPathFullyQualified(string path)
+		{
+			if (path == null)
+				throw new ArgumentNullException(nameof(path));
+
+			return IsPathFullyQualified(path.AsSpan());
+		}
+
+		public static bool IsPathFullyQualified(ReadOnlySpan<char> path)
+		{
+			return !PathInternal.IsPartiallyQualified(path);
+		}
+
+		public static string GetFullPath(string path, string basePath)
+		{
+			if (path == null)
+				throw new ArgumentNullException(nameof(path));
+
+			if (basePath == null)
+				throw new ArgumentNullException(nameof(basePath));
+
+			if (!IsPathFullyQualified(basePath))
+				throw new ArgumentException(SR.Arg_BasePathNotFullyQualified, nameof(basePath));
+
+			if (basePath.Contains('\0') || path.Contains('\0'))
+				throw new ArgumentException(SR.Argument_InvalidPathChars);
+
+			if (IsPathFullyQualified(path))
+				return GetFullPath(path);
+
+			return GetFullPath(CombineInternal(basePath, path));
+		}
+
+		private static string CombineInternal(string first, string second)
+		{
+			if (string.IsNullOrEmpty(first))
+				return second;
+
+			if (string.IsNullOrEmpty(second))
+				return first;
+
+			if (IsPathRooted(second.AsSpan()))
+				return second;
+
+			return JoinInternal(first.AsSpan(), second.AsSpan());
+		}
+	}
+}

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/EventToken.cs

@@ -36,9 +36,9 @@ namespace System.Reflection.Emit {
 	/// </summary>
 	[ComVisible (true)]
 	[Serializable]
-	public struct EventToken {
+	public readonly struct EventToken : IEquatable<EventToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		public static readonly EventToken Empty = new EventToken ();
 

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/FieldToken.cs

@@ -36,9 +36,9 @@ namespace System.Reflection.Emit {
 	/// </summary>
 	[ComVisible (true)]
 	[Serializable]
-	public struct FieldToken {
+	public readonly struct FieldToken : IEquatable<FieldToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		public static readonly FieldToken Empty = new FieldToken ();
 

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/Label.cs

@@ -36,8 +36,8 @@ namespace System.Reflection.Emit {
 
 	[ComVisible (true)]
 	[Serializable]
-	public struct Label {
-		internal int label;
+	public readonly struct Label : IEquatable<Label> {
+		internal readonly int label;
 
 		internal Label (int val) {
 			label = val;

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/MethodToken.cs

@@ -36,9 +36,9 @@ namespace System.Reflection.Emit {
 	/// </summary>
 	[ComVisible (true)]
 	[Serializable]
-	public struct MethodToken {
+	public readonly struct MethodToken : IEquatable<MethodToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		public static readonly MethodToken Empty = new MethodToken ();
 

+ 3 - 3
mcs/class/corlib/System.Reflection.Emit/OpCode.cs

@@ -31,10 +31,10 @@ using System.Runtime.InteropServices;
 namespace System.Reflection.Emit {
 
 	[ComVisible (true)]
-	public struct OpCode {
+	public readonly struct OpCode : IEquatable<OpCode> {
 
-		internal byte op1, op2;
-		byte push, pop, size, type, args, flow;
+		internal readonly byte op1, op2;
+		readonly byte push, pop, size, type, args, flow;
 
 		//
 		// The order is:

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/ParameterToken.cs

@@ -36,9 +36,9 @@ namespace System.Reflection.Emit {
 	/// </summary>
 	[ComVisible (true)]
 	[Serializable]
-	public struct ParameterToken {
+	public readonly struct ParameterToken : IEquatable<ParameterToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		public static readonly ParameterToken Empty = new ParameterToken ();
 

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/PropertyToken.cs

@@ -36,9 +36,9 @@ namespace System.Reflection.Emit {
 	/// </summary>
 	[ComVisible (true)]
 	[Serializable]
-	public struct PropertyToken {
+	public readonly struct PropertyToken : IEquatable<PropertyToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		public static readonly PropertyToken Empty = new PropertyToken ();
 

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/SignatureToken.cs

@@ -35,9 +35,9 @@ namespace System.Reflection.Emit {
 	///  Represents the Token returned by the metadata to represent a Signature.
 	/// </summary>
 	[ComVisible (true)]
-	public struct SignatureToken {
+	public readonly struct SignatureToken : IEquatable<SignatureToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		public static readonly SignatureToken Empty = new SignatureToken ();
 

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/StringToken.cs

@@ -36,9 +36,9 @@ namespace System.Reflection.Emit {
 	/// </summary>
 	[ComVisible (true)]
 	[Serializable]
-	public struct StringToken {
+	public readonly struct StringToken : IEquatable<StringToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		internal StringToken (int val)
 		{

+ 2 - 2
mcs/class/corlib/System.Reflection.Emit/TypeToken.cs

@@ -36,9 +36,9 @@ namespace System.Reflection.Emit {
 	/// </summary>
 	[Serializable]
 	[ComVisible (true)]
-	public struct TypeToken {
+	public readonly struct TypeToken : IEquatable<TypeToken> {
 
-		internal int tokValue;
+		internal readonly int tokValue;
 
 		public static readonly TypeToken Empty = new TypeToken ();
 

+ 2 - 0
mcs/class/corlib/System.Reflection/Assembly.cs

@@ -791,5 +791,7 @@ namespace System.Reflection {
 		public virtual IEnumerable<CustomAttributeData> CustomAttributes {
 			get { return GetCustomAttributesData (); }
 		}
+
+		public virtual Type[] GetForwardedTypes() => throw new PlatformNotSupportedException();
 	}
 }

+ 24 - 0
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs

@@ -2019,5 +2019,29 @@ namespace System.Runtime.InteropServices
 
 			return result;
 		}
+
+		public static unsafe IntPtr StringToCoTaskMemUTF8(string s)
+		{
+			if (s == null)
+			{
+				return IntPtr.Zero;
+			}
+
+			int nb = Encoding.UTF8.GetMaxByteCount(s.Length);
+
+			IntPtr pMem = AllocCoTaskMem(nb + 1);
+
+			int nbWritten;
+			byte* pbMem = (byte*)pMem;
+
+			fixed (char* firstChar = s)
+			{
+				nbWritten = Encoding.UTF8.GetBytes(firstChar, s.Length, pbMem, nb);
+			}
+
+			pbMem[nbWritten] = 0;
+
+			return pMem;
+		}
 	}
 }

+ 2 - 0
mcs/class/corlib/System.Threading/Interlocked.cs

@@ -125,5 +125,7 @@ namespace System.Threading
 		public static void MemoryBarrier () {
 			Thread.MemoryBarrier ();
 		}
+
+		public static void MemoryBarrierProcessWide () => throw new PlatformNotSupportedException (); 
 	}
 }

+ 2 - 2
mcs/class/corlib/System/IntPtr.cs

@@ -51,9 +51,9 @@ namespace System
 {
 	[Serializable]
 	[System.Runtime.InteropServices.ComVisible (true)]
-	public unsafe struct IntPtr : ISerializable, IEquatable<IntPtr>
+	public unsafe readonly struct IntPtr : ISerializable, IEquatable<IntPtr>
 	{
-		private void *m_value;
+		private readonly void* m_value;
 
 		public static readonly IntPtr Zero;
 

+ 2 - 2
mcs/class/corlib/System/UIntPtr.cs

@@ -46,10 +46,10 @@ namespace System
 	[Serializable]
 	[CLSCompliant (false)]
 	[System.Runtime.InteropServices.ComVisible (true)]
-	public unsafe struct UIntPtr : ISerializable, IEquatable<UIntPtr>
+	public unsafe readonly struct UIntPtr : ISerializable, IEquatable<UIntPtr>
 	{
 		public static readonly UIntPtr Zero = new UIntPtr (0u);
-		private void* _pointer;
+		private readonly void* _pointer;
 	
 		public UIntPtr (ulong value)
 		{

+ 35 - 0
mcs/class/corlib/corefx/RandomNumberGenerator.cs

@@ -1,3 +1,5 @@
+using System.Buffers;
+
 namespace System.Security.Cryptography
 {
 	partial class RandomNumberGenerator
@@ -13,5 +15,38 @@ namespace System.Security.Cryptography
 				fixed (byte* ptr = data) Interop.GetRandomBytes (ptr, data.Length);
 			}
 		}
+
+		public virtual void GetBytes(Span<byte> data)
+		{
+			byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
+			try
+			{
+				GetBytes(array, 0, data.Length);
+				new ReadOnlySpan<byte>(array, 0, data.Length).CopyTo(data);
+			}
+			finally
+			{
+				Array.Clear(array, 0, data.Length);
+				ArrayPool<byte>.Shared.Return(array);
+			}
+		}
+
+		public virtual void GetNonZeroBytes(Span<byte> data)
+		{
+			byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
+			try
+			{
+				// NOTE: There is no GetNonZeroBytes(byte[], int, int) overload, so this call
+				// may end up retrieving more data than was intended, if the array pool
+				// gives back a larger array than was actually needed.
+				GetNonZeroBytes(array);
+				new ReadOnlySpan<byte>(array, 0, data.Length).CopyTo(data);
+			}
+			finally
+			{
+				Array.Clear(array, 0, data.Length);
+				ArrayPool<byte>.Shared.Return(array);
+			}
+		}
 	}
 }

+ 35 - 0
mcs/class/corlib/corefx/SR.cs

@@ -1537,4 +1537,39 @@ partial class SR
 	public const string Arg_PathIsVolume = "Path must not be a drive.";
 	public const string IO_FileCreateAlreadyExists = "Cannot create a file when that file already exists.";
 	public const string PlatformNotSupported_FileEncryption = "File encryption is not supported on this platform.";
+	public const string Cryptography_ArgECDHKeySizeMismatch = "The keys from both parties must be the same size to generate a secret agreement.";
+	public const string Cryptography_ArgECDHRequiresECDHKey = "Keys used with the ECDiffieHellmanCng algorithm must have an algorithm group of ECDiffieHellman.";
+	public const string Cryptography_TlsRequiresLabelAndSeed = "The TLS key derivation function requires both the label and seed properties to be set.";
+	public const string Cryptography_TlsRequires64ByteSeed = "The TLS key derivation function requires a seed value of exactly 64 bytes.";
+	public const string Cryptography_Config_EncodedOIDError = "Encoded OID length is too large (greater than 0x7f bytes).";
+	public const string Cryptography_ECXmlSerializationFormatRequired = "XML serialization of an elliptic curve key requires using an overload which specifies the XML format to be used.";
+	public const string Cryptography_InvalidCurveOid = "The specified Oid is not valid. The Oid.FriendlyName or Oid.Value property must be set.";
+	public const string Cryptography_InvalidCurveKeyParameters = "The specified key parameters are not valid. Q.X and Q.Y are required fields. Q.X, Q.Y must be the same length. If D is specified it must be the same length as Q.X and Q.Y for named curves or the same length as Order for explicit curves.";
+	public const string Cryptography_InvalidECCharacteristic2Curve = "The specified Characteristic2 curve parameters are not valid. Polynomial, A, B, G.X, G.Y, and Order are required. A, B, G.X, G.Y must be the same length, and the same length as Q.X, Q.Y and D if those are specified. Seed, Cofactor and Hash are optional. Other parameters are not allowed.";
+	public const string Cryptography_InvalidECPrimeCurve = "The specified prime curve parameters are not valid. Prime, A, B, G.X, G.Y and Order are required and must be the same length, and the same length as Q.X, Q.Y and D if those are specified. Seed, Cofactor and Hash are optional. Other parameters are not allowed.";
+	public const string Cryptography_InvalidECNamedCurve = "The specified named curve parameters are not valid. Only the Oid parameter must be set.";
+	public const string Cryptography_InvalidKey_SemiWeak = "Specified key is a known semi-weak key for '{0}' and cannot be used.";
+	public const string Cryptography_InvalidKey_Weak = "Specified key is a known weak key for '{0}' and cannot be used.";
+	public const string Cryptography_InvalidOperation = "This operation is not supported for this class.";
+	public const string Cryptography_InvalidPadding = "Padding is invalid and cannot be removed.";
+	public const string Cryptography_MissingIV = "The cipher mode specified requires that an initialization vector (IV) be used.";
+	public const string Cryptography_MissingKey = "No asymmetric key object has been associated with this formatter object.";
+	public const string Cryptography_MissingOID = "Required object identifier (OID) cannot be found.";
+	public const string Cryptography_MustTransformWholeBlock = "TransformBlock may only process bytes in block sized increments.";
+	public const string Cryptography_NotValidPrivateKey = "Key is not a valid private key.";
+	public const string Cryptography_NotValidPublicOrPrivateKey = "Key is not a valid public or private key.";
+	public const string Cryptography_PartialBlock = "The input data is not a complete block.";
+	public const string Cryptography_PasswordDerivedBytes_FewBytesSalt = "Salt is not at least eight bytes.";
+	public const string Cryptography_RC2_EKS40 = "EffectiveKeySize value must be at least 40 bits.";
+	public const string Cryptography_RC2_EKSKS = "KeySize value must be at least as large as the EffectiveKeySize value.";
+	public const string Cryptography_RC2_EKSKS2 = "EffectiveKeySize must be the same as KeySize in this implementation.";
+	public const string Cryptography_Rijndael_BlockSize = "BlockSize must be 128 in this implementation.";
+	public const string Cryptography_TransformBeyondEndOfBuffer = "Attempt to transform beyond end of buffer.";
+	public const string Cryptography_CipherModeNotSupported = "The specified CipherMode '{0}' is not supported.";
+	public const string Cryptography_UnknownPaddingMode = "Unknown padding mode used.";
+	public const string Cryptography_UnexpectedTransformTruncation = "CNG provider unexpectedly terminated encryption or decryption prematurely.";
+	public const string Cryptography_UnsupportedPaddingMode = "The specified PaddingMode is not supported.";
+	public const string NotSupported_Method = "Method not supported.";
+	public const string Cryptography_AlgorithmTypesMustBeVisible = "Algorithms added to CryptoConfig must be accessable from outside their assembly.";
+	public const string Cryptography_AddNullOrEmptyName = "CryptoConfig cannot add a mapping for a null or empty name.";
 }

+ 20 - 0
mcs/class/corlib/corefx/Stream.cs

@@ -0,0 +1,20 @@
+using System.Threading.Tasks;
+
+namespace System.IO
+{
+    partial class Stream
+    {
+        public virtual ValueTask DisposeAsync()
+        {
+            try
+            {
+                Dispose();
+                return default;
+            }
+            catch (Exception exc)
+            {
+                return new ValueTask(Task.FromException(exc));
+            }
+        }
+    }
+}

+ 8 - 3
mcs/class/corlib/corlib.csproj

@@ -696,6 +696,7 @@
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\NotImplemented.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Text\ValueUtf8Converter.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Threading\Tasks\BeginEndAwaitableAdapter.cs" />
+    <Compile Include="..\..\..\external\corefx\src\Common\src\System\Threading\Tasks\ForceAsyncAwaiter.cs" />
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Threading\Tasks\RendezvousAwaitable.cs" />
     <Compile Include="..\..\..\external\corefx\src\Microsoft.Win32.Registry\src\Microsoft\Win32\RegistryHive.cs" />
     <Compile Include="..\..\..\external\corefx\src\Microsoft.Win32.Registry\src\Microsoft\Win32\RegistryKeyPermissionCheck.cs" />
@@ -882,10 +883,15 @@
     <Compile Include="..\..\..\external\corefx\src\System.Security.AccessControl\src\System\Security\AccessControl\PrivilegeNotHeldException.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Claims\src\System\Security\Claims\ClaimTypes.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Claims\src\System\Security\Claims\GenericIdentity.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Algorithms\src\Internal\Cryptography\Helpers.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Algorithms\src\System\Security\Cryptography\Rfc2898DeriveBytes.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Csp\src\System\Security\Cryptography\ICspAsymmetricAlgorithm.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Csp\src\System\Security\Cryptography\KeyNumber.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\CryptoStream.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\CryptoStreamMode.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\CryptographicOperations.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HashAlgorithm.cs" />
+    <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HashAlgorithmName.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\ErrorCode.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Helpers.cs" />
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\Microsoft\Win32\SafeHandles\SafePasswordHandle.cs" />
@@ -1201,7 +1207,6 @@
     <Compile Include="..\referencesource\mscorlib\system\security\claims\ClaimsIdentity.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\claims\ClaimsPrincipal.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\claims\RoleClaimProvider.cs" />
-    <Compile Include="..\referencesource\mscorlib\system\security\cryptography\HashAlgorithmName.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\RSAEncryptionPadding.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\RSAEncryptionPaddingMode.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\RSASignaturePadding.cs" />
@@ -1215,7 +1220,6 @@
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\base64transforms.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\crypto.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\cryptoapitransform.cs" />
-    <Compile Include="..\referencesource\mscorlib\system\security\cryptography\cryptostream.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\derivebytes.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\des.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\dsa.cs" />
@@ -1237,7 +1241,6 @@
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\pkcs1maskgenerationmethod.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\randomnumbergenerator.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\rc2.cs" />
-    <Compile Include="..\referencesource\mscorlib\system\security\cryptography\rfc2898derivebytes.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\rijndael.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\rijndaelmanagedtransform.cs" />
     <Compile Include="..\referencesource\mscorlib\system\security\cryptography\ripemd160.cs" />
@@ -1405,6 +1408,7 @@
     <Compile Include="System.IO\MonoIOError.cs" />
     <Compile Include="System.IO\MonoIOStat.cs" />
     <Compile Include="System.IO\Path.cs" />
+    <Compile Include="System.IO\Path.ns21.cs" />
     <Compile Include="System.IO\SearchPattern.cs" />
     <Compile Include="System.IO\UnexceptionalStreamReader.cs" />
     <Compile Include="System.IO\UnexceptionalStreamWriter.cs" />
@@ -2045,6 +2049,7 @@
     <Compile Include="corefx\RuntimeImports.cs" />
     <Compile Include="corefx\SR.cs" />
     <Compile Include="corefx\SR.missing.cs" />
+    <Compile Include="corefx\Stream.cs" />
     <Compile Include="corefx\SynchronizationContext.cs" />
     <Compile Include="corefx\TimeSpanParse.cs" />
     <Compile Include="corefx\TimeZone.cs" />

+ 8 - 3
mcs/class/corlib/corlib.dll.sources

@@ -216,6 +216,7 @@ System.IO/MonoIOError.cs
 System.IO/MonoFileType.cs
 System.IO/MonoIOStat.cs
 System.IO/Path.cs
+System.IO/Path.ns21.cs
 ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/SearchOption.cs
 System.IO/SearchPattern.cs
 ../../../external/corefx/src/Common/src/CoreLib/System/IO/SeekOrigin.cs
@@ -1143,6 +1144,7 @@ ReferenceSources/AppContextDefaultValues.cs
 ../../../external/corefx/src/Common/src/CoreLib/System/IO/MemoryStream.cs
 ../../../external/corefx/src/Common/src/CoreLib/System/IO/PathTooLongException.cs
 ../../../external/corefx/src/Common/src/CoreLib/System/IO/PinnedBufferMemoryStream.cs
+corefx/Stream.cs
 ../../../external/corert/src/System.Private.CoreLib/shared/System/IO/Stream.cs
 ../../../external/corert/src/System.Private.CoreLib/src/System/IO/Stream.CoreRT.cs
 ../../../external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs
@@ -1392,7 +1394,9 @@ ReferenceSources/AppContextDefaultValues.cs
 ../referencesource/mscorlib/system/security/cryptography/base64transforms.cs
 ../referencesource/mscorlib/system/security/cryptography/crypto.cs
 ../referencesource/mscorlib/system/security/cryptography/cryptoapitransform.cs
-../referencesource/mscorlib/system/security/cryptography/cryptostream.cs
+../../../external/corefx/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptoStreamMode.cs
+../../../external/corefx/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptoStream.cs
+../../../external/corefx/src/Common/src/System/Threading/Tasks/ForceAsyncAwaiter.cs
 ../referencesource/mscorlib/system/security/cryptography/derivebytes.cs
 ../referencesource/mscorlib/system/security/cryptography/des.cs
 ../referencesource/mscorlib/system/security/cryptography/descryptoserviceprovider.cs
@@ -1401,7 +1405,7 @@ ReferenceSources/AppContextDefaultValues.cs
 ../referencesource/mscorlib/system/security/cryptography/dsasignatureformatter.cs
 ../../../external/corefx/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs
 ../../../external/corefx/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptographicOperations.cs
-../referencesource/mscorlib/system/security/cryptography/HashAlgorithmName.cs
+../../../external/corefx/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithmName.cs
 ../referencesource/mscorlib/system/security/cryptography/hmac.cs
 ../referencesource/mscorlib/system/security/cryptography/hmacmd5.cs
 ../referencesource/mscorlib/system/security/cryptography/hmacripemd160.cs
@@ -1419,7 +1423,8 @@ ReferenceSources/AppContextDefaultValues.cs
 ../referencesource/mscorlib/system/security/cryptography/randomnumbergenerator.cs
 ../referencesource/mscorlib/system/security/cryptography/rc2.cs
 ../referencesource/mscorlib/system/security/cryptography/rc2cryptoserviceprovider.cs
-../referencesource/mscorlib/system/security/cryptography/rfc2898derivebytes.cs
+../../../external/corefx/src/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/Helpers.cs
+../../../external/corefx/src/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.cs
 ../referencesource/mscorlib/system/security/cryptography/rijndael.cs
 ../referencesource/mscorlib/system/security/cryptography/rijndaelmanaged.cs
 ../referencesource/mscorlib/system/security/cryptography/rijndaelmanagedtransform.cs

+ 93 - 0
mcs/class/referencesource/System.Core/System/Security/Cryptography/ECDsa.cs

@@ -6,6 +6,9 @@
 
 using System;
 using System.IO;
+#if MONO
+using System.Buffers;
+#endif
 
 namespace System.Security.Cryptography {
     /// <summary>
@@ -217,5 +220,95 @@ namespace System.Security.Cryptography {
         internal static Exception HashAlgorithmNameNullOrEmpty() {
             return new ArgumentException(SR.GetString(SR.Cryptography_HashAlgorithmNameNullOrEmpty), "hashAlgorithm");
         }
+
+#if MONO // these methods were copied from CoreFX for NS2.1 support
+        protected virtual bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
+        {
+            byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
+            try
+            {
+                data.CopyTo(array);
+                byte[] hash = HashData(array, 0, data.Length, hashAlgorithm);
+                if (hash.Length <= destination.Length)
+                {
+                    new ReadOnlySpan<byte>(hash).CopyTo(destination);
+                    bytesWritten = hash.Length;
+                    return true;
+                }
+                else
+                {
+                    bytesWritten = 0;
+                    return false;
+                }
+            }
+            finally
+            {
+                Array.Clear(array, 0, data.Length);
+                ArrayPool<byte>.Shared.Return(array);
+            }
+        }
+
+        public virtual bool TrySignHash(ReadOnlySpan<byte> hash, Span<byte> destination, out int bytesWritten)
+        {
+            byte[] result = SignHash(hash.ToArray());
+            if (result.Length <= destination.Length)
+            {
+                new ReadOnlySpan<byte>(result).CopyTo(destination);
+                bytesWritten = result.Length;
+                return true;
+            }
+            else
+            {
+                bytesWritten = 0;
+                return false;
+            }
+        }
+
+        public virtual bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature) =>
+            VerifyHash(hash.ToArray(), signature.ToArray());
+
+        public virtual bool TrySignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
+        {
+            if (string.IsNullOrEmpty(hashAlgorithm.Name))
+            {
+                throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
+            }
+
+            if (TryHashData(data, destination, hashAlgorithm, out int hashLength) &&
+                TrySignHash(destination.Slice(0, hashLength), destination, out bytesWritten))
+            {
+                return true;
+            }
+
+            bytesWritten = 0;
+            return false;
+        }
+
+        public virtual bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm)
+        {
+            if (string.IsNullOrEmpty(hashAlgorithm.Name))
+            {
+                throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
+            }
+
+            for (int i = 256; ; i = checked(i * 2))
+            {
+                int hashLength = 0;
+                byte[] hash = ArrayPool<byte>.Shared.Rent(i);
+                try
+                {
+                    if (TryHashData(data, hash, hashAlgorithm, out hashLength))
+                    {
+                        return VerifyHash(new ReadOnlySpan<byte>(hash, 0, hashLength), signature);
+                    }
+                }
+                finally
+                {
+                    Array.Clear(hash, 0, hashLength);
+                    ArrayPool<byte>.Shared.Return(hash);
+                }
+            }
+        }
+#endif
     }
 }

+ 14 - 3
mcs/class/referencesource/System.Data/System/Data/Common/DbProviderFactories.cs

@@ -35,9 +35,11 @@ namespace System.Data.Common {
         private static DataTable _providerTable;
         private static object _lockobj = new object();
 
-        static public DbProviderFactory GetFactory(string providerInvariantName) {
-            ADP.CheckArgumentLength(providerInvariantName, "providerInvariantName");
+        static public DbProviderFactory GetFactory(string providerInvariantName) => GetFactory(providerInvariantName, true);
 
+        static public DbProviderFactory GetFactory(string providerInvariantName, bool throwOnError) {
+            if (throwOnError)
+                ADP.CheckArgumentLength(providerInvariantName, "providerInvariantName");
             // NOTES: Include the Framework Providers and any other Providers listed in the config file.
             DataTable providerTable = GetProviderTable();
             if (null != providerTable) {
@@ -54,7 +56,10 @@ namespace System.Data.Common {
                     return DbProviderFactories.GetFactory(providerRow);
                 }
             }
-            throw ADP.ConfigProviderNotFound();
+
+            if (throwOnError)
+                throw ADP.ConfigProviderNotFound();
+            return null;
         }
 
         static public DbProviderFactory GetFactory(DataRow providerRow) {
@@ -258,6 +263,12 @@ namespace System.Data.Common {
         }
 
 #if MONO
+        public static bool TryGetFactory(string providerInvariantName, out DbProviderFactory factory)
+        {
+            factory = GetFactory(providerInvariantName, throwOnError: false);
+            return factory != null;
+        }
+
         public static IEnumerable<string> GetProviderInvariantNames()
         {
             return _registeredFactories.Keys.ToList();

+ 1 - 1
mcs/class/referencesource/System.Data/System/Data/DataSysAttribute.cs

@@ -20,7 +20,7 @@ namespace System.Data {
     ///    </para>
     /// </devdoc>
     [AttributeUsage(AttributeTargets.All)]
-    [ Obsolete("DataSysDescriptionAttribute has been deprecated.  http://go.microsoft.com/fwlink/?linkid=14202", false) ]
+    [Obsolete("DataSysDescriptionAttribute has been deprecated.  https://go.microsoft.com/fwlink/?linkid=14202", false) ]
     public class DataSysDescriptionAttribute : DescriptionAttribute {
 
         private bool replaced = false;

+ 1 - 1
mcs/class/referencesource/System.Xml/System/Xml/Core/XmlValidatingReader.cs

@@ -16,7 +16,7 @@ using System.Security.Permissions;
 namespace System.Xml
 {
     [PermissionSetAttribute( SecurityAction.InheritanceDemand, Name = "FullTrust" )]
-    [Obsolete("Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+    [Obsolete("Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. https://go.microsoft.com/fwlink/?linkid=14202")]
     public class XmlValidatingReader : XmlReader, IXmlLineInfo, IXmlNamespaceResolver {
 //
 // Member fields

+ 1 - 1
mcs/class/referencesource/System.Xml/System/Xml/Schema/XmlSchemaCollection.cs

@@ -24,7 +24,7 @@ namespace System.Xml.Schema {
     ///       The Validate method then uses this internal representation for
     ///       efficient runtime validation of any given subtree.</para>
     /// </devdoc>
-    [Obsolete("Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")]
+    [Obsolete("Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. https://go.microsoft.com/fwlink/?linkid=14202")]
     public sealed class XmlSchemaCollection: ICollection {
         private Hashtable               collection;
         private XmlNameTable            nameTable;

+ 1 - 1
mcs/class/referencesource/System.Xml/System/Xml/Serialization/XmlAnyAttributeAttribute.cs

@@ -13,7 +13,7 @@ namespace System.Xml.Serialization {
     /// <devdoc>
     ///    <para>[To be supplied.]</para>
     /// </devdoc>
-    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=false)]
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
     public class XmlAnyAttributeAttribute : System.Attribute {
 
         /// <include file='doc\XmlAnyAttributeAttribute.uex' path='docs/doc[@for="XmlAnyAttributeAttribute.XmlAnyAttributeAttribute"]/*' />

+ 1 - 1
mcs/class/referencesource/System.Xml/System/Xml/Serialization/XmlNamespaceDeclarationsAttribute.cs

@@ -13,7 +13,7 @@ namespace System.Xml.Serialization {
     /// <devdoc>
     ///    <para>[To be supplied.]</para>
     /// </devdoc>
-    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=false)]
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
     public class XmlNamespaceDeclarationsAttribute : System.Attribute {
 
         /// <include file='doc\XmlNamespaceDeclarationsAttribute.uex' path='docs/doc[@for="XmlNamespaceDeclarationsAttribute.XmlNamespaceDeclarationsAttribute"]/*' />

+ 1 - 1
mcs/class/referencesource/System/net/System/Net/GlobalProxySelection.cs

@@ -6,7 +6,7 @@
 
 namespace System.Net
 {
-    [Obsolete("This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. http://go.microsoft.com/fwlink/?linkid=14202")]
+    [Obsolete("This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. https://go.microsoft.com/fwlink/?linkid=14202")]
     public class GlobalProxySelection
     {
         // This just wraps WebRequest.DefaultWebProxy and modifies it to be compatible with Everett.

+ 8 - 0
mcs/class/referencesource/System/net/System/Net/SocketAddress.cs

@@ -160,10 +160,14 @@ namespace System.Net {
                 }
             } else {
                 // IPv4 Address serialization
+#if MONO
+                ipAddress.TryWriteBytes(m_Buffer.AsSpan(4), out int bytesWritten);
+#else
                 m_Buffer[4] = unchecked((byte)(ipAddress.m_Address));
                 m_Buffer[5] = unchecked((byte)(ipAddress.m_Address >> 8));
                 m_Buffer[6] = unchecked((byte)(ipAddress.m_Address >> 16));
                 m_Buffer[7] = unchecked((byte)(ipAddress.m_Address >> 24));
+#endif
             }
         }
 
@@ -177,7 +181,11 @@ namespace System.Net {
             if (Family == AddressFamily.InterNetworkV6) {
                 Contract.Assert(Size >= IPv6AddressSize);
 
+#if MONO
+                byte[] address = new byte[IPAddressParserStatics.IPv6AddressBytes];
+#else
                 byte[] address = new byte[IPAddress.IPv6AddressBytes];
+#endif
                 for (int i = 0; i < address.Length; i++) {
                     address[i] = m_Buffer[i + 8];
                 }

+ 13 - 1
mcs/class/referencesource/System/net/System/Net/Sockets/UDPClient.cs

@@ -488,7 +488,7 @@ namespace System.Net.Sockets {
             // if the user really wants complete control over Broadcast addresses he needs to
             // inherit from UdpClient and gain control over the Socket and do whatever is appropriate.
             //
-            if (Client!=null && !m_IsBroadcast && ipAddress.IsBroadcast) {
+            if (Client!=null && !m_IsBroadcast && IsBroadcast(ipAddress)) {
                 //
                 // we need to set the Broadcast socket option.
                 // note that, once we set the option on the Socket, we never reset it.
@@ -498,6 +498,18 @@ namespace System.Net.Sockets {
             }
         }
 
+        private static bool IsBroadcast(IPAddress address)
+        {
+            if (address.AddressFamily == AddressFamily.InterNetworkV6)
+            {
+                // No such thing as a broadcast address for IPv6.
+                return false;
+            }
+            else
+            {
+                return address.Equals(IPAddress.Broadcast);
+            }
+        }
 
 
         /// <devdoc>

+ 16 - 1
mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs

@@ -23,6 +23,8 @@ namespace System.Diagnostics {
     using Microsoft.Win32;        
     using Microsoft.Win32.SafeHandles;
     using System.Collections.Specialized;
+    using System.Collections;
+    using System.Collections.Generic;
     using System.Globalization;
     using System.Security;
     using System.Security.Permissions;
@@ -2100,6 +2102,9 @@ namespace System.Diagnostics {
                 throw new InvalidOperationException(SR.GetString(SR.StandardErrorEncodingNotAllowed));
             }            
             
+            if (!string.IsNullOrEmpty(startInfo.Arguments) && startInfo.ArgumentList.Count > 0)
+                throw new InvalidOperationException(SR.ArgumentAndArgumentListInitialized);
+
             // See knowledge base article Q190351 for an explanation of the following code.  Noteworthy tricky points:
             //    * The handles are duplicated as non-inheritable before they are passed to CreateProcess so
             //      that the child process can not close them
@@ -2111,7 +2116,17 @@ namespace System.Diagnostics {
                 throw new ObjectDisposedException(GetType().Name);
             }
 
-            StringBuilder commandLine = BuildCommandLine(startInfo.FileName, startInfo.Arguments);
+            string arguments;
+            if (startInfo.ArgumentList.Count > 0) {
+                StringBuilder sb = new StringBuilder ();
+                Process.AppendArguments (sb, startInfo.ArgumentList);
+                arguments = sb.ToString ();
+            }
+            else {
+                arguments = startInfo.Arguments;
+            }
+
+            StringBuilder commandLine = BuildCommandLine(startInfo.FileName, arguments);
 
             NativeMethods.STARTUPINFO startupInfo = new NativeMethods.STARTUPINFO();
             SafeNativeMethods.PROCESS_INFORMATION processInfo = new SafeNativeMethods.PROCESS_INFORMATION();

+ 1 - 1
mcs/class/referencesource/System/sys/system/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs

@@ -8,7 +8,7 @@ namespace System.Diagnostics.CodeAnalysis
     /// enclosed methods and properties from code coverage collection.
     /// </summary>
     [AttributeUsage(
-        AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event,
+        AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Struct,
         Inherited = false,
         AllowMultiple = false
     )]

+ 14 - 0
mcs/class/referencesource/mscorlib/system/io/binaryreader.cs

@@ -511,6 +511,20 @@ namespace System.IO {
             return chars;
         }
 
+#if MONO
+        public virtual int Read(Span<char> buffer)
+        {
+            char[] bufferBytes = buffer.ToArray();
+            return Read(bufferBytes, 0, bufferBytes.Length);
+        }
+
+        public virtual int Read(Span<byte> buffer)
+        {
+            byte[] bufferBytes = buffer.ToArray();
+            return Read(bufferBytes, 0, bufferBytes.Length);
+        }
+#endif
+
         public virtual int Read(byte[] buffer, int index, int count) {
             if (buffer==null)
                 throw new ArgumentNullException("buffer", Environment.GetResourceString("ArgumentNull_Buffer"));

+ 40 - 0
mcs/class/referencesource/mscorlib/system/io/binarywriter.cs

@@ -20,6 +20,7 @@ using System.Runtime;
 using System.Runtime.Serialization;
 using System.Text;
 using System.Diagnostics.Contracts;
+using System.Threading.Tasks;
 
 namespace System.IO {
     // This abstract base class represents a writer that can write
@@ -135,6 +136,45 @@ namespace System.IO {
         {
             return OutStream.Seek(offset, origin);
         }
+
+#if MONO
+        public virtual void Write(ReadOnlySpan<byte> buffer)
+        {
+            Write(buffer.ToArray());
+        }
+
+        public virtual void Write(ReadOnlySpan<char> buffer)
+        {
+            Write(buffer.ToArray());
+        }
+
+        public virtual ValueTask DisposeAsync()
+        {
+            try
+            {
+                if (GetType() == typeof(BinaryWriter))
+                {
+                    if (_leaveOpen)
+                    {
+                        return new ValueTask(OutStream.FlushAsync());
+                    }
+
+                    OutStream.Close();
+                }
+                else
+                {
+                    // Since this is a derived BinaryWriter, delegate to whatever logic
+                    // the derived implementation already has in Dispose.
+                    Dispose();
+                }
+                return default;
+            }
+            catch (Exception exc)
+            {
+                return new ValueTask(Task.FromException(exc));
+            }
+        }
+#endif
         
         // Writes a boolean to this stream. A single byte is written to the stream
         // with the value 0 representing false or the value 1 representing true.

+ 1 - 1
mcs/class/referencesource/mscorlib/system/reflection/emit/methodbuilder.cs

@@ -1403,7 +1403,7 @@ namespace System.Reflection.Emit
     /// </summary>
     [StructLayout(LayoutKind.Sequential)]
     [ComVisible(false)]
-    public struct ExceptionHandler : IEquatable<ExceptionHandler>
+    public readonly struct ExceptionHandler : IEquatable<ExceptionHandler>
     {
         // Keep in sync with unmanged structure. 
         internal readonly int m_exceptionClass;

+ 1 - 1
mcs/class/referencesource/mscorlib/system/runtime/interopservices/attributes.cs

@@ -1148,7 +1148,7 @@ namespace System.Runtime.InteropServices{
         }
     }
 
-    [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
+    [AttributeUsage(AttributeTargets.Method, Inherited=false)]
     [System.Runtime.InteropServices.ComVisible(false)]
     public sealed class ManagedToNativeComInteropStubAttribute : Attribute
     {

+ 3 - 3
mcs/class/referencesource/mscorlib/system/runtime/serialization/streamingcontext.cs

@@ -18,9 +18,9 @@ namespace System.Runtime.Serialization {
     using System;
     [Serializable]
 [System.Runtime.InteropServices.ComVisible(true)]
-    public struct StreamingContext {
-        internal Object m_additionalContext;
-        internal StreamingContextStates m_state;
+    public readonly struct StreamingContext {
+        internal readonly Object m_additionalContext;
+        internal readonly StreamingContextStates m_state;
     
         public StreamingContext(StreamingContextStates state) 
             : this (state, null) {

+ 126 - 0
mcs/class/referencesource/mscorlib/system/security/cryptography/dsa.cs

@@ -16,6 +16,9 @@ namespace System.Security.Cryptography {
     using System.Security.Util;
     using System.Globalization;
     using System.IO;
+#if MONO
+    using System.Buffers;
+#endif
     using System.Diagnostics.Contracts;
 
     // DSAParameters is serializable so that one could pass the public parameters
@@ -266,5 +269,128 @@ namespace System.Security.Cryptography {
         {
             return new ArgumentException(Environment.GetResourceString("Cryptography_HashAlgorithmNameNullOrEmpty"), "hashAlgorithm");
         }
+
+#if MONO
+        // these methods were copied from CoreFX for NS2.1 support
+        public static DSA Create(int keySizeInBits)
+        {
+            DSA dsa = Create();
+
+            try
+            {
+                dsa.KeySize = keySizeInBits;
+                return dsa;
+            }
+            catch
+            {
+                dsa.Dispose();
+                throw;
+            }
+        }
+
+        public static DSA Create(DSAParameters parameters)
+        {
+            DSA dsa = Create();
+
+            try
+            {
+                dsa.ImportParameters(parameters);
+                return dsa;
+            }
+            catch
+            {
+                dsa.Dispose();
+                throw;
+            }
+        }
+
+        public virtual bool TryCreateSignature(ReadOnlySpan<byte> hash, Span<byte> destination, out int bytesWritten)
+        {
+            byte[] sig = CreateSignature(hash.ToArray());
+            if (sig.Length <= destination.Length)
+            {
+                new ReadOnlySpan<byte>(sig).CopyTo(destination);
+                bytesWritten = sig.Length;
+                return true;
+            }
+            else
+            {
+                bytesWritten = 0;
+                return false;
+            }
+        }
+
+        protected virtual bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
+        {
+            byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
+            try
+            {
+                data.CopyTo(array);
+                byte[] hash = HashData(array, 0, data.Length, hashAlgorithm);
+                if (destination.Length >= hash.Length)
+                {
+                    new ReadOnlySpan<byte>(hash).CopyTo(destination);
+                    bytesWritten = hash.Length;
+                    return true;
+                }
+                else
+                {
+                    bytesWritten = 0;
+                    return false;
+                }
+            }
+            finally
+            {
+                Array.Clear(array, 0, data.Length);
+                ArrayPool<byte>.Shared.Return(array);
+            }
+        }
+
+        public virtual bool TrySignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
+        {
+            if (string.IsNullOrEmpty(hashAlgorithm.Name))
+            {
+                throw HashAlgorithmNameNullOrEmpty();
+            }
+
+            if (TryHashData(data, destination, hashAlgorithm, out int hashLength) &&
+                TryCreateSignature(destination.Slice(0, hashLength), destination, out bytesWritten))
+            {
+                return true;
+            }
+
+            bytesWritten = 0;
+            return false;
+        }
+
+        public virtual bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm)
+        {
+            if (string.IsNullOrEmpty(hashAlgorithm.Name))
+            {
+                throw HashAlgorithmNameNullOrEmpty();
+            }
+
+            for (int i = 256; ; i = checked(i * 2))
+            {
+                int hashLength = 0;
+                byte[] hash = ArrayPool<byte>.Shared.Rent(i);
+                try
+                {
+                    if (TryHashData(data, hash, hashAlgorithm, out hashLength))
+                    {
+                        return VerifySignature(new ReadOnlySpan<byte>(hash, 0, hashLength), signature);
+                    }
+                }
+                finally
+                {
+                    Array.Clear(hash, 0, hashLength);
+                    ArrayPool<byte>.Shared.Return(hash);
+                }
+            }
+        }
+
+        public virtual bool VerifySignature(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature) =>
+            VerifySignature(hash.ToArray(), signature.ToArray());
+#endif
     }
 }

+ 141 - 0
mcs/class/referencesource/mscorlib/system/security/cryptography/rsa.cs

@@ -17,6 +17,9 @@ namespace System.Security.Cryptography {
     using System.Security.Util;
     using System.Globalization;
     using System.Diagnostics.Contracts;
+#if MONO
+    using System.Buffers;
+#endif
 
     // We allow only the public components of an RSAParameters object, the Modulus and Exponent
     // to be serializable.
@@ -338,5 +341,143 @@ namespace System.Security.Cryptography {
         abstract public RSAParameters ExportParameters(bool includePrivateParameters);
 
         abstract public void ImportParameters(RSAParameters parameters);
+
+#if MONO // these methods were copied from CoreFX for NS2.1 support
+        public static RSA Create(int keySizeInBits)
+        {
+            RSA rsa = Create();
+
+            try
+            {
+                rsa.KeySize = keySizeInBits;
+                return rsa;
+            }
+            catch
+            {
+                rsa.Dispose();
+                throw;
+            }
+        }
+
+        public static RSA Create(RSAParameters parameters)
+        {
+            RSA rsa = Create();
+
+            try
+            {
+                rsa.ImportParameters(parameters);
+                return rsa;
+            }
+            catch
+            {
+                rsa.Dispose();
+                throw;
+            }
+        }
+
+        public virtual bool TryDecrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, out int bytesWritten)
+        {
+            byte[] result = Decrypt(data.ToArray(), padding);
+
+            if (destination.Length >= result.Length)
+            {
+                new ReadOnlySpan<byte>(result).CopyTo(destination);
+                bytesWritten = result.Length;
+                return true;
+            }
+
+            bytesWritten = 0;
+            return false;
+        }
+
+        public virtual bool TryEncrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, out int bytesWritten)
+        {
+            byte[] result = Encrypt(data.ToArray(), padding);
+
+            if (destination.Length >= result.Length)
+            {
+                new ReadOnlySpan<byte>(result).CopyTo(destination);
+                bytesWritten = result.Length;
+                return true;
+            }
+
+            bytesWritten = 0;
+            return false;
+        }
+
+        protected virtual bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
+        {
+            byte[] result;
+            byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
+            try
+            {
+                data.CopyTo(array);
+                result = HashData(array, 0, data.Length, hashAlgorithm);
+            }
+            finally
+            {
+                Array.Clear(array, 0, data.Length);
+                ArrayPool<byte>.Shared.Return(array);
+            }
+
+            if (destination.Length >= result.Length)
+            {
+                new ReadOnlySpan<byte>(result).CopyTo(destination);
+                bytesWritten = result.Length;
+                return true;
+            }
+
+            bytesWritten = 0;
+            return false;
+        }
+
+        public virtual bool TrySignHash(ReadOnlySpan<byte> hash, Span<byte> destination, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding, out int bytesWritten)
+        {
+            byte[] result = SignHash(hash.ToArray(), hashAlgorithm, padding);
+
+            if (destination.Length >= result.Length)
+            {
+                new ReadOnlySpan<byte>(result).CopyTo(destination);
+                bytesWritten = result.Length;
+                return true;
+            }
+
+            bytesWritten = 0;
+            return false;
+        }
+
+        public virtual bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
+        {
+            if (string.IsNullOrEmpty(hashAlgorithm.Name))
+            {
+                throw HashAlgorithmNameNullOrEmpty();
+            }
+            if (padding == null)
+            {
+                throw new ArgumentNullException(nameof(padding));
+            }
+
+            for (int i = 256; ; i = checked(i * 2))
+            {
+                int hashLength = 0;
+                byte[] hash = ArrayPool<byte>.Shared.Rent(i);
+                try
+                {
+                    if (TryHashData(data, hash, hashAlgorithm, out hashLength))
+                    {
+                        return VerifyHash(new ReadOnlySpan<byte>(hash, 0, hashLength), signature, hashAlgorithm, padding);
+                    }
+                }
+                finally
+                {
+                    Array.Clear(hash, 0, hashLength);
+                    ArrayPool<byte>.Shared.Return(hash);
+                }
+            }
+        }
+
+        public virtual bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding) =>
+            VerifyHash(hash.ToArray(), signature.ToArray(), hashAlgorithm, padding);
+#endif
     }
 }

+ 3 - 3
mono/metadata/w32socket.c

@@ -1923,14 +1923,14 @@ ipaddress_handle_to_struct_in_addr (MonoObjectHandle ipaddr)
 	struct in_addr inaddr;
 	MonoClassField *field;
 	
-	field = mono_class_get_field_from_name_full (mono_handle_class (ipaddr), "m_Address", NULL);
+	field = mono_class_get_field_from_name_full (mono_handle_class (ipaddr), "_addressOrScopeId", NULL);
 	g_assert (field);
 
 	/* No idea why .net uses a 64bit type to hold a 32bit value...
 	 *
 	 * Internal value of IPAddess is in little-endian order
 	 */
-	inaddr.s_addr = GUINT_FROM_LE ((guint32)MONO_HANDLE_GET_FIELD_VAL (ipaddr, guint64, field));
+	inaddr.s_addr = GUINT_FROM_LE ((guint32)MONO_HANDLE_GET_FIELD_VAL (ipaddr, guint32, field));
 	
 	return inaddr;
 }
@@ -1943,7 +1943,7 @@ ipaddress_handle_to_struct_in6_addr (MonoObjectHandle ipaddr)
 	MonoClassField *field;
 	int i;
 
-	field = mono_class_get_field_from_name_full (mono_handle_class (ipaddr), "m_Numbers", NULL);
+	field = mono_class_get_field_from_name_full (mono_handle_class (ipaddr), "_numbers", NULL);
 	g_assert (field);
 	MonoArrayHandle data = MONO_HANDLE_NEW_GET_FIELD (ipaddr, MonoArray, field);