Harden typed task parameter infrastructure - #7
Draft
OvesN wants to merge 2 commits into
Draft
Conversation
Add dedicated regression coverage for malformed typed items, AOT-safe path factories, live parameter logging, event forwarding, and binlog serialization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #
Context
These issues were found while migrating real in-box tasks to typed parameters in OvesN/msbuild#6. 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_ThrowsArgumentExceptionAbsolutePathTaskParameterTextUsesOriginalValueTaskParameterEventForwardingPreservesAbsolutePathOriginalValueBinaryLogSerializationPreservesAbsolutePathOriginalValueAll 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.