Skip to content

Commit 7832c5d

Browse files
Ensure we create new RemoteInvokeOptions for every call (#107875)
The RemoteInvokeOptions instance is mutated by RemoveExecutor.Invoke and cannot be shared. Co-authored-by: Eric StJohn <[email protected]>
1 parent 414a324 commit 7832c5d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/WindowsServiceTester.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ private WindowsServiceTester(SafeServiceHandle serviceHandle, RemoteInvokeHandle
6161
}
6262

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

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

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

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

72-
private static RemoteInvokeOptions remoteInvokeOptions = new RemoteInvokeOptions() { Start = false };
72+
private static RemoteInvokeOptions CreateRemoteInvokeOptions() => new RemoteInvokeOptions() { Start = false };
7373

7474
private static WindowsServiceTester Create(RemoteInvokeHandle remoteInvokeHandle, string serviceName)
7575
{

0 commit comments

Comments
 (0)