Fix comparison in TaskHostParameters #12733
Merged
YuliiaKovalova merged 2 commits intomainfrom Nov 10, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements proper equality semantics for the TaskHostParameters struct by adding IEquatable<TaskHostParameters>, Equals, and GetHashCode implementations. The changes ensure that task host parameter comparisons correctly consider only the identity properties (Runtime, Architecture, and TaskHostFactoryExplicitlyRequested) and use case-insensitive string comparisons, while excluding path properties (DotnetHostPath and MSBuildAssemblyPath) from identity checks.
Key changes:
- Adds
IEquatable<TaskHostParameters>implementation with case-insensitive string comparison for Runtime and Architecture - Implements
GetHashCodeusing a manual hash code calculation compatible with .NET Framework 4.7.2 - Updates
ToDictionary()to useStringComparer.OrdinalIgnoreCasefor consistency - Refines
IdentityParametersMatchin TaskRegistry.cs to explicitly exclude path properties from exact match comparisons
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Framework/TaskHostParameters.cs | Implements IEquatable<TaskHostParameters>, adds Equals and GetHashCode methods, and updates ToDictionary to use case-insensitive string comparer |
| src/Build/Instance/TaskRegistry.cs | Removes path property comparisons from exact match logic in IdentityParametersMatch to align with the new equality implementation |
| .mcp.json | Adds MCP server configuration file (appears unrelated to the core PR purpose) |
Comments suppressed due to low confidence (1)
src/Build/Instance/TaskRegistry.cs:914
- With the new
GetHashCodeimplementation inTaskHostParameters, this code could be simplified to callobj.TaskIdentityParameters.GetHashCode()directly instead of manually computing hash codes for Runtime and Architecture. This would ensure consistency and reduce code duplication.
int runtimeHash = obj.TaskIdentityParameters.Runtime == null ? 0 : StringComparer.OrdinalIgnoreCase.GetHashCode(obj.TaskIdentityParameters.Runtime);
int architectureHash = obj.TaskIdentityParameters.Architecture == null ? 0 : StringComparer.OrdinalIgnoreCase.GetHashCode(obj.TaskIdentityParameters.Architecture);
d50ad2d to
4ee8cb0
Compare
MichalPavlik
approved these changes
Nov 10, 2025
This was referenced Nov 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change introduces a new read only struct that is used in Dictionary for caching in TaskRegistry
#12620
Without a proper equality check it spawns a new process due to mismatch.
Experimental insertion without extra allocation reported: https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/686770