diff --git a/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpActivityIndicator.cs b/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpActivityIndicator.cs index 6aee5e53bc..bde5b6043b 100644 --- a/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpActivityIndicator.cs +++ b/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpActivityIndicator.cs @@ -62,9 +62,12 @@ public HangDumpActivityIndicator( if (_commandLineOptions.IsOptionSet(HangDumpCommandLineProvider.HangDumpOptionName) && !_commandLineOptions.IsOptionSet(PlatformCommandLineProvider.ServerOptionKey)) { - string namedPipeSuffix = _environment.GetEnvironmentVariable(HangDumpConfiguration.MutexNameSuffix) ?? throw new InvalidOperationException($"Expected {HangDumpConfiguration.MutexNameSuffix} environment variable set."); + string namedPipeSuffix = _environment.GetEnvironmentVariable(HangDumpConfiguration.MutexNameSuffix) + ?? throw new InvalidOperationException($"Expected {HangDumpConfiguration.MutexNameSuffix} environment variable set."); + // @Marco: Why do we need to duplicate logic here instead of using HangDumpConfiguration.PipeNameKey? string pipeNameEnvironmentVariable = $"{HangDumpConfiguration.PipeName}_{FNV_1aHashHelper.ComputeStringHash(testApplicationModuleInfo.GetCurrentTestApplicationFullPath())}_{namedPipeSuffix}"; - string namedPipeName = _environment.GetEnvironmentVariable(pipeNameEnvironmentVariable) ?? throw new InvalidOperationException($"Expected {pipeNameEnvironmentVariable} environment variable set."); + string namedPipeName = _environment.GetEnvironmentVariable(pipeNameEnvironmentVariable) + ?? throw new InvalidOperationException($"Expected {pipeNameEnvironmentVariable} environment variable set."); _namedPipeClient = new NamedPipeClient(namedPipeName); _namedPipeClient.RegisterSerializer(new ActivityIndicatorMutexNameRequestSerializer(), typeof(ActivityIndicatorMutexNameRequest)); _namedPipeClient.RegisterSerializer(new VoidResponseSerializer(), typeof(VoidResponse)); @@ -114,7 +117,8 @@ await _namedPipeClient.RequestReplyAsync IsEnabledAsync() => Task.FromResult( // TrxReportGenerator is enabled only when trx report is enabled _commandLineOptions.IsOptionSet(TrxReportGeneratorCommandLine.TrxReportOptionName) - // TestController is not used when we run in server mode - && !_commandLineOptions.IsOptionSet(PlatformCommandLineProvider.ServerOptionKey) - // If crash dump is not enabled we run trx in-process only - && _commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashDumpOptionName)); + // TestController is not used when we run in server mode + && !_commandLineOptions.IsOptionSet(PlatformCommandLineProvider.ServerOptionKey) + // If crash dump is not enabled we run trx in-process only + && _commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashDumpOptionName)); #pragma warning restore SA1114 // Parameter list should follow declaration public Task UpdateAsync(IEnvironmentVariables environmentVariables) diff --git a/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportExtensions.cs b/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportExtensions.cs index 926f6eadcd..69ba9fcc6a 100644 --- a/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportExtensions.cs +++ b/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportExtensions.cs @@ -22,7 +22,6 @@ public static void AddTrxReportProvider(this ITestApplicationBuilder builder) throw new InvalidOperationException(ExtensionResources.InvalidTestApplicationBuilderType); } - PipeNameDescription pipeNameDescription = NamedPipeServer.GetPipeName($"trxpipename.{Guid.NewGuid():N}"); var commandLine = new TrxReportGeneratorCommandLine(); var compositeTestSessionTrxService = @@ -42,29 +41,37 @@ public static void AddTrxReportProvider(this ITestApplicationBuilder builder) serviceProvider.GetLoggerFactory().CreateLogger())); builder.TestHost.AddTestApplicationLifecycleCallbacks(serviceProvider => - new TrxTestApplicationLifecycleCallbacks( - serviceProvider.GetCommandLineOptions(), - serviceProvider.GetEnvironment())); + new TrxTestApplicationLifecycleCallbacks( + serviceProvider.GetCommandLineOptions(), + serviceProvider.GetEnvironment())); builder.TestHost.AddDataConsumer(compositeTestSessionTrxService); builder.TestHost.AddTestSessionLifetimeHandle(compositeTestSessionTrxService); builder.CommandLine.AddProvider(() => commandLine); + PipeNameDescription pipeNameDescription = NamedPipeServer.GetPipeName(Guid.NewGuid().ToString("N")); var compositeLifeTimeHandler = new CompositeExtensionFactory(serviceProvider => - new TrxProcessLifetimeHandler( - serviceProvider.GetCommandLineOptions(), - serviceProvider.GetEnvironment(), - serviceProvider.GetLoggerFactory(), - serviceProvider.GetMessageBus(), - serviceProvider.GetTestApplicationModuleInfo(), - serviceProvider.GetConfiguration(), - serviceProvider.GetSystemClock(), - serviceProvider.GetTask(), - pipeNameDescription)); + { + serviceProvider.GetLoggerFactory().CreateLogger().LogTrace($"TRX pipe name: '{pipeNameDescription.Name}"); + return new TrxProcessLifetimeHandler( + serviceProvider.GetCommandLineOptions(), + serviceProvider.GetEnvironment(), + serviceProvider.GetLoggerFactory(), + serviceProvider.GetMessageBus(), + serviceProvider.GetTestApplicationModuleInfo(), + serviceProvider.GetConfiguration(), + serviceProvider.GetSystemClock(), + serviceProvider.GetTask(), + pipeNameDescription); + }); ((TestHostControllersManager)builder.TestHostControllers).AddDataConsumer(compositeLifeTimeHandler); builder.TestHostControllers.AddProcessLifetimeHandler(compositeLifeTimeHandler); - builder.TestHostControllers.AddEnvironmentVariableProvider(serviceProvider => new TrxEnvironmentVariableProvider(serviceProvider.GetCommandLineOptions(), pipeNameDescription.Name)); + builder.TestHostControllers.AddEnvironmentVariableProvider(serviceProvider => + { + serviceProvider.GetLoggerFactory().CreateLogger().LogTrace($"TRX pipe name: '{pipeNameDescription.Name}"); + return new TrxEnvironmentVariableProvider(serviceProvider.GetCommandLineOptions(), pipeNameDescription.Name); + }); ToolTrxCompareFactory toolTrxCompareFactory = new(); TrxCompareToolCommandLine createTrxCompareToolCommandLine = toolTrxCompareFactory.CreateTrxCompareToolCommandLine(); diff --git a/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs b/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs index 45a14ad103..c633230a8a 100644 --- a/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs +++ b/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs @@ -50,7 +50,7 @@ public InvokeTestingPlatformTask() Debugger.Launch(); } - _pipeNameDescription = NamedPipeServer.GetPipeName($"{Guid.NewGuid():N}"); + _pipeNameDescription = NamedPipeServer.GetPipeName(Guid.NewGuid().ToString("N")); } internal InvokeTestingPlatformTask(IFileSystem fileSystem)