Harden typed task parameter infrastructure - #14819
Merged
OvesN merged 1 commit intoAug 26, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens MSBuild’s typed task parameter infrastructure by ensuring malformed or relative AbsolutePath values don’t crash logging/forwarding/binlog replay and that invalid typed-item paths flow through normal parameter-binding error handling.
Changes:
- Wrap
FullPathmetadata failures when constructingTaskItem<T>so malformed paths surface asArgumentException(enabling MSB4030-style binding errors instead of unhandled exceptions). - Preserve
AbsolutePath.OriginalValue(relative input) when logging task parameters, forwardingTaskParameterEventArgs, and serializing task-parameter items into binlogs. - Add regression tests covering invalid path binding, task-parameter text formatting, event forwarding, and binlog round-tripping.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Utilities.UnitTests/TaskItem_Tests.cs | Adds regression test ensuring invalid path metadata results in ArgumentException. |
| src/Framework/TaskParameterEventArgs.cs | Preserves AbsolutePath.OriginalValue during task-parameter event serialization. |
| src/Framework/TaskItem_T.cs | Converts FullPath metadata failures into ArgumentException to integrate with binding error handling. |
| src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs | Preserves AbsolutePath.OriginalValue when writing task-parameter item lists to binlog. |
| src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs | Logs AbsolutePath parameters using OriginalValue (keeps relative input in logs). |
| src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs | Adds regression tests for logging text, event forwarding, and binlog serialization preserving relative values. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
OvesN
force-pushed
the
dev/veronikao/typed-parameter-infrastructure-fixes-upstream
branch
from
August 25, 2026 08:46
4244329 to
c04ef83
Compare
baronfel
approved these changes
Aug 25, 2026
baronfel
left a comment
Member
There was a problem hiding this comment.
LGTM overall - but I think we need to figure out a better pattern for the type extensibility.
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.
Context
These issues were found while migrating real in-box tasks to typed parameters. Direct task tests passed, but real MSBuild binding, malformed inputs, logging, event forwarding, and binlog replay exposed infrastructure gaps.
Changes Made
Malformed typed-item paths could escape as unhandled exceptions.
TaskItem<T>derives path values fromFullPath; malformed values could throwInvalidOperationException, bypassing normal parameter-binding error handling. The constructor now converts this toArgumentException, allowing MSBuild to report MSB4030.Real-world reproduction:
Before the fix, binding
ITaskItem<AbsolutePath>[]could terminate the node with an unhandled exception while evaluatingFullPath. After the fix, the project receives:Logging of
AbsolutePathtask parameters could crash or inflate paths.ItemGroupLoggingHelpertreatedAbsolutePathas an arbitrary value type and calledConvert.ChangeType, which throws becauseAbsolutePathis notIConvertible. Now we log absolute path correctly, using originally passed path in logsAbsolutePath.OriginalValue.Real-world reproduction:
With task-input logging enabled, MSBuild attempted to format the bound
AbsolutePathand failed with:The fixed output remains relative:
Forwarded task-parameter events lost relative path values.
TaskParameterEventArgsserializedAbsolutePaththroughToString(), replacing a value such asinput.txtwith its absolute form. Forwarding now serializesOriginalValue.Real-world example:
A distributed logger could therefore observe a different value depending on which node produced the event. Forwarded events now retain
input.txt.Binlog task-parameter serialization lost relative path values.
BuildEventArgsWriterhad the sameToString()behavior, so replayed binlogs differed from live output. Binlog serialization now preservesOriginalValue.Real-world example:
The live and replayed event streams now contain the same relative value.
Testing
Each fix has a dedicated regression test:
FromITaskItem_InvalidPath_ThrowsArgumentExceptionAbsolutePathTaskParameterTextUsesOriginalValueTaskParameterEventForwardingPreservesAbsolutePathOriginalValueBinaryLogSerializationPreservesAbsolutePathOriginalValueBinaryLogSerializationWritesEmptyItemSpecForDefaultAbsolutePathAll dedicated tests pass on net11.0 and net472. The full Debug build also succeeds.
Notes
This PR contains only typed-parameter infrastructure fixes. The task migrations and user documentation are in the stacked PR OvesN/msbuild#6.