Serialize whitespace-only Literal<T> values as elements instead of text (STUD-80981) - #405
Open
PavelDrg wants to merge 1 commit into
Open
Serialize whitespace-only Literal<T> values as elements instead of text (STUD-80981)#405PavelDrg wants to merge 1 commit into
PavelDrg wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
david-barzi
approved these changes
Aug 6, 2026
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.
Description
A whitespace-only value in an Invoke Workflow File argument — e.g. a single space — is silently dropped when the workflow is reopened. This is the write-side half of the problem: the value is serialized in a form that parsers are entitled to discard, so every consumer that reads the file back loses it.
Companion to #403, which fixes the read side. Neither subsumes the other — see "Relationship to #403" below.
Root cause
Literal<T>.CanConvertToStringreports that a whitespace-only string can be written as text, soXamlObjectReaderemits the value as element content on the argument:A XAML parser discards whitespace-only text in an element whose content property is not a string.
InArgument<T>declaresExpression— anActivity<T>— as its content property, so the text is dropped before the type converter that would have consumed it is ever consulted.The same method already refuses text form for null and empty strings for exactly this reason (
Value == null, and theIsNullOrEmptyguard added in 5c84ac5 for STUD-74008). Whitespace-only is the same case, and was simply missed.Fix
One line —
IsNullOrEmpty→IsNullOrWhiteSpace. The value now serializes as an element:Literal<T>declaresValueas its content property, and that is a string, so this lands in the parser's existingprop.Type == XamlLanguage.Stringbranch, which preserves the whitespace. No parser change is required for this form to round-trip.Because it changes the data rather than a reader, every consumer benefits — designer, validation, the analyzer, the reference DB, WorkflowCompiler and Robot — without any of them being touched.
Values with surrounding whitespace (
" x ") are unaffected and still serialize as text; only whitespace-only values change form.Tests
Added to
TestCases.Workflows/WF4Samples/LiteralTests.cs, alongside the existing null/empty cases:CanConvertToString_WhitespaceOnlyString_ReturnsFalse— space, double space, tabXamlSerialize_WhitespaceOnlyStringLiteral_WritesLiteralElement— asserts the element form is emittedXamlRoundTrip_WhitespaceOnlyStringLiteral_PreservesTheValue— save then load, value intactCanConvertToString_StringWithSurroundingWhitespace_ReturnsTrue— guards that" x "still uses text formVerified independently of #403: with
XamlPullParser.cschecked out fromdevelop(i.e. the unfixed parser),LiteralTestsis 29/29 green. That is what demonstrates the new format round-trips on an unpatched parser, including the WPFSystem.Xamlthat the Studio designer andUiPath.Studio.Projectactually load.Suites run locally:
TestCases.Workflows271 + 265 passed, zero failures.System.Xaml.TestCaseshas a pre-existing compile error ondevelop(XamlObjectWriterTest.cs:2129, CS1503 with recent SDKs) unrelated to this change.Relationship to #403
XamlPullParserLiteral.CanConvertToStringSystem.Xaml#403 remains necessary: it is the only thing that helps already-published packages, where Robot reads a legacy whitespace argument and gets an empty value at runtime. No write-side change can reach a
.nupkgthat has already shipped.This PR is what closes STUD-80981 for newly authored workflows. Note it lands in
System.Activities.dll, which Studio consumes via theUiPath.Workflowpackage — so it reaches Studio through a dependency bump, not a change in the Studio repo.Jira
https://uipath.atlassian.net/browse/STUD-80981
🤖 Generated with Claude Code