diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index bd6c30de67..4a8134cd03 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -1510,23 +1510,21 @@ private IRequestData GetRequestData(ProtocolConfig protocolConfig) private static List GetSources(TestRunRequestPayload testRunRequestPayload) { // TODO: This should also use hashset to only return distinct sources. - List sources = new(); - if (testRunRequestPayload.Sources != null - && testRunRequestPayload.Sources.Count > 0) + if (testRunRequestPayload.Sources is { Count: > 0 }) { - sources = testRunRequestPayload.Sources; + return testRunRequestPayload.Sources; } - else if (testRunRequestPayload.TestCases != null - && testRunRequestPayload.TestCases.Count > 0) + + if (testRunRequestPayload.TestCases is { Count: > 0 }) { - ISet sourcesSet = new HashSet(); + var sourcesSet = new HashSet(); foreach (var testCase in testRunRequestPayload.TestCases) { sourcesSet.Add(testCase.Source); } - sources = sourcesSet.ToList(); + return sourcesSet.ToList(); } - return sources; + return []; } }