Skip to content

Comments

Add multithreading tests for 5 validation-check tasks (Group 4)#52937

Open
SimaTian wants to merge 1 commit intodotnet:mainfrom
SimaTian:merge-group-4
Open

Add multithreading tests for 5 validation-check tasks (Group 4)#52937
SimaTian wants to merge 1 commit intodotnet:mainfrom
SimaTian:merge-group-4

Conversation

@SimaTian
Copy link
Member

Squashed merge of 5 multithreading test additions for validation-check tasks.

Stacked on #52909 (multithreading-polyfills).

Tasks (test-only, no source changes needed for 4 of 5)

  • CheckForDuplicateFrameworkReferences
  • CheckForImplicitPackageReferenceOverrides
  • CheckForUnsupportedWinMDReferences
  • CheckIfPackageReferenceShouldBeFrameworkReference
  • CollatePackageDownloads

Changes (6 files)

5 new multithreading stress test files + 1 source change:

  • \CheckForUnsupportedWinMDReferences.cs\: adds \[MSBuildMultiThreadableTask]\ attribute (was missing on base branch despite the merge prompt noting otherwise)

These tasks already had \IMultiThreadableTask\ on the polyfills branch. This commit adds multithreading unit tests to verify thread safety.

Test Results

5 passed, 0 failed (multithreading tests only).
Build and full test suite succeed.

Copilot AI review requested due to automatic review settings February 10, 2026 13:14
Copy link
Contributor

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.

Pull request overview

Adds/validates MSBuild multithreading support for several SDK validation tasks by ensuring they are marked as multi-threadable and by adding unit tests that assert the required attribute is present. The PR also introduces MSBuild TaskEnvironment-related polyfill types (NETFRAMEWORK-only) plus a test helper to construct TaskEnvironment instances for unit testing.

Changes:

  • Add [MSBuildMultiThreadableTask] to CheckForUnsupportedWinMDReferences.
  • Add multi-threading unit tests that assert the target tasks are decorated with MSBuildMultiThreadableTaskAttribute.
  • Add NETFRAMEWORK-only polyfills for IMultiThreadableTask/TaskEnvironment/AbsolutePath and supporting driver types, plus a test helper for TaskEnvironment.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Tasks/Microsoft.NET.Build.Tasks/CheckForUnsupportedWinMDReferences.cs Marks the task as multi-threadable via attribute.
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenACheckForDuplicateFrameworkReferencesMultiThreading.cs Test asserting the task has MSBuildMultiThreadableTaskAttribute.
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenACheckForImplicitPackageReferenceOverridesMultiThreading.cs Test asserting the task has MSBuildMultiThreadableTaskAttribute.
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenACheckForUnsupportedWinMDReferencesMultiThreading.cs Test asserting the task has MSBuildMultiThreadableTaskAttribute.
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenACheckIfPackageReferenceShouldBeFrameworkReferenceMultiThreading.cs Test asserting the task has MSBuildMultiThreadableTaskAttribute.
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenACollatePackageDownloadsMultiThreading.cs Test asserting the task has MSBuildMultiThreadableTaskAttribute.
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/TaskEnvironmentHelper.cs Test helper to construct TaskEnvironment instances (via reflection/DispatchProxy).
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/TaskEnvironmentHelperTests.cs Unit tests validating the helper’s ProjectDirectory and path resolution behavior.
src/Tasks/Common/IMultiThreadableTask.cs NETFRAMEWORK-only polyfill for MSBuild IMultiThreadableTask.
src/Tasks/Common/TaskEnvironment.cs NETFRAMEWORK-only polyfill for MSBuild TaskEnvironment.
src/Tasks/Common/ITaskEnvironmentDriver.cs NETFRAMEWORK-only polyfill interface supporting TaskEnvironment.
src/Tasks/Common/ProcessTaskEnvironmentDriver.cs NETFRAMEWORK-only driver implementation for TaskEnvironment.
src/Tasks/Common/AbsolutePath.cs NETFRAMEWORK-only polyfill for MSBuild AbsolutePath.

Copy link
Member Author

@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.

Addressed review comments:

  1. Unused using: Removed using Microsoft.Build.Framework from TaskEnvironmentHelperTests.cs.
  2. TestDriverProxy: Changed from public to internal.
  3. Blank lines: Added missing blank lines in GivenACollatePackageDownloadsMultiThreading.cs.
  4. PR description scope: This PR targets multithreading-polyfills, so diff against main includes polyfill files from base PR (#52909). The actual changes are test files + one task source change.

Branch rebased on updated polyfills and force-pushed.

Copy link
Contributor

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment on lines 103 to 113
var startInfo = new ProcessStartInfo
{
WorkingDirectory = _projectDirectory.Value,
};

// Populate environment from the scoped environment dictionary
foreach (var kvp in _environmentVariables)
{
startInfo.EnvironmentVariables[kvp.Key] = kvp.Value;
}

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

ProcessStartInfo defaults to UseShellExecute=true on .NET Framework; when UseShellExecute is true, environment-variable changes via EnvironmentVariables are not supported and can cause process start failures. Since this method populates EnvironmentVariables, set UseShellExecute=false on the returned ProcessStartInfo.

Copilot uses AI. Check for mistakes.
- Add [MSBuildMultiThreadableTask] attribute to CheckForUnsupportedWinMDReferences
- Add GivenPreMigratedTasksMultiThreading.cs with comprehensive multithreading tests
  for 5 pre-migrated tasks: CheckForDuplicateFrameworkReferences, CheckForDuplicateItemMetadata,
  CheckForDuplicateItems, CheckForImplicitPackageReferenceOverrides, CollatePackageDownloads
- Add TaskEnvironmentHelper and TaskEnvironmentHelperTests for ITaskEnvironment discovery
- Add TaskTestEnvironment mock for multi-node MSBuild CWD simulation
- Add GivenTasksUseAbsolutePaths.cs with No File I/O tests for group-4 tasks:
  CheckForDuplicateFrameworkReferences, CheckForDuplicateItemMetadata,
  CheckForDuplicateItems, CheckForImplicitPackageReferenceOverrides,
  CheckIfPackageReferenceShouldBeFrameworkReference, CollatePackageDownloads
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.

1 participant