-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathCrashDumpExtensions.cs
More file actions
47 lines (40 loc) · 1.86 KB
/
CrashDumpExtensions.cs
File metadata and controls
47 lines (40 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Testing.Extensions.Diagnostics;
using Microsoft.Testing.Platform.Builder;
using Microsoft.Testing.Platform.Services;
namespace Microsoft.Testing.Extensions;
/// <summary>
/// Provides extension methods for adding crash dump support to the test application builder.
/// </summary>
public static class CrashDumpExtensions
{
/// <summary>
/// Adds crash dump support to the test application builder.
/// </summary>
/// <param name="builder">The test application builder.</param>
/// <param name="ignoreIfNotSupported">Determines if the extension should not be enabled on netfx.</param>
public static void AddCrashDumpProvider(this ITestApplicationBuilder builder, bool ignoreIfNotSupported = false)
{
CrashDumpConfiguration crashDumpGeneratorConfiguration = new();
if (ignoreIfNotSupported)
{
#if !NETCOREAPP
crashDumpGeneratorConfiguration.Enable = false;
#endif
}
builder.TestHostControllers.AddEnvironmentVariableProvider(serviceProvider
=> new CrashDumpEnvironmentVariableProvider(
serviceProvider.GetConfiguration(),
serviceProvider.GetCommandLineOptions(),
crashDumpGeneratorConfiguration,
serviceProvider.GetLoggerFactory()));
builder.TestHostControllers.AddProcessLifetimeHandler(serviceProvider
=> new CrashDumpProcessLifetimeHandler(
serviceProvider.GetCommandLineOptions(),
serviceProvider.GetMessageBus(),
serviceProvider.GetOutputDevice(),
crashDumpGeneratorConfiguration));
builder.CommandLine.AddProvider(() => new CrashDumpCommandLineProvider());
}
}