Preserve whitespace-only argument values when parsing already-saved XAML (STUD-80981) - #403
Open
PavelDrg wants to merge 1 commit into
Open
Preserve whitespace-only argument values when parsing already-saved XAML (STUD-80981)#403PavelDrg wants to merge 1 commit into
PavelDrg wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PavelDrg
marked this pull request as draft
August 3, 2026 13:47
PavelDrg
marked this pull request as ready for review
August 3, 2026 14:37
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
XAML already on disk carries whitespace-only argument values in a form the parser discards:
The value is present in the file, but is dropped on load, so the argument comes back empty.
This PR fixes the read side, for files that already exist. #405 fixes the write side so this form stops being produced in the first place. Neither subsumes the other — see "Relationship to #405" below.
What this covers, and what it does not
This changes CoreWF's
System.Xaml, so it reaches consumers that load this parser:It does not reach the Studio designer. Both Studio processes resolve
System.Xamlfrom the shared framework, not from CoreWF:There is a CoreWF
System.Xaml.dllin the Studio tree, but atOutput/bin/Debug/Studio/net8.0/— the ActivityCompiler/analyzer tooling folder — not next to the app. So this PR alone does not close STUD-80981 for the designer; #405 does that.The value here is runtime correctness for workflows already saved or published, which no write-side change can reach.
Root cause
XamlPullParser.Logic_IsDiscardableWhitespacedecides whether whitespace-only text at the end of an element is significant. For elements with a content property it only keeps the whitespace when that property is a string or a whitespace-significant collection.InArgument<T>declares both a content property (Expression) and a type converter, so the content-property branch discards the whitespace before the type-converter branch — which would have kept it — is ever consulted. The original comment in that method already describes the intended behavior: .NET 3.0 surfaced whitespace for type-convertible content properties as long as the content property had not been set.Fix
InArgumentConverterreceives the whitespace and producesLiteral<string>with the original value.ContentPropertyAssignedflag onXamlParserFrametracks whether the current element's content property has already received content.PreviousChildTypecannot serve this purpose because the implicitEndMemberemitted after each content item resets it. The gate keeps documents with inheritedxml:space="preserve"and child-element expressions (<InArgument><VisualBasicValue/> </InArgument>) loading exactly as before.Property elements and attribute-set properties were already excluded via
ForcedToUseConstructor, and frames areReset()on recycling, so no stale state is possible.Tests
Added to
TestCases.Workflows/XamlTests.cs, running in both the JIT and AOT expression-compilation variants:Assignand come back intact — compiled only for net6.0, since the net6.0-windows test build uses the WPF System.Xaml which does not have the fixxml:space='preserve'with a child-element expression still loadsSuites run locally: TestCases.Workflows 261+255 passed, TestCases.Xaml 92+92, TestCases.Activities 770+770 — zero failures. System.Xaml.TestCases has a pre-existing compile error on develop (
XamlObjectWriterTest.cs:2129, CS1503 with recent SDKs) unrelated to this change.Relationship to #405
XamlPullParserLiteral.CanConvertToStringSystem.XamlOnce #405 ships, newly authored workflows never produce the ambiguous form, so this PR's scope narrows over time to the existing corpus. It does not become redundant: published packages are immutable, and a
.uipxshipped last year keeps itsxml:spaceform forever.Jira
https://uipath.atlassian.net/browse/STUD-80981
Context: this started as the proposed fix for STUD-80981, from review discussion on https://github.com/UiPath/Studio/pull/29107. Measuring which
System.Xamlthe Studio processes actually load showed the designer is on the framework parser, so the ticket is closed by the write-side fix in #405 instead. This PR is retained for the runtime/legacy path, and arguably warrants its own ticket.🤖 Generated with Claude Code