Skip to content

Commit f090bbe

Browse files
ericstjjtschuster
authored andcommitted
Ensure we create new RemoteInvokeOptions for every call (dotnet#107820)
The RemoteInvokeOptions instance is mutated by RemoveExecutor.Invoke and cannot be shared.
1 parent 8582cb1 commit f090bbe

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

+5-5
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)