in src/Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared/InProcess/TestInvoker_InProc.cs [38:81]
public Tuple<decimal, Exception> InvokeTest(
ITest test,
IMessageBus messageBus,
Type testClass,
object?[]? constructorArguments,
MethodInfo testMethod,
object?[]? testMethodArguments)
{
var aggregator = new ExceptionAggregator();
var beforeAfterAttributes = new BeforeAfterTestAttribute[0];
var cancellationTokenSource = new CancellationTokenSource();
var synchronizationContext = new DispatcherSynchronizationContext(Application.Current.Dispatcher, DispatcherPriority.Background);
var result = Task.Factory.StartNew(
async () =>
{
try
{
var invoker = new XunitTestInvoker(
test,
messageBus,
testClass,
constructorArguments,
testMethod,
testMethodArguments,
beforeAfterAttributes,
aggregator,
cancellationTokenSource);
return await invoker.RunAsync();
}
catch (Exception)
{
Debugger.Launch();
throw;
}
},
CancellationToken.None,
TaskCreationOptions.None,
#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
new SynchronizationContextTaskScheduler(synchronizationContext)).Unwrap().GetAwaiter().GetResult();
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
return Tuple.Create(result, aggregator.ToException());
}