Repository navigation
Fix null URI handling in generated dependency property setters - #818
Merged
Merged
Conversation
Guard optimized URI setters after typed hooks in both caching modes, preserve the string null/empty fallback and boxed set hooks, and audit all generated XAML helper paths with regression coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the runtime/reflection harness and fragment assertions with existing VerifySources snapshots. Cover URI null fallbacks, null-producing typed hooks, and boxed string/URI hooks without changing the shared test helpers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Arlodotexe
approved these changes
Sep 24, 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.
Summary
Generated
Urisetters currently callXamlBindingHelper.SetPropertyFromUriunconditionally, but the native helper rejects a null value. This affects bothUri?properties and non-nullable properties that receive null at runtime, including values replaced by a typed setter hook.SetValue(Property, value)for null URIs, retaining the optimized helper for non-null values in both caching modes and both XAML namespaces. The check runs after the typed set hook; caching, change hooks, and dependency-property callback ordering are preserved.stringfallback. Select the fallback by the enabled helper rather than the property type, also fixing cached string setters bypassing an implemented boxed set hook.VerifySourceshelper, and update the component documentation. NoClearValue, skipped null assignments, projection-version changes, or application-specific workarounds are introduced.XamlBindingHelper null audit
Audited every helper selection and both setter emitters. The
SetPropertyFromprefix is omitted in this table. Native entry-point checks are visible in the WinUI implementation.UriSetValuefallback, independently of nullable annotations, after typed hooks have run.StringObjectSetValue.Boolean,Byte,Char16,Double,Int32,Int64,Single,UInt32,UInt64SetValue.DateTime,TimeSpan,Point,Rect,SizeSetValue.Color,CornerRadius,ThicknessSetValue.An implemented boxed setter hook disables typed helpers so it can inspect or replace the boxed value. The cached string special case was the exception; this PR brings it back in line with the other paths. No other emitted helper needs an additional null fallback.
Regression coverage
The added tests follow the existing source-generator test pattern: provide the input source and compare the entire generated output with
VerifySources. They coverUri/Uri?, both caching modes, typed hooks assigning null, and boxed hooks for nullable/non-nullable URI and string properties. Existing string null/empty snapshots are preserved.There is no added reflection, generated-code execution harness, managed XAML emulation, fragment matching, or shared test-helper modification in the PR.
Validation
Uri/Uri?transitions in both caching modes, hook-induced nulls and ordering, null/empty strings, object nulls, and explicit local-null storage rather than clearing the property. That execution harness is not part of the committed tests.