Skip to content

Migrate GetAssemblyVersion to IMultiThreadableTask#53948

Open
SimaTian wants to merge 4 commits intodotnet:mainfrom
SimaTian:migrate-get-assembly-version
Open

Migrate GetAssemblyVersion to IMultiThreadableTask#53948
SimaTian wants to merge 4 commits intodotnet:mainfrom
SimaTian:migrate-get-assembly-version

Conversation

@SimaTian
Copy link
Copy Markdown
Member

Migrates \GetAssemblyVersion\ to support \IMultiThreadableTask.

Changes

  • Pattern A (pure in-memory): attribute + interface + stub TaskEnvironment. Despite the task's name, it parses a NuGet version STRING (\NuGetVersion.TryParse) — no assembly file I/O, no env-var reads.
  • Adds 8 behavioral tests using start-gate pattern.

Supersedes

Part of the split of stuck merge-group PR #53116. This is the 4-of-5 split for \GetAssemblyVersion.

Copy link
Copy Markdown
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

Migrates GetAssemblyVersion to support MSBuild multithreaded execution by marking it multi-threadable and implementing IMultiThreadableTask, with unit tests validating behavior and concurrent execution.

Changes:

  • Add [MSBuildMultiThreadableTask] and implement IMultiThreadableTask on GetAssemblyVersion, including a TaskEnvironment property.
  • Add a new unit test suite covering interface/property shape, version parsing behavior, error handling, and concurrent execution.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Tasks/Microsoft.NET.Build.Tasks/GetAssemblyVersion.cs Adds multi-threading support metadata/interface and exposes TaskEnvironment for MSBuild injection.
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAGetAssemblyVersionMultiThreading.cs Adds behavioral + concurrency tests for the multi-threadable task migration.

SimaTian and others added 2 commits April 29, 2026 13:47
GetAssemblyVersion is a pure in-memory task that parses a NuGet version
string and extracts the assembly version portion. No file I/O or path
resolution is performed.

Migration changes:
- Added [MSBuildMultiThreadableTask] attribute
- Implemented IMultiThreadableTask interface
- Added TaskEnvironment property with #if NETFRAMEWORK fallback

Added comprehensive multithreading tests:
- Interface implementation verification
- TaskEnvironment property validation
- Version parsing correctness tests (simple and semantic versions)
- Invalid version error handling
- Concurrent execution with identical inputs (16 threads with start-gate)
- Concurrent execution with different inputs (8 threads)
- Output consistency verification

All tests use start-gate pattern (TaskCompletionSource) to avoid
barrier/Parallel.For deadlock anti-pattern from prior reviews.

Co-authored-by: Copilot <[email protected]>
@AlesProkop AlesProkop marked this pull request as ready for review May 5, 2026 10:23
Delegates the SDK's TaskEnvironmentDefaults and TaskEnvironmentHelper
shims to MSBuild's public TaskEnvironment.Fallback /
CreateWithProjectDirectoryAndEnvironment APIs (dotnet/msbuild#13462),
and drops the now-unused ProcessTaskEnvironmentDriver polyfill.

Pipelines are expected to fail until the consumed MSBuild API
target version is bumped to a build that exposes these APIs.

Co-authored-by: Copilot <[email protected]>
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.

4 participants