@@ -12,6 +12,8 @@ namespace Microsoft.DotNet.Cli.Commands.Test.IPC;
12
12
13
13
internal sealed class NamedPipeServer : NamedPipeBase
14
14
{
15
+ private static bool IsUnix => Path . DirectorySeparatorChar == '/' ;
16
+
15
17
private readonly Func < NamedPipeServer , IRequest , Task < IResponse > > _callback ;
16
18
private readonly NamedPipeServerStream _namedPipeServerStream ;
17
19
private readonly CancellationToken _cancellationToken ;
@@ -24,20 +26,18 @@ internal sealed class NamedPipeServer : NamedPipeBase
24
26
private bool _disposed ;
25
27
26
28
public NamedPipeServer (
27
- PipeNameDescription pipeNameDescription ,
29
+ string pipeName ,
28
30
Func < NamedPipeServer , IRequest , Task < IResponse > > callback ,
29
31
int maxNumberOfServerInstances ,
30
32
CancellationToken cancellationToken ,
31
33
bool skipUnknownMessages )
32
34
{
33
- _namedPipeServerStream = new ( ( PipeName = pipeNameDescription ) . Name , PipeDirection . InOut , maxNumberOfServerInstances , PipeTransmissionMode . Byte , PipeOptions . Asynchronous | PipeOptions . CurrentUserOnly ) ;
35
+ _namedPipeServerStream = new ( pipeName , PipeDirection . InOut , maxNumberOfServerInstances , PipeTransmissionMode . Byte , PipeOptions . Asynchronous | PipeOptions . CurrentUserOnly ) ;
34
36
_callback = callback ;
35
37
_cancellationToken = cancellationToken ;
36
38
_skipUnknownMessages = skipUnknownMessages ;
37
39
}
38
40
39
- public PipeNameDescription PipeName { get ; private set ; }
40
-
41
41
public bool WasConnected { get ; private set ; }
42
42
43
43
public async Task WaitConnectionAsync ( CancellationToken cancellationToken )
@@ -183,22 +183,15 @@ private async Task InternalLoopAsync(CancellationToken cancellationToken)
183
183
}
184
184
}
185
185
186
- public static PipeNameDescription GetPipeName ( string name )
186
+ public static string GetPipeName ( string name )
187
187
{
188
- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
188
+ if ( ! IsUnix )
189
189
{
190
- return new PipeNameDescription ( $ "testingplatform.pipe.{ name . Replace ( '\\ ' , '.' ) } ", false ) ;
190
+ return $ "testingplatform.pipe.{ name . Replace ( '\\ ' , '.' ) } ";
191
191
}
192
192
193
- string directoryId = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , name ) ;
194
- Directory . CreateDirectory ( directoryId ) ;
195
- return new PipeNameDescription (
196
- ! Directory . Exists ( directoryId )
197
- ? throw new DirectoryNotFoundException ( string . Format (
198
- CultureInfo . InvariantCulture ,
199
- $ "Directory: { directoryId } doesn't exist.",
200
- directoryId ) )
201
- : Path . Combine ( directoryId , ".p" ) , true ) ;
193
+ // Similar to https://github.com/dotnet/roslyn/blob/99bf83c7bc52fa1ff27cf792db38755d5767c004/src/Compilers/Shared/NamedPipeUtil.cs#L26-L42
194
+ return Path . Combine ( "/tmp" , name ) ;
202
195
}
203
196
204
197
public void Dispose ( )
@@ -227,8 +220,6 @@ public void Dispose()
227
220
// Ensure we are still disposing the resouces correctly, even if _loopTask completes with
228
221
// an exception, or if the task doesn't complete within the 90 seconds limit.
229
222
_namedPipeServerStream . Dispose ( ) ;
230
- PipeName . Dispose ( ) ;
231
-
232
223
_disposed = true ;
233
224
}
234
225
}
0 commit comments