Skip to content

Commit 8a734ff

Browse files
authored
Remove unused locals in System.ServiceProcess.ServiceController (#39640)
Remove unused locals and private methods in System.ServiceProcess.ServiceController. This fixes a part of #30457.
1 parent 095cb16 commit 8a734ff

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

src/libraries/System.ServiceProcess.ServiceController/tests/ServiceControllerTests.cs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class ServiceControllerTests : IDisposable
1515
private static readonly Lazy<bool> s_isElevated = new Lazy<bool>(() => AdminHelpers.IsProcessElevated());
1616
protected static bool IsProcessElevated => s_isElevated.Value;
1717

18-
private const int ExpectedDependentServiceCount = 3;
1918
private bool _disposed;
2019

2120
public ServiceControllerTests()
@@ -58,7 +57,7 @@ public void ConstructWithMachineName()
5857
var controller = new ServiceController(_testService.TestServiceName, _testService.TestMachineName);
5958
AssertExpectedProperties(controller);
6059

61-
AssertExtensions.Throws<ArgumentException>(null, () => { var c = new ServiceController(_testService.TestServiceName, ""); });
60+
AssertExtensions.Throws<ArgumentException>(null, () => { new ServiceController(_testService.TestServiceName, ""); });
6261
}
6362

6463
[ConditionalFact(nameof(IsProcessElevated))]
@@ -184,34 +183,5 @@ public void Dispose()
184183
_disposed = true;
185184
}
186185
}
187-
188-
private static ServiceController AssertHasDependent(ServiceController controller, string serviceName, string displayName)
189-
{
190-
var dependent = FindService(controller.DependentServices, serviceName, displayName);
191-
Assert.NotNull(dependent);
192-
193-
return dependent;
194-
}
195-
196-
private static ServiceController AssertDependsOn(ServiceController controller, string serviceName, string displayName)
197-
{
198-
var dependency = FindService(controller.ServicesDependedOn, serviceName, displayName);
199-
Assert.NotNull(dependency);
200-
201-
return dependency;
202-
}
203-
204-
private static ServiceController FindService(ServiceController[] services, string serviceName, string displayName)
205-
{
206-
foreach (ServiceController service in services)
207-
{
208-
if (service.ServiceName == serviceName && service.DisplayName == displayName)
209-
{
210-
return service;
211-
}
212-
}
213-
214-
return null;
215-
}
216186
}
217187
}

src/libraries/System.ServiceProcess.ServiceController/tests/TestServiceProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ private void CreateTestServices()
106106
testServiceInstaller.ServicesDependedOn = new string[] { _dependentServices.TestServiceName };
107107
}
108108

109-
var comparer = PlatformDetection.IsNetFramework ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal; // .NET Framework upper cases the name
110109
string processName = Process.GetCurrentProcess().MainModule.FileName;
111110
string entryPointName = typeof(TestService).Assembly.Location;
112111
string arguments = TestServiceName;

0 commit comments

Comments
 (0)