Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DiagnosticsClient.ApplyStartupHook public #5086

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,36 @@ internal async Task<Dictionary<string, string>> GetProcessEnvironmentAsync(Cance
return await helper.ReadEnvironmentAsync(response.Continuation, token).ConfigureAwait(false);
}

internal void ApplyStartupHook(string startupHookPath)
/// <summary>
/// Loads the specified assembly with a StartupHook in the target process.
/// </summary>
/// <param name="startupHookPath">The path to the assembly containing the StartupHook.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="startupHookPath"/> is null or empty.</exception>
public void ApplyStartupHook(string startupHookPath)
{
if (string.IsNullOrEmpty(startupHookPath))
{
throw new ArgumentNullException(nameof(startupHookPath));
}

IpcMessage message = CreateApplyStartupHookMessage(startupHookPath);
IpcMessage response = IpcClient.SendMessage(_endpoint, message);
ValidateResponseMessage(response, nameof(ApplyStartupHook));
}

internal async Task ApplyStartupHookAsync(string startupHookPath, CancellationToken token)
/// <summary>
/// Loads the specified assembly with a StartupHook in the target process.
/// </summary>
/// <param name="startupHookPath">The path to the assembly containing the StartupHook.</param>
/// <param name="token">The token to monitor for cancellation requests.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="startupHookPath"/> is null or empty.</exception>
public async Task ApplyStartupHookAsync(string startupHookPath, CancellationToken token)
{
if (string.IsNullOrEmpty(startupHookPath))
{
throw new ArgumentNullException(nameof(startupHookPath));
}

IpcMessage message = CreateApplyStartupHookMessage(startupHookPath);
IpcMessage response = await IpcClient.SendMessageAsync(_endpoint, message, token).ConfigureAwait(false);
ValidateResponseMessage(response, nameof(ApplyStartupHookAsync));
Expand Down