Migrate GetAssemblyIdentity to multithreaded execution model#13588
Migrate GetAssemblyIdentity to multithreaded execution model#13588jankratochvilcz wants to merge 3 commits intomainfrom
Conversation
Absolutize item.ItemSpec via TaskEnvironment.GetAbsolutePath() before AssemblyName.GetAssemblyName. Add tests for baseline behavior, project-relative resolution, output integrity, and metadata copying. Fixes #13571 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Migrates the GetAssemblyIdentity built-in task to MSBuild’s multithreaded execution model by resolving AssemblyFiles relative paths via TaskEnvironment.GetAbsolutePath() rather than Environment.CurrentDirectory, making path handling safe under concurrent project execution.
Changes:
- Mark
GetAssemblyIdentityas[MSBuildMultiThreadableTask], implementIMultiThreadableTask, and add aTaskEnvironmentproperty defaulting toTaskEnvironment.Fallback. - Absolutize each
AssemblyFilesitem at the task boundary before callingAssemblyName.GetAssemblyName(...), preserving existing per-item error/continue semantics. - Add new unit tests covering success, failure modes, project-directory relative resolution, and output/metadata behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Tasks/GetAssemblyIdentity.cs | Implements the multithreaded task contract and switches path resolution to TaskEnvironment.GetAbsolutePath() before reading assemblies. |
| src/Tasks.UnitTests/GetAssemblyIdentity_Tests.cs | Adds initial unit coverage for baseline behavior, error handling, project-relative resolution, and output integrity/metadata copying. |
There was a problem hiding this comment.
Generated by Expert Code Review (on open) for issue #13588 · ● 27.6M
There was a problem hiding this comment.
Generated by Expert Code Review (on open) for issue #13588 · ● 27.6M
There was a problem hiding this comment.
Review: Migrate GetAssemblyIdentity to multithreaded execution model
Verdict: Looks good ✅
This is a clean, well-executed migration that follows the established IMultiThreadableTask pattern (matching Copy.cs, Delete.cs, AssignTargetPath.cs).
Compatibility Analysis
No breaking changes detected. Key observations:
-
Error behavior preserved: The original
catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e))already catchesArgumentException, so invalid paths (empty strings, illegal characters) were already handled gracefully. The newGetAbsolutePathcatch block on line 79 intercepts the same exception type before it reachesAssemblyName.GetAssemblyName, producing the same MSB3441 error code via the same resource string. -
Output property safe: The
[Output] Assembliesitems useAssemblyName.FullNameas theirItemSpec— not any file path — so absolutized paths cannot leak into downstream task inputs. -
Error messages use original paths: All
Log.LogErrorWithCodeFromResourcescalls useitem.ItemSpec(the user's original input), not the absolutizedassemblyPath.
Migration Pattern Compliance
| Check | Status |
|---|---|
[MSBuildMultiThreadableTask] attribute |
✅ |
IMultiThreadableTask interface |
✅ |
TaskEnvironment default = Fallback |
✅ |
GetAbsolutePath with ArgumentException catch |
✅ |
| Error messages use original path | ✅ |
| Output properties not contaminated | ✅ |
| No environment variable usage to migrate | ✅ N/A |
| No process start to migrate | ✅ N/A |
Test Coverage
Excellent — 8 tests covering:
- ✅ Happy path (absolute path to real assembly)
- ✅ Non-existent file → MSB3441
- ✅ Non-assembly file → MSB3441
- ✅ Mixed batch (good + bad items processed independently)
- ✅ Empty
ItemSpec→ MSB3441 - ✅ Relative path resolution against project directory (the migration's core behavioral change)
- ✅ Output items don't contain absolutized paths
- ✅ Input metadata copied to output
Minor Nit
The test file has #nullable disable which conflicts with the "new files should always use nullable reference types" guidance, but matches the overwhelming convention in src/Tasks.UnitTests/. Low priority.
Generated by Expert Code Review (on open) for issue #13588 · ● 3.4M
Migrates the
GetAssemblyIdentitytask to MSBuild's multithreaded execution model, applying the absolutize-at-boundary pattern.Fixes #13571.
What changed
Relative
AssemblyFilespaths are now resolved viaTaskEnvironment.GetAbsolutePath()instead of relying onEnvironment.CurrentDirectory. This makes the task safe for concurrent execution across projects with different working directories.Validation
GetAssemblyIdentity_Tests— 8 tests covering baseline behavior, project-relative resolution, output integrity (Sin 1), and metadata copying.Tasks.UnitTestsbuild passes with 0 warnings.