Skip to content

Commit

Permalink
Ensure we create new RemoteInvokeOptions for every call (#107875)
Browse files Browse the repository at this point in the history
The RemoteInvokeOptions instance is mutated by RemoveExecutor.Invoke and cannot be shared.

Co-authored-by: Eric StJohn <ericstj@microsoft.com>
  • Loading branch information
github-actions[bot] and ericstj authored Sep 17, 2024
1 parent 414a324 commit 7832c5d
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ private WindowsServiceTester(SafeServiceHandle serviceHandle, RemoteInvokeHandle
}

// the following overloads are necessary to ensure the compiler will produce the correct signature from a lambda.
public static WindowsServiceTester Create(Func<Task> serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, remoteInvokeOptions), serviceName);
public static WindowsServiceTester Create(Func<Task> serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, CreateRemoteInvokeOptions()), serviceName);

public static WindowsServiceTester Create(Func<Task<int>> serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, remoteInvokeOptions), serviceName);
public static WindowsServiceTester Create(Func<Task<int>> serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, CreateRemoteInvokeOptions()), serviceName);

public static WindowsServiceTester Create(Func<int> serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, remoteInvokeOptions), serviceName);
public static WindowsServiceTester Create(Func<int> serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, CreateRemoteInvokeOptions()), serviceName);

public static WindowsServiceTester Create(Action serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, remoteInvokeOptions), serviceName);
public static WindowsServiceTester Create(Action serviceMain, [CallerMemberName] string serviceName = null) => Create(RemoteExecutor.Invoke(serviceMain, CreateRemoteInvokeOptions()), serviceName);

private static RemoteInvokeOptions remoteInvokeOptions = new RemoteInvokeOptions() { Start = false };
private static RemoteInvokeOptions CreateRemoteInvokeOptions() => new RemoteInvokeOptions() { Start = false };

private static WindowsServiceTester Create(RemoteInvokeHandle remoteInvokeHandle, string serviceName)
{
Expand Down

0 comments on commit 7832c5d

Please sign in to comment.