Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Build/BackEnd/BuildManager/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ IEnumerable<ILogger> AppendDebuggingLoggers(IEnumerable<ILogger> loggers)

var logger = new BinaryLogger { Parameters = binlogPath };

return (loggers ?? Enumerable.Empty<ILogger>()).Concat(new[] { logger });
return (loggers ?? [logger]);
}

void InitializeCaches()
Expand Down Expand Up @@ -1522,7 +1522,7 @@ private BuildRequestConfiguration CreateConfiguration(Project project, BuildRequ

if (existingConfiguration == null)
{
existingConfiguration = new BuildRequestConfiguration(GetNewConfigurationId(), new BuildRequestData(newInstance, Array.Empty<string>()), null /* use the instance's tools version */);
existingConfiguration = new BuildRequestConfiguration(GetNewConfigurationId(), new BuildRequestData(newInstance, []), null /* use the instance's tools version */);
}
else
{
Expand Down Expand Up @@ -1830,7 +1830,7 @@ void IssueBuildSubmissionToSchedulerImpl(BuildSubmission submission, bool allowM
}
}

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

HandleNewRequest(Scheduler.VirtualNode, blocker);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/BuildManager/BuildSubmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public override BuildResult Execute()
ExecuteAsync(null, null, _legacyThreadingSemantics);
if (_legacyThreadingSemantics)
{
RequestBuilder.WaitWithBuilderThreadStart(new[] { WaitHandle }, false, legacyThreadingData, SubmissionId);
RequestBuilder.WaitWithBuilderThreadStart([WaitHandle], false, legacyThreadingData, SubmissionId);
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions src/Build/BackEnd/Client/MSBuildClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,11 @@ private bool TryLaunchServer()

try
{
string[] msBuildServerOptions = new string[] {
string[] msBuildServerOptions =
[
"/nologo",
"/nodemode:8"
};
];
NodeLauncher nodeLauncher = new NodeLauncher();
CommunicationsUtilities.Trace("Starting Server...");
Process msbuildProcess = nodeLauncher.Start(_msbuildLocation, string.Join(" ", msBuildServerOptions), nodeId: 0);
Expand Down
11 changes: 6 additions & 5 deletions src/Build/BackEnd/Client/MSBuildClientPacketPump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,15 @@ private void RunReadLoop(Stream localStream, ManualResetEvent localPacketPumpShu
// will be returned by WaitAny if multiple wait handles are signalled. We prefer to have the
// terminate event triggered so that we cannot get into a situation where packets are being
// spammed to the client and it never gets an opportunity to shutdown.
WaitHandle[] handles = new WaitHandle[] {
localPacketPumpShutdownEvent,
WaitHandle[] handles =
[
localPacketPumpShutdownEvent,
#if FEATURE_APM
result.AsyncWaitHandle
result.AsyncWaitHandle
#else
((IAsyncResult)readTask).AsyncWaitHandle
((IAsyncResult)readTask).AsyncWaitHandle
#endif
};
];
int waitId = WaitHandle.WaitAny(handles);
switch (waitId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ public Process Start(string msbuildLocation, string commandLineArgs, int nodeId)
FileAccessPolicy.AllowAll | FileAccessPolicy.ReportAccess);

// Support shared compilation
info.FileAccessManifest.ChildProcessesToBreakawayFromSandbox = new BreakawayChildProcess[]
{
info.FileAccessManifest.ChildProcessesToBreakawayFromSandbox =
[
#if RUNTIME_TYPE_NETCORE
new BreakawayChildProcess(NativeMethodsShared.IsWindows ? "dotnet.exe" : "dotnet", "vbcscompiler.dll", CommandLineArgsSubstringContainmentIgnoreCase: true)
#else
new BreakawayChildProcess(NativeMethodsShared.IsWindows ? "VBCSCompiler.exe" : "VBCSCompiler")
#endif
};
];
info.FileAccessManifest.MonitorChildProcesses = true;
info.FileAccessManifest.IgnoreReparsePoints = true;
info.FileAccessManifest.UseExtraThreadToDrainNtClose = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private void PacketPumpProc()
// will be returned by WaitAny if multiple wait handles are signalled. We prefer to have the
// terminate event triggered so that we cannot get into a situation where packets are being
// spammed to the endpoint and it never gets an opportunity to shutdown.
WaitHandle[] handles = new WaitHandle[] { _terminatePacketPump, _packetAvailable };
WaitHandle[] handles = [_terminatePacketPump, _packetAvailable];

bool exitLoop = false;
do
Expand Down
4 changes: 2 additions & 2 deletions src/Build/BackEnd/Components/Logging/ProjectLoggingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static ProjectStartedEventArgs CreateProjectStarted(
{
if (projectProperties is null)
{
properties = Enumerable.Empty<DictionaryEntry>();
properties = [];
}
else if (Traits.LogAllEnvironmentVariables)
{
Expand All @@ -218,7 +218,7 @@ private static ProjectStartedEventArgs CreateProjectStarted(
properties = projectProperties.Filter(p => p is not EnvironmentDerivedProjectPropertyInstance || EnvironmentUtilities.IsWellKnownEnvironmentDerivedProperty(p.Name), p => new DictionaryEntry(p.Name, p.EvaluatedValue));
}

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

if (projectProperties != null &&
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/ProjectCache/CacheContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CacheContext(
MSBuildFileSystemBase fileSystem,
ProjectGraph? graph = null,
IReadOnlyCollection<ProjectGraphEntryPoint>? graphEntryPoints = null)
: this(pluginSettings, fileSystem, requestedTargets: Array.Empty<string>(), graph, graphEntryPoints)
: this(pluginSettings, fileSystem, requestedTargets: [], graph, graphEntryPoints)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public void PostCacheRequest(CacheRequest cacheRequest, CancellationToken cancel

BuildRequestData buildRequest = new BuildRequestData(
cacheRequest.Configuration.Project,
cacheRequest.Submission.BuildRequestData?.TargetNames.ToArray() ?? Array.Empty<string>());
cacheRequest.Submission.BuildRequestData?.TargetNames.ToArray() ?? []);
BuildEventContext buildEventContext = _loggingService.CreateProjectCacheBuildEventContext(
cacheRequest.Submission.SubmissionId,
evaluationId: cacheRequest.Configuration.Project.EvaluationId,
Expand Down Expand Up @@ -650,7 +650,7 @@ private IReadOnlyCollection<ProjectGraphEntryPoint> GetGraphEntryPoints(BuildReq
}
else
{
return new[] { new ProjectGraphEntryPoint(configuration.ProjectFullPath, globalProperties) };
return [new ProjectGraphEntryPoint(configuration.ProjectFullPath, globalProperties)];
}

static IReadOnlyCollection<ProjectGraphEntryPoint> GenerateGraphEntryPointsFromSolutionConfigurationXml(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ internal static List<string[]> CreateTargetLists(
// Separate target invocations for each individual target.
foreach (string targetName in targets)
{
targetLists.Add(new[] { targetName });
targetLists.Add([targetName]);
}
}
else
Expand Down
8 changes: 4 additions & 4 deletions src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public async Task BlockOnTargetInProgress(int blockingGlobalRequestId, string bl

RaiseOnBlockedRequest(blockingGlobalRequestId, blockingTarget, partialBuildResult);

WaitHandle[] handles = new WaitHandle[] { _terminateEvent, _continueEvent };
WaitHandle[] handles = [_terminateEvent, _continueEvent];

int handle;
if (IsBuilderUsingLegacyThreadingSemantics(_componentHost, _requestEntry))
Expand Down Expand Up @@ -448,7 +448,7 @@ public void Reacquire()
VerifyIsNotZombie();
RaiseOnBlockedRequest(_requestEntry.Request.GlobalRequestId, String.Empty);

WaitHandle[] handles = new WaitHandle[] { _terminateEvent, _continueEvent };
WaitHandle[] handles = [_terminateEvent, _continueEvent];

int handle = WaitHandle.WaitAny(handles);

Expand Down Expand Up @@ -506,7 +506,7 @@ public int RequestCores(object monitorLockObject, int requestedCores, bool waitF
RaiseResourceRequest(ResourceRequest.CreateAcquireRequest(_requestEntry.Request.GlobalRequestId, requestedCores, waitForCores));

// Wait for one of two events to be signaled: 1) The build was canceled, 2) The response to our request was received.
WaitHandle[] waitHandles = new WaitHandle[] { _terminateEvent, responseEvent };
WaitHandle[] waitHandles = [_terminateEvent, responseEvent];
int waitResult;

// Drop the lock so that the same task can call ReleaseCores from other threads to unblock itself.
Expand Down Expand Up @@ -957,7 +957,7 @@ private async Task<BuildResult[]> StartNewBuildRequests(FullyQualifiedBuildReque
BuildResult[] results;
if (waitForResults)
{
WaitHandle[] handles = new WaitHandle[] { _terminateEvent, _continueEvent };
WaitHandle[] handles = [_terminateEvent, _continueEvent];

int handle;
if (IsBuilderUsingLegacyThreadingSemantics(_componentHost, _requestEntry))
Expand Down
12 changes: 6 additions & 6 deletions src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ public bool BuildProjectFile(string projectFileName, string[] targetNames, Syste
{
VerifyActiveProxy();
return BuildProjectFilesInParallel(
new string[] { projectFileName },
[projectFileName],
targetNames,
new IDictionary[] { globalProperties },
new IDictionary[] { targetOutputs },
new string[] { toolsVersion },
[globalProperties],
[targetOutputs],
[toolsVersion],
true,
false);
}
Expand Down Expand Up @@ -1205,8 +1205,8 @@ private async Task<BuildEngineResult> BuildProjectFilesInParallelAsync(string[]
BuildResult[] results = await builderCallback.BuildProjects(
projectFileNames,
propertyDictionaries,
toolsVersion ?? Array.Empty<string>(),
targetNames ?? Array.Empty<string>(),
toolsVersion ?? [],
targetNames ?? [],
waitForResults: true,
skipNonexistentTargets: skipNonexistentTargets);

Expand Down
14 changes: 7 additions & 7 deletions src/Build/BackEnd/Components/Scheduler/SchedulableRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public IEnumerable<string> ActiveTargets
{
get
{
VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Yielding, SchedulableRequestState.Blocked, SchedulableRequestState.Executing });
VerifyOneOfStates([SchedulableRequestState.Yielding, SchedulableRequestState.Blocked, SchedulableRequestState.Executing]);
return _activeTargetsWhenBlocked;
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ public void Reacquire()
/// <param name="blockingTarget">Target that we are blocked on which is being built by <paramref name="blockingRequest"/></param>
public void BlockByRequest(SchedulableRequest blockingRequest, string[] activeTargets, string blockingTarget = null)
{
VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Blocked, SchedulableRequestState.Executing });
VerifyOneOfStates([SchedulableRequestState.Blocked, SchedulableRequestState.Executing]);
ErrorUtilities.VerifyThrowArgumentNull(blockingRequest, nameof(blockingRequest));
ErrorUtilities.VerifyThrowArgumentNull(activeTargets, nameof(activeTargets));
ErrorUtilities.VerifyThrow(BlockingTarget == null, "Cannot block again if we're already blocked on a target");
Expand All @@ -350,7 +350,7 @@ public void BlockByRequest(SchedulableRequest blockingRequest, string[] activeTa
// to also execute, then that request is not unscheduled (because it was running on the node) and it is not executing (because this condition
// can only occur against requests which are executing on the same node and since the request which called this method is the one currently
// executing on that node, that means the request it is blocked by must either be itself blocked or ready.)
blockingRequest.VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Yielding, SchedulableRequestState.Blocked, SchedulableRequestState.Ready, SchedulableRequestState.Unscheduled });
blockingRequest.VerifyOneOfStates([SchedulableRequestState.Yielding, SchedulableRequestState.Blocked, SchedulableRequestState.Ready, SchedulableRequestState.Unscheduled]);

// Update our list of active targets. This has to be done before we detect circular dependencies because we use this information to detect
// re-entrancy circular dependencies.
Expand All @@ -371,7 +371,7 @@ public void BlockByRequest(SchedulableRequest blockingRequest, string[] activeTa
/// </summary>
public void UnblockWithPartialResultForBlockingTarget(BuildResult result)
{
VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Blocked, SchedulableRequestState.Unscheduled });
VerifyOneOfStates([SchedulableRequestState.Blocked, SchedulableRequestState.Unscheduled]);
ErrorUtilities.VerifyThrowArgumentNull(result, nameof(result));

BlockingRequestKey key = new BlockingRequestKey(result);
Expand All @@ -384,7 +384,7 @@ public void UnblockWithPartialResultForBlockingTarget(BuildResult result)
/// </summary>
public void UnblockWithResult(BuildResult result)
{
VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Blocked, SchedulableRequestState.Unscheduled });
VerifyOneOfStates([SchedulableRequestState.Blocked, SchedulableRequestState.Unscheduled]);
ErrorUtilities.VerifyThrowArgumentNull(result, nameof(result));

BlockingRequestKey key = new BlockingRequestKey(result);
Expand All @@ -400,7 +400,7 @@ public void ResumeExecution(int nodeId)
{
ErrorUtilities.VerifyThrow(_assignedNodeId == Scheduler.InvalidNodeId || _assignedNodeId == nodeId, "Request must always resume on the same node on which it was started.");

VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Ready, SchedulableRequestState.Unscheduled });
VerifyOneOfStates([SchedulableRequestState.Ready, SchedulableRequestState.Unscheduled]);
ErrorUtilities.VerifyThrow((_state == SchedulableRequestState.Ready) || !_schedulingData.IsRequestScheduled(this), "Another instance of request {0} is already scheduled.", _request.GlobalRequestId);
ErrorUtilities.VerifyThrow(!_schedulingData.IsNodeWorking(nodeId), "Cannot resume execution of request {0} because node {1} is already working.", _request.GlobalRequestId, nodeId);

Expand All @@ -416,7 +416,7 @@ public void ResumeExecution(int nodeId)
/// </summary>
public void Complete(BuildResult result)
{
VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Ready, SchedulableRequestState.Executing, SchedulableRequestState.Unscheduled });
VerifyOneOfStates([SchedulableRequestState.Ready, SchedulableRequestState.Executing, SchedulableRequestState.Unscheduled]);
ErrorUtilities.VerifyThrow(_state != SchedulableRequestState.Ready || result.CircularDependency, "Request can only be Completed from the Ready state if the result indicates a circular dependency occurred.");
ErrorUtilities.VerifyThrow(_requestsWeAreBlockedBy.Count == 0, "We can't be complete if we are still blocked on requests.");

Expand Down
4 changes: 2 additions & 2 deletions src/Build/BackEnd/Components/Scheduler/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ private void HandleRequestBlockedOnInProgressTarget(SchedulableRequest blockedRe

// The request we blocked on couldn't have been executing (because we are) so it must either be yielding (which is ok because
// it isn't modifying its own state, just running a background process), ready, or still blocked.
blockingRequest.VerifyOneOfStates(new SchedulableRequestState[] { SchedulableRequestState.Yielding, SchedulableRequestState.Ready, SchedulableRequestState.Blocked });
blockingRequest.VerifyOneOfStates([SchedulableRequestState.Yielding, SchedulableRequestState.Ready, SchedulableRequestState.Blocked]);

// detect the case for https://github.com/dotnet/msbuild/issues/3047
// if we have partial results AND blocked and blocking share the same configuration AND are blocked on each other
Expand All @@ -1651,7 +1651,7 @@ private void HandleRequestBlockedOnInProgressTarget(SchedulableRequest blockedRe
private void HandleRequestBlockedOnResultsTransfer(SchedulableRequest parentRequest, List<ScheduleResponse> responses)
{
// Create the new request which will go to the configuration's results node.
BuildRequest newRequest = new BuildRequest(parentRequest.BuildRequest.SubmissionId, BuildRequest.ResultsTransferNodeRequestId, parentRequest.BuildRequest.ConfigurationId, Array.Empty<string>(), null, parentRequest.BuildRequest.BuildEventContext, parentRequest.BuildRequest, parentRequest.BuildRequest.BuildRequestDataFlags);
BuildRequest newRequest = new BuildRequest(parentRequest.BuildRequest.SubmissionId, BuildRequest.ResultsTransferNodeRequestId, parentRequest.BuildRequest.ConfigurationId, [], null, parentRequest.BuildRequest.BuildEventContext, parentRequest.BuildRequest, parentRequest.BuildRequest.BuildRequestDataFlags);

// Assign a new global request id - always different from any other.
newRequest.GlobalRequestId = _nextGlobalRequestId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override SdkResultBase Resolve(SdkReference sdk, SdkResolverContextBase c

return FileUtilities.DirectoryExistsNoThrow(sdkPath)
? factory.IndicateSuccess(sdkPath, string.Empty)
: factory.IndicateFailure(new string[] { ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("DefaultSDKResolverError", sdk.Name, sdkPath) }, null);
: factory.IndicateFailure([ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("DefaultSDKResolverError", sdk.Name, sdkPath)], null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private SdkResult RequestSdkPathFromMainNode(int submissionId, SdkReference sdk,
SendPacket(packet);

// Wait for either the response or a shutdown event. Either event means this thread should return
WaitHandle.WaitAny(new WaitHandle[] { _responseReceivedEvent, ShutdownEvent });
WaitHandle.WaitAny([_responseReceivedEvent, ShutdownEvent]);

// Keep track of the element location of the reference
_lastResponse.ElementLocation = sdkReferenceLocation;
Expand Down
Loading