From 6ea53bf028aedad10384a528225a507e42a5caf8 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 5 Jun 2019 09:52:34 -0400 Subject: [PATCH] Implement NamedPipeClientStream in the unityaot profile (case 1159863) This change builds the class library code to implement the `NamedPipeClientStream` class in the unityaot profile on Windows. For the time being, we will not implement this class for non-Windows platforms, since that requires the Mono.Posix.dll assembly and a native library as well. We may consider adding support on Posix platforms in the future. --- .../System.IO.Pipes/NamedPipeClientStream.cs | 22 +++++++++++++------ .../System.Core/System.IO.Pipes/PipeStream.cs | 2 +- .../unityaot_System.Core.dll.sources | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/mcs/class/System.Core/System.IO.Pipes/NamedPipeClientStream.cs b/mcs/class/System.Core/System.IO.Pipes/NamedPipeClientStream.cs index a27c4dc0b4d3..bd71ec318014 100644 --- a/mcs/class/System.Core/System.IO.Pipes/NamedPipeClientStream.cs +++ b/mcs/class/System.Core/System.IO.Pipes/NamedPipeClientStream.cs @@ -74,7 +74,7 @@ public NamedPipeClientStream (string serverName, string pipeName, PipeDirection } public NamedPipeClientStream (string serverName, string pipeName, PipeDirection direction, PipeOptions options, TokenImpersonationLevel impersonationLevel, HandleInheritability inheritability) -#if MOBILE +#if MOBILE && !UNITY_AOT : base (direction, DefaultBufferSize) { throw new NotImplementedException (); @@ -88,13 +88,17 @@ public NamedPipeClientStream (string serverName, string pipeName, PipeDirection public NamedPipeClientStream (PipeDirection direction, bool isAsync, bool isConnected, SafePipeHandle safePipeHandle) : base (direction, DefaultBufferSize) { -#if MOBILE +#if MOBILE && !UNITY_AOT throw new NotImplementedException (); #else if (IsWindows) impl = new Win32NamedPipeClient (this, safePipeHandle); else +#if UNITY_AOT + throw new NotImplementedException (); +#else impl = new UnixNamedPipeClient (this, safePipeHandle); +#endif IsConnected = isConnected; InitializeHandle (safePipeHandle, true, isAsync); #endif @@ -106,13 +110,17 @@ public NamedPipeClientStream (string serverName, string pipeName, PipeAccessRigh if (impersonationLevel != TokenImpersonationLevel.None || inheritability != HandleInheritability.None) throw ThrowACLException (); -#if MOBILE +#if MOBILE && !UNITY_AOT throw new NotImplementedException (); #else if (IsWindows) impl = new Win32NamedPipeClient (this, serverName, pipeName, desiredAccessRights, options, inheritability); else +#if UNITY_AOT + throw new NotImplementedException (); +#else impl = new UnixNamedPipeClient (this, serverName, pipeName, desiredAccessRights, options, inheritability); +#endif #endif } @@ -121,13 +129,13 @@ public NamedPipeClientStream (string serverName, string pipeName, PipeAccessRigh Dispose (false); } -#if !MOBILE +#if !MOBILE || UNITY_AOT INamedPipeClient impl; #endif public void Connect () { -#if MOBILE +#if MOBILE && !UNITY_AOT throw new NotImplementedException (); #else impl.Connect (); @@ -138,7 +146,7 @@ public void Connect () public void Connect (int timeout) { -#if MOBILE +#if MOBILE && !UNITY_AOT throw new NotImplementedException (); #else impl.Connect (timeout); @@ -174,7 +182,7 @@ protected override internal void CheckPipePropertyOperations () { public int NumberOfServerInstances { get { CheckPipePropertyOperations (); -#if MOBILE +#if MOBILE && !UNITY_AOT throw new NotImplementedException (); #else return impl.NumberOfServerInstances; diff --git a/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs b/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs index 738342c76e88..52b0773020f1 100644 --- a/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs +++ b/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs @@ -46,7 +46,7 @@ public abstract class PipeStream : Stream // FIXME: not precise. internal const int DefaultBufferSize = 0x400; -#if !MOBILE +#if !MOBILE || UNITY_AOT internal static bool IsWindows { get { return Win32Marshal.IsWindows; } } diff --git a/mcs/class/System.Core/unityaot_System.Core.dll.sources b/mcs/class/System.Core/unityaot_System.Core.dll.sources index 5ec6fe909185..4baa8f0c00b7 100644 --- a/mcs/class/System.Core/unityaot_System.Core.dll.sources +++ b/mcs/class/System.Core/unityaot_System.Core.dll.sources @@ -1,3 +1,4 @@ #include winaot_System.Core.dll.sources ../referencesource/System.Core/System/Linq/Enumerable.cs corefx/SR.cs +System.IO.Pipes/PipeWin32.cs