diff --git a/src/xunit.runner.visualstudio/Utility/DiaSessionWrapper.cs b/src/xunit.runner.visualstudio/Utility/DiaSessionWrapper.cs
index 461ec67..8a3825d 100644
--- a/src/xunit.runner.visualstudio/Utility/DiaSessionWrapper.cs
+++ b/src/xunit.runner.visualstudio/Utility/DiaSessionWrapper.cs
@@ -16,13 +16,13 @@ class DiaSessionWrapper : IDisposable
#endif
readonly DiaSessionWrapperHelper? helper;
readonly DiaSession? session;
- readonly DiagnosticMessageSink diagnosticMessageSink;
+ readonly DiagnosticMessageSink internalDiagnosticMessageSink;
public DiaSessionWrapper(
string assemblyFileName,
- DiagnosticMessageSink diagnosticMessageSink)
+ DiagnosticMessageSink internalDiagnosticMessageSink)
{
- this.diagnosticMessageSink = Guard.ArgumentNotNull(diagnosticMessageSink);
+ this.internalDiagnosticMessageSink = Guard.ArgumentNotNull(internalDiagnosticMessageSink);
try
{
@@ -30,7 +30,7 @@ public DiaSessionWrapper(
}
catch (Exception ex)
{
- diagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception creating DiaSession: {ex}"));
+ internalDiagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception creating DiaSession: {ex}"));
}
try
@@ -48,7 +48,7 @@ public DiaSessionWrapper(
}
catch (Exception ex)
{
- diagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception creating DiaSessionWrapperHelper: {ex}"));
+ internalDiagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception creating DiaSessionWrapperHelper: {ex}"));
}
}
@@ -66,7 +66,7 @@ public DiaSessionWrapper(
}
catch (Exception ex)
{
- diagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception getting source mapping for {typeName}.{methodName}: {ex}"));
+ internalDiagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception getting source mapping for {typeName}.{methodName}: {ex}"));
return null;
}
}
diff --git a/src/xunit.runner.visualstudio/Utility/VisualStudioSourceInformationProvider.cs b/src/xunit.runner.visualstudio/Utility/VisualStudioSourceInformationProvider.cs
index d80e26f..0708fd9 100644
--- a/src/xunit.runner.visualstudio/Utility/VisualStudioSourceInformationProvider.cs
+++ b/src/xunit.runner.visualstudio/Utility/VisualStudioSourceInformationProvider.cs
@@ -18,12 +18,12 @@ public class VisualStudioSourceInformationProvider : LongLivedMarshalByRefObject
/// Initializes a new instance of the class.
///
/// The assembly file name.
- /// The message sink to send internal diagnostic messages to.
+ /// The message sink to send internal diagnostic messages to.
public VisualStudioSourceInformationProvider(
string assemblyFileName,
- DiagnosticMessageSink diagnosticMessageSink)
+ DiagnosticMessageSink internalDiagnosticMessageSink)
{
- session = new DiaSessionWrapper(assemblyFileName, diagnosticMessageSink);
+ session = new DiaSessionWrapper(assemblyFileName, internalDiagnosticMessageSink);
}
///
diff --git a/src/xunit.runner.visualstudio/VsTestRunner.cs b/src/xunit.runner.visualstudio/VsTestRunner.cs
index 4c79e6c..8f80168 100644
--- a/src/xunit.runner.visualstudio/VsTestRunner.cs
+++ b/src/xunit.runner.visualstudio/VsTestRunner.cs
@@ -227,9 +227,9 @@ void DiscoverTests(
{
RemotingUtility.CleanUpRegisteredChannels();
- var internalDiagnosticsMessageSink = DiagnosticMessageSink.ForInternalDiagnostics(logger, runSettings.InternalDiagnosticMessages ?? false);
+ var internalDiagnosticsSinkLocal = DiagnosticMessageSink.ForInternalDiagnostics(logger, runSettings.InternalDiagnosticMessages ?? false);
+ using var _ = AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), MessageSinkAdapter.Wrap(internalDiagnosticsSinkLocal));
- using var _ = AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), MessageSinkAdapter.Wrap(internalDiagnosticsMessageSink));
foreach (var assemblyFileNameCanBeWithoutAbsolutePath in sources)
{
var assembly = new XunitProjectAssembly { AssemblyFilename = GetAssemblyFileName(assemblyFileNameCanBeWithoutAbsolutePath) };
@@ -237,11 +237,11 @@ void DiscoverTests(
var fileName = Path.GetFileNameWithoutExtension(assembly.AssemblyFilename);
var shadowCopy = assembly.Configuration.ShadowCopyOrDefault;
- var diagnosticSink = DiagnosticMessageSink.ForDiagnostics(logger, fileName, assembly.Configuration.DiagnosticMessagesOrDefault);
+ var diagnosticsSinkLocal = DiagnosticMessageSink.ForDiagnostics(logger, fileName, assembly.Configuration.DiagnosticMessagesOrDefault);
var appDomain = assembly.Configuration.AppDomain ?? AppDomainDefaultBehavior;
- using var sourceInformationProvider = new VisualStudioSourceInformationProvider(assembly.AssemblyFilename, diagnosticSink);
- using var controller = new XunitFrontController(appDomain, assembly.AssemblyFilename, shadowCopy: shadowCopy, sourceInformationProvider: sourceInformationProvider, diagnosticMessageSink: MessageSinkAdapter.Wrap(diagnosticSink));
+ using var sourceInformationProvider = new VisualStudioSourceInformationProvider(assembly.AssemblyFilename, internalDiagnosticsSinkLocal);
+ using var controller = new XunitFrontController(appDomain, assembly.AssemblyFilename, shadowCopy: shadowCopy, sourceInformationProvider: sourceInformationProvider, diagnosticMessageSink: MessageSinkAdapter.Wrap(diagnosticsSinkLocal));
if (!DiscoverTestsInSource(controller, logger, testPlatformContext, runSettings, visitorFactory, visitComplete, assembly))
break;
}
@@ -384,18 +384,16 @@ void RunTests(
var parallelizeAssemblies = runInfos.All(runInfo => runInfo.Assembly.Configuration.ParallelizeAssemblyOrDefault);
var reporter = GetRunnerReporter(logger, runSettings, runInfos.Select(ari => ari.Assembly.AssemblyFilename).ToList());
using var reporterMessageHandler = MessageSinkWithTypesAdapter.Wrap(reporter.CreateMessageHandler(new VisualStudioRunnerLogger(logger)));
- using var internalDiagnosticsMessageSink = DiagnosticMessageSink.ForInternalDiagnostics(logger, runSettings.InternalDiagnosticMessages ?? false);
+ using var internalDiagnosticsSinkLocal = DiagnosticMessageSink.ForInternalDiagnostics(logger, runSettings.InternalDiagnosticMessages ?? false);
+ using var _ = AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), MessageSinkAdapter.Wrap(internalDiagnosticsSinkLocal));
- using (AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), MessageSinkAdapter.Wrap(internalDiagnosticsMessageSink)))
- {
- if (parallelizeAssemblies)
- runInfos
- .Select(runInfo => RunTestsInAssemblyAsync(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo))
- .ToList()
- .ForEach(@event => @event.WaitOne());
- else
- runInfos.ForEach(runInfo => RunTestsInAssembly(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo));
- }
+ if (parallelizeAssemblies)
+ runInfos
+ .Select(runInfo => RunTestsInAssemblyAsync(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo))
+ .ToList()
+ .ForEach(@event => @event.WaitOne());
+ else
+ runInfos.ForEach(runInfo => RunTestsInAssembly(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo));
}
catch (Exception ex)
{
@@ -426,10 +424,12 @@ void RunTestsInAssembly(
var appDomain = configuration.AppDomain ?? AppDomainDefaultBehavior;
var longRunningSeconds = configuration.LongRunningTestSecondsOrDefault;
- var diagnosticSink = DiagnosticMessageSink.ForDiagnostics(logger, assemblyDisplayName, runInfo.Assembly.Configuration.DiagnosticMessagesOrDefault);
- var diagnosticMessageSink = MessageSinkAdapter.Wrap(diagnosticSink);
- using var sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName, diagnosticSink);
- using var controller = new XunitFrontController(appDomain, assemblyFileName, shadowCopy: shadowCopy, sourceInformationProvider: sourceInformationProvider, diagnosticMessageSink: diagnosticMessageSink);
+ var diagnosticsSinkLocal = DiagnosticMessageSink.ForDiagnostics(logger, assemblyDisplayName, runInfo.Assembly.Configuration.DiagnosticMessagesOrDefault);
+ var diagnosticsSinkRemote = MessageSinkAdapter.Wrap(diagnosticsSinkLocal);
+ var internalDiagnosticsSinkLocal = DiagnosticMessageSink.ForInternalDiagnostics(logger, runInfo.Assembly.Configuration.InternalDiagnosticMessagesOrDefault);
+
+ using var sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName, internalDiagnosticsSinkLocal);
+ using var controller = new XunitFrontController(appDomain, assemblyFileName, shadowCopy: shadowCopy, sourceInformationProvider: sourceInformationProvider, diagnosticMessageSink: diagnosticsSinkRemote);
var testCasesMap = new Dictionary();
var testCases = new List();
if (runInfo.TestCases is null || !runInfo.TestCases.Any())
@@ -543,7 +543,7 @@ void RunTestsInAssembly(
using var vsExecutionSink = new VsExecutionSink(reporterMessageHandler, frameworkHandle, logger, testCasesMap, () => cancelled);
IExecutionSink resultsSink = vsExecutionSink;
if (longRunningSeconds > 0)
- resultsSink = new DelegatingLongRunningTestDetectionSink(resultsSink, TimeSpan.FromSeconds(longRunningSeconds), diagnosticSink);
+ resultsSink = new DelegatingLongRunningTestDetectionSink(resultsSink, TimeSpan.FromSeconds(longRunningSeconds), diagnosticsSinkLocal);
if (configuration.FailSkipsOrDefault)
resultsSink = new DelegatingFailSkipSink(resultsSink);