@@ -22,6 +22,8 @@ internal sealed class NamedPipeServer : NamedPipeBase, IServer
2222 ;
2323#pragma warning restore CA1416 // Validate platform compatibility
2424
25+ private static bool IsUnix => Path . DirectorySeparatorChar == '/' ;
26+
2527 private readonly Func < IRequest , Task < IResponse > > _callback ;
2628 private readonly IEnvironment _environment ;
2729 private readonly NamedPipeServerStream _namedPipeServerStream ;
@@ -277,32 +279,24 @@ private async Task InternalLoopAsync(CancellationToken cancellationToken)
277279 // If core MTP is updated, but old version of TRX is still used, it will try to call this overload at runtime.
278280 // Without it, MissingMethodException will be thrown at runtime.
279281 public static PipeNameDescription GetPipeName ( string name )
280- => GetPipeName ( name , new SystemEnvironment ( ) ) ;
281-
282- public static PipeNameDescription GetPipeName ( string name , IEnvironment environment )
283282 {
284- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
283+ if ( ! IsUnix )
285284 {
286- return new PipeNameDescription ( $ "testingplatform.pipe.{ name . Replace ( '\\ ' , '.' ) } ", false ) ;
285+ return new PipeNameDescription ( $ "testingplatform.pipe.{ name . Replace ( '\\ ' , '.' ) } ") ;
287286 }
288287
289- #pragma warning disable RS0030 // Do not use banned APIs - We are using IEnvironment, but we still need the enum from the Environment class in BCL. This is safe.
290- string directoryId = Path . Combine ( environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData , Environment . SpecialFolderOption . None ) , name ) ;
291- #pragma warning disable RS0030 // Do not use banned APIs
292- Directory . CreateDirectory ( directoryId ) ;
293- return new PipeNameDescription (
294- ! Directory . Exists ( directoryId )
295- ? throw new DirectoryNotFoundException ( string . Format (
296- CultureInfo . InvariantCulture ,
297- #if PLATFORM_MSBUILD
298- $ "Directory: { directoryId } doesn't exist.",
299- #else
300- PlatformResources . CouldNotFindDirectoryErrorMessage ,
301- #endif
302- directoryId) )
303- : Path . Combine ( directoryId , ".p" ) , true ) ;
288+ // Similar to https://github.com/dotnet/roslyn/blob/99bf83c7bc52fa1ff27cf792db38755d5767c004/src/Compilers/Shared/NamedPipeUtil.cs#L26-L42
289+ return new PipeNameDescription ( Path . Combine ( "/tmp" , name ) ) ;
304290 }
305291
292+ // For compatibility only.
293+ // Old versions of MTP used to have this overload without IEnvironment.
294+ // Extensions (e.g, TRX) calls into this overload.
295+ // If core MTP is updated, but old version of TRX is still used, it will try to call this overload at runtime.
296+ // Without it, MissingMethodException will be thrown at runtime.
297+ public static PipeNameDescription GetPipeName ( string name , IEnvironment _ )
298+ => GetPipeName ( name ) ;
299+
306300 public void Dispose ( )
307301 {
308302 if ( _disposed )
0 commit comments