Skip to content

Commit 1f786d4

Browse files
committed
Revert "revert "use collection expressions in (non-test) sources (dotnet#10758)""
This reverts commit 588aa6b.
1 parent 588aa6b commit 1f786d4

File tree

112 files changed

+378
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+378
-394
lines changed

src/Build/BackEnd/BuildManager/BuildManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ IEnumerable<ILogger> AppendDebuggingLoggers(IEnumerable<ILogger> loggers)
668668

669669
var logger = new BinaryLogger { Parameters = binlogPath };
670670

671-
return (loggers ?? Enumerable.Empty<ILogger>()).Concat(new[] { logger });
671+
return (loggers ?? [logger]);
672672
}
673673

674674
void InitializeCaches()
@@ -1522,7 +1522,7 @@ private BuildRequestConfiguration CreateConfiguration(Project project, BuildRequ
15221522

15231523
if (existingConfiguration == null)
15241524
{
1525-
existingConfiguration = new BuildRequestConfiguration(GetNewConfigurationId(), new BuildRequestData(newInstance, Array.Empty<string>()), null /* use the instance's tools version */);
1525+
existingConfiguration = new BuildRequestConfiguration(GetNewConfigurationId(), new BuildRequestData(newInstance, []), null /* use the instance's tools version */);
15261526
}
15271527
else
15281528
{
@@ -1830,7 +1830,7 @@ void IssueBuildSubmissionToSchedulerImpl(BuildSubmission submission, bool allowM
18301830
}
18311831
}
18321832

1833-
BuildRequestBlocker blocker = new BuildRequestBlocker(-1, Array.Empty<string>(), new[] { submission.BuildRequest });
1833+
BuildRequestBlocker blocker = new BuildRequestBlocker(-1, [], [submission.BuildRequest]);
18341834

18351835
HandleNewRequest(Scheduler.VirtualNode, blocker);
18361836
}

src/Build/BackEnd/BuildManager/BuildSubmission.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public override BuildResult Execute()
187187
ExecuteAsync(null, null, _legacyThreadingSemantics);
188188
if (_legacyThreadingSemantics)
189189
{
190-
RequestBuilder.WaitWithBuilderThreadStart(new[] { WaitHandle }, false, legacyThreadingData, SubmissionId);
190+
RequestBuilder.WaitWithBuilderThreadStart([WaitHandle], false, legacyThreadingData, SubmissionId);
191191
}
192192
else
193193
{

src/Build/BackEnd/Client/MSBuildClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,11 @@ private bool TryLaunchServer()
467467

468468
try
469469
{
470-
string[] msBuildServerOptions = new string[] {
470+
string[] msBuildServerOptions =
471+
[
471472
"/nologo",
472473
"/nodemode:8"
473-
};
474+
];
474475
NodeLauncher nodeLauncher = new NodeLauncher();
475476
CommunicationsUtilities.Trace("Starting Server...");
476477
Process msbuildProcess = nodeLauncher.Start(_msbuildLocation, string.Join(" ", msBuildServerOptions), nodeId: 0);

src/Build/BackEnd/Client/MSBuildClientPacketPump.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,15 @@ private void RunReadLoop(Stream localStream, ManualResetEvent localPacketPumpShu
205205
// will be returned by WaitAny if multiple wait handles are signalled. We prefer to have the
206206
// terminate event triggered so that we cannot get into a situation where packets are being
207207
// spammed to the client and it never gets an opportunity to shutdown.
208-
WaitHandle[] handles = new WaitHandle[] {
209-
localPacketPumpShutdownEvent,
208+
WaitHandle[] handles =
209+
[
210+
localPacketPumpShutdownEvent,
210211
#if FEATURE_APM
211-
result.AsyncWaitHandle
212+
result.AsyncWaitHandle
212213
#else
213-
((IAsyncResult)readTask).AsyncWaitHandle
214+
((IAsyncResult)readTask).AsyncWaitHandle
214215
#endif
215-
};
216+
];
216217
int waitId = WaitHandle.WaitAny(handles);
217218
switch (waitId)
218219
{

src/Build/BackEnd/Components/Communications/DetouredNodeLauncher.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ public Process Start(string msbuildLocation, string commandLineArgs, int nodeId)
107107
FileAccessPolicy.AllowAll | FileAccessPolicy.ReportAccess);
108108

109109
// Support shared compilation
110-
info.FileAccessManifest.ChildProcessesToBreakawayFromSandbox = new BreakawayChildProcess[]
111-
{
110+
info.FileAccessManifest.ChildProcessesToBreakawayFromSandbox =
111+
[
112112
#if RUNTIME_TYPE_NETCORE
113113
new BreakawayChildProcess(NativeMethodsShared.IsWindows ? "dotnet.exe" : "dotnet", "vbcscompiler.dll", CommandLineArgsSubstringContainmentIgnoreCase: true)
114114
#else
115115
new BreakawayChildProcess(NativeMethodsShared.IsWindows ? "VBCSCompiler.exe" : "VBCSCompiler")
116116
#endif
117-
};
117+
];
118118
info.FileAccessManifest.MonitorChildProcesses = true;
119119
info.FileAccessManifest.IgnoreReparsePoints = true;
120120
info.FileAccessManifest.UseExtraThreadToDrainNtClose = false;

src/Build/BackEnd/Components/Communications/NodeEndpointInProc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private void PacketPumpProc()
420420
// will be returned by WaitAny if multiple wait handles are signalled. We prefer to have the
421421
// terminate event triggered so that we cannot get into a situation where packets are being
422422
// spammed to the endpoint and it never gets an opportunity to shutdown.
423-
WaitHandle[] handles = new WaitHandle[] { _terminatePacketPump, _packetAvailable };
423+
WaitHandle[] handles = [_terminatePacketPump, _packetAvailable];
424424

425425
bool exitLoop = false;
426426
do

src/Build/BackEnd/Components/Logging/ProjectLoggingContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private static ProjectStartedEventArgs CreateProjectStarted(
207207
{
208208
if (projectProperties is null)
209209
{
210-
properties = Enumerable.Empty<DictionaryEntry>();
210+
properties = [];
211211
}
212212
else if (Traits.LogAllEnvironmentVariables)
213213
{
@@ -218,7 +218,7 @@ private static ProjectStartedEventArgs CreateProjectStarted(
218218
properties = projectProperties.Filter(p => p is not EnvironmentDerivedProjectPropertyInstance || EnvironmentUtilities.IsWellKnownEnvironmentDerivedProperty(p.Name), p => new DictionaryEntry(p.Name, p.EvaluatedValue));
219219
}
220220

221-
items = projectItems?.GetCopyOnReadEnumerable(item => new DictionaryEntry(item.ItemType, new TaskItem(item))) ?? Enumerable.Empty<DictionaryEntry>();
221+
items = projectItems?.GetCopyOnReadEnumerable(item => new DictionaryEntry(item.ItemType, new TaskItem(item))) ?? [];
222222
}
223223

224224
if (projectProperties != null &&

src/Build/BackEnd/Components/ProjectCache/CacheContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public CacheContext(
3030
MSBuildFileSystemBase fileSystem,
3131
ProjectGraph? graph = null,
3232
IReadOnlyCollection<ProjectGraphEntryPoint>? graphEntryPoints = null)
33-
: this(pluginSettings, fileSystem, requestedTargets: Array.Empty<string>(), graph, graphEntryPoints)
33+
: this(pluginSettings, fileSystem, requestedTargets: [], graph, graphEntryPoints)
3434
{
3535
}
3636

src/Build/BackEnd/Components/ProjectCache/ProjectCacheService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public void PostCacheRequest(CacheRequest cacheRequest, CancellationToken cancel
454454

455455
BuildRequestData buildRequest = new BuildRequestData(
456456
cacheRequest.Configuration.Project,
457-
cacheRequest.Submission.BuildRequestData?.TargetNames.ToArray() ?? Array.Empty<string>());
457+
cacheRequest.Submission.BuildRequestData?.TargetNames.ToArray() ?? []);
458458
BuildEventContext buildEventContext = _loggingService.CreateProjectCacheBuildEventContext(
459459
cacheRequest.Submission.SubmissionId,
460460
evaluationId: cacheRequest.Configuration.Project.EvaluationId,
@@ -650,7 +650,7 @@ private IReadOnlyCollection<ProjectGraphEntryPoint> GetGraphEntryPoints(BuildReq
650650
}
651651
else
652652
{
653-
return new[] { new ProjectGraphEntryPoint(configuration.ProjectFullPath, globalProperties) };
653+
return [new ProjectGraphEntryPoint(configuration.ProjectFullPath, globalProperties)];
654654
}
655655

656656
static IReadOnlyCollection<ProjectGraphEntryPoint> GenerateGraphEntryPointsFromSolutionConfigurationXml(

src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/MSBuild.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ internal static List<string[]> CreateTargetLists(
504504
// Separate target invocations for each individual target.
505505
foreach (string targetName in targets)
506506
{
507-
targetLists.Add(new[] { targetName });
507+
targetLists.Add([targetName]);
508508
}
509509
}
510510
else

0 commit comments

Comments
 (0)