Skip to content

Conversation

stephentoub
Copy link
Member

This is based only on code inspection / static analysis / searching around. It is not based on profiling. I do not know how much of an impact any of these have; we could choose to cherry-pick from this if there are particular areas that demonstrate gains.

This is based only on code inspection / static analysis / searching around. It is not based on profiling.
@stephentoub
Copy link
Member Author

cc: @MihaZupan, fyi on the SearchValues usage

@stephentoub stephentoub requested a review from Copilot February 14, 2025 22:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request updates several components and unit tests to leverage newer and more efficient .NET features, simplifying asynchronous operations and collection enumeration while improving code readability. Key changes include:

  • Replacing manual string concatenation with string.Create under NET.
  • Using WaitAsync and AsTask for asynchronous operations in place of older patterns.
  • Switching from manual enumerator conversions (GetEnumerator().ToArray()) to direct ToArray() calls.
  • Refactoring thread naming and static field declarations to use string interpolation and readonly modifiers.
  • Updating unit tests to iterate over character ranges with a for loop and checking invalid characters using explicit conditions.

Changes

File Description
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs Improved string creation and wait logic based on target .NET version.
src/Build.UnitTests/Globbing/MSBuildGlob_Tests.cs Updated iteration over invalid path characters and using explicit arrays for file name chars.
src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs Switched from IndexOf to Contains for clarity.
src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs Changed thread identifier usage to Environment.CurrentManagedThreadId.
src/Build.UnitTests/BackEnd/CacheAggregator_Tests.cs Simplified collection enumerations using ToArray().
src/Build/BackEnd/Client/MSBuildClientPacketPump.cs Updated asynchronous read operations to use AsTask.
src/Build.UnitTests/FileUtilitiesRegex_Tests.cs Removed redundant regex match check.
src/Build/BackEnd/Components/FileAccesses/FileAccessManager.cs Updated string interpolation for file access prefix.
src/Build/BackEnd/Components/ProjectCache/ProjectCacheService.cs Removed unnecessary ContinueWith calls during asynchronous plugin initialization.
src/Build/BackEnd/BuildManager/BuildRequestEngine/BuildRequestEngine.cs Adjusted logging to use new thread id retrieval.
src/Build.UnitTests/BackEnd/ConfigCache_Tests.cs, CacheAggregator.cs, IsolateProjects_Tests.cs, ResultsCache_Tests.cs, ResultCacheBasedBuilds_Tests.cs Consolidated and simplified collection enumeration calls using ToArray().
src/Build/BackEnd/Components/Communications/NodeProviderInProc.cs, NodeEndpointInProc.cs, TranslatorExtensions.cs, LoggingService.cs Refactored thread naming, static fields, and lazy initialization to newer .NET constructs.

Copilot reviewed 191 out of 191 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/Build.UnitTests/Globbing/MSBuildGlob_Tests.cs:74

  • Verify that iterating from 0 to 127 covers all invalid path characters as provided by FileUtilities.InvalidPathChars; if the set includes characters outside this range, adjust the loop boundaries accordingly.
for (int i = 0; i < 128; i++)

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

  • Ensure that exceptions thrown during asynchronous plugin initialization remain intentionally unobserved; if not, consider adding proper error handling to capture and log any initialization failures.
_ = GetProjectCachePluginAsync(projectCacheDescriptor, projectGraph, buildRequestConfiguration: null, requestedTargets, cancellationToken);

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(am halfway done)

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

137 / 191

Copy link
Member

@SimaTian SimaTian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

30/191, review in progress.

@SimaTian
Copy link
Member

SimaTian commented Mar 4, 2025

100/191 so far, no issues.

This reverts commit aa508b8.

No need to worry about speed on this path so let's just match existing behavior.
@SimaTian
Copy link
Member

Perfstar results look promising - the PR has a visible positive impact on Evaluation.

Copy link
Member

@SimaTian SimaTian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want this one. I'll look if there is an easy way to resolve the conflicts and there is one comment from Rainer for the named pipes - do we want to revert that one so that we can merge the pipe change from @ccastanedaucf without issues, then revisit if necessary?

@SimaTian SimaTian enabled auto-merge March 14, 2025 14:42
@SimaTian SimaTian merged commit 1a41d7b into dotnet:main Mar 14, 2025
9 checks passed
@stephentoub
Copy link
Member Author

Thanks for getting it over the finish line, @SimaTian.

@stephentoub stephentoub deleted the lowhangingfruit branch March 14, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants