Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cc8f589
Make BuildRequestEngine.TraceEngine calls allocation-free
DustinCampbell Apr 16, 2026
5226052
BuildRequestEngine: Don't re-compute "trace" file path
DustinCampbell Apr 16, 2026
f1c08f2
Make Scheduler.TraceScheduler calls allocation-free
DustinCampbell Apr 16, 2026
28064fa
Scheduler: Don't re-compute "trace" and "state" file paths
DustinCampbell Apr 16, 2026
2a483d2
Clean up ErrorUtilities a bit
DustinCampbell Apr 16, 2026
ed7affe
Make ErrorUtilities.DebugTraceMessage allocation-free
DustinCampbell Apr 16, 2026
327ff7d
Make ErrorUtilities.VerifyThrow allocation-free
DustinCampbell Apr 16, 2026
e329f4e
Update ErrorUtiliites.VerifyThrow callers
DustinCampbell Apr 16, 2026
7490b4f
Remove VerifyThrowInternalError in favor of VerifyThrow
DustinCampbell Apr 16, 2026
f574880
Make ErrorUtilities.ThrowInternalError allocation-free
DustinCampbell Apr 16, 2026
58638be
Update ErrorUtilities.ThrowInternalError callers
DustinCampbell Apr 16, 2026
fab065b
Move several ErrorUtilities members to FrameworkErrorUtilities
DustinCampbell Apr 16, 2026
8afc02e
Fix ErrorUtilities.DebugTraceMessage call
DustinCampbell Apr 16, 2026
ae2651e
Remove errant space character
DustinCampbell Apr 16, 2026
2ebdc96
Update ErrorUtilities calls that were written to avoid boxing
DustinCampbell Apr 16, 2026
26537b2
Remove BuildRequestEngineStatus.Box() extension method
DustinCampbell Apr 16, 2026
6ad13d2
Reduce potential for boxing in StringBuilderHelper
DustinCampbell Apr 16, 2026
45c1ca7
Update ErrorUtilities_Tests
DustinCampbell Apr 16, 2026
6c961d4
Fix a couple of calls after merge with main
DustinCampbell Apr 21, 2026
f8bc586
Merge branch 'main' into allocation-free-formatting
DustinCampbell May 6, 2026
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
21 changes: 9 additions & 12 deletions src/Build/BackEnd/BuildManager/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ private void LoadSolutionIntoConfiguration(BuildRequestConfiguration config, Bui
return;
}

ErrorUtilities.VerifyThrow(FileUtilities.IsSolutionFilename(config.ProjectFullPath), "{0} is not a solution", config.ProjectFullPath);
ErrorUtilities.VerifyThrow(FileUtilities.IsSolutionFilename(config.ProjectFullPath), $"{config.ProjectFullPath} is not a solution");

var buildEventContext = request.BuildEventContext;
if (buildEventContext == BuildEventContext.Invalid)
Expand Down Expand Up @@ -1899,7 +1899,7 @@ private void ProcessPacket(int node, INodePacket packet)
break;

default:
ErrorUtilities.ThrowInternalError("Unexpected packet received by BuildManager: {0}", packet.Type);
ErrorUtilities.ThrowInternalError($"Unexpected packet received by BuildManager: {packet.Type}");
break;
}
}
Expand Down Expand Up @@ -2393,7 +2393,7 @@ private void VerifyStateInternal(BuildManagerState requiredState)
{
if (_buildManagerState != requiredState)
{
ErrorUtilities.ThrowInternalError("Expected state {0}, actual state {1}", requiredState, _buildManagerState);
ErrorUtilities.ThrowInternalError($"Expected state {requiredState}, actual state {_buildManagerState}");
}
}

Expand Down Expand Up @@ -2742,7 +2742,7 @@ private void HandleNodeShutdown(int node, NodeShutdown shutdownPacket)

_shuttingDown = true;
_executionCancellationTokenSource?.Cancel();
ErrorUtilities.VerifyThrow(_activeNodes.Contains(node), "Unexpected shutdown from node {0} which shouldn't exist.", node);
ErrorUtilities.VerifyThrow(_activeNodes.Contains(node), $"Unexpected shutdown from node {node} which shouldn't exist.");
_activeNodes.Remove(node);

if (shutdownPacket.Reason != NodeShutdownReason.Requested)
Expand Down Expand Up @@ -2945,7 +2945,7 @@ private void PerformSchedulingActions(IEnumerable<ScheduleResponse> responses)
break;

default:
ErrorUtilities.ThrowInternalError("Scheduling action {0} not handled.", response.Action);
ErrorUtilities.ThrowInternalError($"Scheduling action {response.Action} not handled.");
break;
}
}
Expand Down Expand Up @@ -3381,17 +3381,14 @@ private static void LogDeferredMessages(ILoggingService loggingService, IEnumera
/// Ensures that the packet type matches the expected type
/// </summary>
/// <typeparam name="I">The instance-type of packet being expected</typeparam>
private static I ExpectPacketType<I>(INodePacket packet, NodePacketType expectedType) where I : class, INodePacket
private static I ExpectPacketType<I>(INodePacket packet, NodePacketType expectedType)
where I : class, INodePacket
{
I? castPacket = packet as I;

// PERF: Not using VerifyThrow here to avoid boxing of expectedType.
if (castPacket == null)
{
ErrorUtilities.ThrowInternalError("Incorrect packet type: {0} should have been {1}", packet.Type, expectedType);
}
ErrorUtilities.VerifyThrow(castPacket != null, $"Incorrect packet type: {packet.Type} should have been {expectedType}");

return castPacket!;
return castPacket;
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions src/Build/BackEnd/BuildManager/BuildSubmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ protected internal override void CheckResultValidForCompletion(BuildResult resul
// this one.)
if (result.ConfigurationId != BuildRequest?.ConfigurationId)
{
ErrorUtilities.ThrowInternalError("BuildResult configuration ({0}) doesn't match BuildRequest configuration ({1})",
result.ConfigurationId, BuildRequest?.ConfigurationId);
ErrorUtilities.ThrowInternalError($"BuildResult configuration ({result.ConfigurationId}) doesn't match BuildRequest configuration ({BuildRequest?.ConfigurationId})");
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Build/BackEnd/BuildManager/LegacyThreadingData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal void RegisterSubmissionForLegacyThread(int submissionId)
{
lock (_legacyThreadingEventsLock)
{
ErrorUtilities.VerifyThrow(!_legacyThreadingEventsById.ContainsKey(submissionId), "Submission {0} should not already be registered with LegacyThreadingData", submissionId);
ErrorUtilities.VerifyThrow(!_legacyThreadingEventsById.ContainsKey(submissionId), $"Submission {submissionId} should not already be registered with LegacyThreadingData");

_legacyThreadingEventsById[submissionId] = new Tuple<AutoResetEvent, ManualResetEvent>(
new AutoResetEvent(false),
Expand All @@ -104,7 +104,7 @@ internal void UnregisterSubmissionForLegacyThread(int submissionId)
{
lock (_legacyThreadingEventsLock)
{
ErrorUtilities.VerifyThrow(_legacyThreadingEventsById.ContainsKey(submissionId), "Submission {0} should have been previously registered with LegacyThreadingData", submissionId);
ErrorUtilities.VerifyThrow(_legacyThreadingEventsById.ContainsKey(submissionId), $"Submission {submissionId} should have been previously registered with LegacyThreadingData");

// Dispose the events
_legacyThreadingEventsById[submissionId].Item1?.Dispose();
Expand All @@ -127,7 +127,7 @@ internal WaitHandle GetStartRequestBuilderMainThreadEventForSubmission(int submi
_legacyThreadingEventsById.TryGetValue(submissionId, out legacyThreadingEvents);
}

ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, "We're trying to wait on the legacy thread for submission {0}, but that submission has not been registered.", submissionId);
ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, $"We're trying to wait on the legacy thread for submission {submissionId}, but that submission has not been registered.");

return legacyThreadingEvents.Item1;
}
Expand All @@ -145,7 +145,7 @@ internal Task GetLegacyThreadInactiveTask(int submissionId)
_legacyThreadingEventsById.TryGetValue(submissionId, out legacyThreadingEvents);
}

ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, "We're trying to track when the legacy thread for submission {0} goes inactive, but that submission has not been registered.", submissionId);
ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, $"We're trying to track when the legacy thread for submission {submissionId} goes inactive, but that submission has not been registered.");

return legacyThreadingEvents.Item2.ToTask();
}
Expand All @@ -168,7 +168,7 @@ internal void SignalLegacyThreadStart(RequestBuilder instance)
_legacyThreadingEventsById.TryGetValue(submissionId, out legacyThreadingEvents);
}

ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, "We're trying to signal that the legacy thread is ready for submission {0} to execute, but that submission has not been registered", submissionId);
ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, $"We're trying to signal that the legacy thread is ready for submission {submissionId} to execute, but that submission has not been registered");

// signal that this submission is currently controlling the legacy thread
legacyThreadingEvents.Item1.Set();
Expand All @@ -190,7 +190,7 @@ internal void SignalLegacyThreadEnd(int submissionId)
_legacyThreadingEventsById.TryGetValue(submissionId, out legacyThreadingEvents);
}

ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, "We're trying to signal that submission {0} is done with the legacy thread, but that submission has not been registered", submissionId);
ErrorUtilities.VerifyThrow(legacyThreadingEvents != null, $"We're trying to signal that submission {submissionId} is done with the legacy thread, but that submission has not been registered");

// The legacy thread is now idle
legacyThreadingEvents.Item2.Set();
Expand Down
4 changes: 2 additions & 2 deletions src/Build/BackEnd/Client/MSBuildClientPacketPump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void RunReadLoop(Stream localStream, ManualResetEvent localPacketPumpShu
}
else
{
ErrorUtilities.ThrowInternalError("Incomplete header read. {0} of {1} bytes read", headerBytesRead, headerByte.Length);
ErrorUtilities.ThrowInternalError($"Incomplete header read. {headerBytesRead} of {headerByte.Length} bytes read");
}
}

Expand Down Expand Up @@ -321,7 +321,7 @@ private void RunReadLoop(Stream localStream, ManualResetEvent localPacketPumpShu
break;

default:
ErrorUtilities.ThrowInternalError("WaitId {0} out of range.", waitId);
ErrorUtilities.ThrowInternalError($"WaitId {waitId} out of range.");
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void ReplaceFactory(BuildComponentType componentType, BuildComponentFacto
/// <param name="instance">The instance to be registered.</param>
public void ReplaceFactory(BuildComponentType componentType, IBuildComponent instance)
{
ErrorUtilities.VerifyThrow(_componentEntriesByType[componentType].Pattern == CreationPattern.Singleton, "Previously existing factory for type {0} was not a singleton factory.", componentType);
ErrorUtilities.VerifyThrow(_componentEntriesByType[componentType].Pattern == CreationPattern.Singleton, $"Previously existing factory for type {componentType} was not a singleton factory.");
_componentEntriesByType[componentType] = new BuildComponentEntry(componentType, instance);
}

Expand All @@ -160,7 +160,7 @@ public IBuildComponent GetComponent(BuildComponentType type)
{
if (!_componentEntriesByType.TryGetValue(type, out BuildComponentEntry componentEntry))
{
ErrorUtilities.ThrowInternalError("No factory registered for component type {0}", type);
ErrorUtilities.ThrowInternalError($"No factory registered for component type {type}");
}

return componentEntry.GetInstance(_host);
Expand Down
Loading
Loading