Skip to content

feat!: Rewrite relative XAML URIs to the MRT local-resource form - #23978

Merged
Xiaoy312 merged 20 commits into
feature/breakingchangesfrom
dev/xygu/20260804/bc51-ms-resource-uri-rewrite
Aug 11, 2026
Merged

Xiaoy312 merged 20 commits into
feature/breakingchangesfrom
dev/xygu/20260804/bc51-ms-resource-uri-rewrite

Conversation

@Xiaoy312

@Xiaoy312 Xiaoy312 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: Part of #8339

PR Type:

✨ Feature

What changed? 🚀

BC51 of the 7.0 rollup: a relative URI in XAML now compiles to the MRT local-resource form
WinUI produces (ms-resource:///Files/…) instead of being emitted verbatim. This fills the
else branch that has carried a // Breaking change … (#8339) placeholder in
XamlFileGenerator.RewriteUri since that issue was filed.

Expected values were measured on native WinUI (WinAppSDK 1.7) with a self-contained
unpackaged probe app, for both application and library XAML, rather than inferred:

WinUI target Compiled value
a value landing in a BitmapImage — BitmapImage.UriSource, or an ImageSource-typed property (Image.Source, ImageBrush.ImageSource, custom DP) given a non-svg path ms-appx:/// + file-relative base
a value landing in an SvgImageSource — including Image.Source="x.svg" ms-resource:///Files/<raw>
every other Uri-typed property — BitmapIcon/BitmapIconSource.UriSource, NavigateUri, WebView2.Source, custom Uri DPs ms-resource:///Files/<raw>

Two properties of that rewrite drove the implementation:

  1. The ms-appx special case is not keyed on the owner type. Uno keyed it on the owner,
    which was wrong in both directions — ImageBrush.ImageSource and a custom ImageSource DP
    fell through to the verbatim branch, while a Uri-typed property on an ImageSource-derived
    owner took the ms-appx branch. Uno now keys on the property type.
  2. The ms-resource rewrite is a raw prefix concat, dropping a leading / and ignoring the
    folder of the XAML file — with no assembly prefix, even in a library.

ResourceDictionary.Source is untouched — it resolves through RetrieveDictionaryForSource,
not RewriteUri.

The svg carve-out is a deliberate divergence

Uno keeps every ImageSource-typed property on the ms-appx form, svg included. WinUI does
not, as the table above shows — that row was probed for this PR and had never been measured
before.

The discriminator is how the sink resolves the form, not what the form can express.
ms-appx is resolved as an asset path, so it carries the assembly prefix a library's own assets
need; ms-resource is understood only by Uno's mapping, which resolves against the app root.
Following WinUI here would leave a library's svg assets unreachable, with no MRT to fall back
on. (An assembly-qualified ms-resource is emitted for ResourceDictionary.Source, because
dictionary resolution is a registry string-key lookup rather than asset resolution — so the form
itself is not the constraint. An earlier version of this PR justified the carve-out with exactly
that mistaken claim.)

Keeping images loading

ms-resource:///Files/X is mapped to ms-appx:///X — the equivalent of MRT's Files subtree —
so relative-URI BitmapIcon/BitmapIconSource keep loading the same asset they load today.
The value changes; the behavior does not.

The mapping sits where a URI is consumed, not only in the ImageSource conversion:
ImageSource.InitFromUri (which every UriSource assignment reaches through
OnUriSourceChanged, on every target), the BitmapImage Skia loader (the one place a raw DP
value is read), and LoadedImageSurface.StartLoadFromUri. A UriSource assigned directly —
ctor, x:Bind, a Setter, code-behind — therefore resolves too, while still reporting the URI
it was given, the way WinUI reports a Uri-typed property.

The mapping preserves the fragment (load-bearing for SvgImageSource) and rejects a non-empty
authority: ms-resource://OtherPkg/Files/x.png names another package's resources, which
ms-appx cannot reach, so mapping it would silently resolve the app's asset of the same name.
An unmappable ms-resource URI now warns rather than failing silently.

Also in this PR

  • A path may contain a backslash, and the ms-appx branch emitted a regular string literal,
    so ImageSource="Assets\x.png" had \x read as an escape and dropped the generated file
    entirely. Both branches now emit verbatim literals.
  • UriExtensions.IsLocalResource → IsMsAppx (source-breaking). The old name said "local
    resource" but the predicate tests for ms-appx — the opposite end of this very mapping. The
    internal helpers were renamed to match (MsResourceFilesPrefix, NormalizeMsResourceFilesUri).
  • UriExtensions.IsAppData guarded against a relative URI — it read uri.Scheme behind only
    a null check, where the neighbouring predicate correctly guards IsAbsoluteUri &&.
    Defensive hardening; no known caller reaches it.
  • Launcher on Skia reports launch failures the way WinUI does. Measured on WinAppSDK 1.7:
    LaunchUriAsync returns true without launching anything for ms-resource, ms-appx and
    unregistered schemes alike. Uno's Win32 extension let a ShellExecute failure escape into
    HyperlinkButton.OnClick, which is async void.

build/PackageDiffIgnore.xml does carry an entry for this PR — the IsLocalResource
removal. Nothing else publicly visible is removed or retyped; XamlFilePathHelper is internal.

Validation

Per debugging-discipline.md, labelled by evidence type. All local evidence is Skia desktop,
net10.0
— net11.0 is not buildable on this SDK and is left to CI.

  • Code review: every consumer of a raw URI value was traced before deciding where to map.
    OnUriSourceChanged → InitFromUri covers all platforms, which is why the conversion operator
    does not map (it would only change the value a caller reads back).
  • Compile (analyzers on, -p:UnoFastDevBuild=false -p:OptimizeImplicitlyTriggeredBuild=false):
    Uno.UI.Skia, Uno.UI.Reference, Uno.Skia, Uno.Foundation.Skia and the netstandard2.0
    Uno.UI.SourceGenerators — 0 errors, 0 warnings. The generator matters separately: it
    compiles XamlFilePathHelper.shared.cs too, where the span-based string.Concat overload does
    not exist.
  • Runtime — generator tests: full suite → 482 total, 480 passed, 2 skipped, 0 failed. A
    Given_RelativeUri golden locks the emitted shape for every property kind, including a rooted
    path, a backslash, SvgImageSource, and the Setter path (which reaches the rewrite through
    the style's target type rather than the syntactic owner).
  • Runtime — unit tests: new Given_XamlFilePathHelper → 21/21, covering scheme/folder
    casing, query and percent-escape survival, the fragment and foreign-package cases, and
    TryGetMsAppxAssetPath.
  • Runtime — runtime tests: Given_RelativeUriRewrite → 11/11, 0 inconclusive, plus
    Given_BitmapSource → 15 passed / 1 pre-existing skip. Value assertions measured against WinUI
    run on the WinUI head too; the ms-appx-value and mapping assertions are excluded there, since
    MRT resolves the local-resource URI natively.
  • Fails-before / passes-after, each verified by reverting one thing at a time:
    • neutering the scheme constant the mapping compares → 8 of the 21 unit rows fail;
    • dropping only the new authority clause → exactly the foreign-package row flips, which is
      the only proof that half of the fix does anything;
    • reverting the mapping in ImageSource → 4 of the 6 tests that existed at that point fail
      (the 2 that pass are intentional regression guards);
    • reverting only the BitmapImage Skia loader line → When_Local_Resource_On_UriSource_Loads
      times out (which also proves ActualHeight > 0 is a real load signal, not a template-size
      proxy);
    • un-fixing the verbatim literal → the generated MainPage file disappears from the
      compilation;
    • re-adding the mapping in the conversion operator → the new value test fails;
    • pointing BitmapIconSource at a missing asset → its load test fails.

Not validated locally: the WinUI head, WASM, native Android/iOS, and hot reload — left to CI.
Six of the eleven IsMsAppx call sites (mobile, WASM, macOS, AddIns) are not compiled by any
project buildable here; their completeness proof is a repo-wide zero-hit grep for the old name
across every text format, and the mobile/WASM/macOS CI legs are the real check. The
PackageDiffIgnore entry is likewise CI-gated.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) — 11 runtime tests, 21 unit tests, 2 source-generator goldens
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — migration guide updated
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

Breaking change impact and migration path

This changes the compiled value of a relative URI, so it is a breaking change — intentional,
scoped to the 7.0 major, and toward WinUI parity. Documented in
migrating-to-uno-7.md. Four impacts:

  1. A relative value is now absolute at the point of use. WebView2.Source with a relative
    value used to throw ArgumentException while the page initialized; it now navigates an
    ms-resource: URI no web view can service, so the failure is silent instead of loud. A
    scheme-less NavigateUri (www.example.com) becomes ms-resource:///Files/www.example.com
    and reaches the launcher as an unregistered scheme, and a relative
    Control.DefaultStyleResourceUri no longer throws while resolving.
    Migration: give these properties absolute URIs — https://…, ms-appx:///….
    Measured on WinAppSDK 1.7, Launcher.LaunchUriAsync returns true without launching
    anything for ms-resource and ms-appx alike, so a relative NavigateUri is equally inert
    on WinUI — the silent failure is parity, but it is quieter than the exception Uno used to
    raise.
  2. In a library, the two property kinds resolve differently. On an ImageSource-typed
    property the value now carries the library's assembly prefix (ms-appx:///MyLib/Assets/x.png),
    so a library's own assets resolve — but a library asset that previously resolved from the
    consuming app's root no longer does. On a Uri-typed property the ms-resource form is
    mapped against the app root, so it does not. Migration: a library shipping assets for
    BitmapIcon must use an explicit ms-appx:///MyLib/… URI.
  3. ImageBrush.ImageSource and custom ImageSource properties previously kept the relative
    string and now resolve against the base URI, consistent with Image.Source.
  4. UriExtensions.IsLocalResource is renamed to IsMsAppx (source-breaking, no forwarding
    shim). Same behavior. Migration: rename the call.

Images declared in application XAML keep loading the same asset. To keep any value verbatim,
write it as an explicit ms-appx:///… URI in XAML.

Known divergence left open

Uno resolves the ms-appx form against the assembly root; WinUI resolves it against the
XAML file's folder. Assets/logo.png in Views/MainPage.xaml is
ms-appx:///Assets/logo.png here and ms-appx:///Views/Assets/logo.png on WinUI. This predates
BC51 and is unchanged by it, but it is a real behavior gap and is now named in the migration
note; it needs its own BC entry, since fixing it changes compiled values again.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/code-generation Categorizes an issue or PR as relevant to code generation kind/documentation labels Aug 5, 2026
@nventive-devops

Copy link
Copy Markdown
Contributor

The build 225950 found UI Test snapshots differences: skia-linux-screenshots: 74, skia-windows-screenshots: 314

Details
  • skia-linux-screenshots: 74 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • DoubleImageBrushInList.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DropDownButtonPage.png-dark
    • ImageBrush_Stretch.png
    • Image_UseTargetSizeLate.png-dark
    • Image_UseTargetSizeLate.png
    • Gamepad_Enumeration.png-dark
    • DisplayInformation.png-dark
    • Buttons.png
    • DamageRegion_ShadowChildPaintingCaster.png-dark
    • Gamepad_CurrentReading.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
  • skia-windows-screenshots: 314 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Battery.png-dark
    • BitmapIcon_Foreground.png
    • BitmapIcon_Generic.png-dark
    • Button_Enabled_Control_Disabled.png
    • DataTransferManager.png-dark
    • DataTransferManager.png
    • DownloadFileSavePickerTests.png-dark
    • DownloadFileSavePickerTests.png
    • Focus_FocusVisual_Properties.png-dark
    • AutoSuggestBox_BitmapIcon.png
    • Basics Pivot Test.png-dark
    • Battery.png
    • BitmapIcon_Sizing.png-dark
    • ColorPickerSample.png-dark
    • DataTemplate_Update_Sample.png-dark
    • DataTemplate_Update_Sample.png
    • Haptics.VibrationDevice.png-dark
    • Haptics.VibrationDevice.png
    • AuthenticationBroker_Demo.png
    • BitmapIcon_Foreground.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 225950 has failed on Uno.UI - CI.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 226197 found UI Test snapshots differences: skia-linux-screenshots: 74, skia-windows-screenshots: 990

Details
  • skia-linux-screenshots: 74 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Gamepad_Enumeration.png-dark
    • DropDownButtonPage.png-dark
    • Gamepad_CurrentReading.png-dark
    • ImageBrushWithRotateTransform.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • CalendarView_Theming.png-dark
    • DamageRegion_ShadowChildPaintingCaster.png-dark
    • DoubleImageBrushInList.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ImageBrush_Stretch.png
    • Buttons.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ClipboardTests.png-dark
  • skia-windows-screenshots: 990 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ApplicationViewMode.png-dark
    • AppBarToggleButtonTest.png
    • AppXamlDefinedResources.png-dark
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutoSuggestBox_Icons.png-dark
    • BasicEnability.png-dark
    • AutoSuggestBox_Keyboard.png
    • BorderRightwithmargins.png-dark
    • BorderBottomwithmargins.png-dark
    • BorderRightwithmargins.png
    • Border_BorderThickness.png
    • Border_CornerRadius_Alignments.png-dark
    • Border_Clipped_Change_Property.png-dark
    • Border_CornerRadius_Alignments.png
    • Border_Corner_Overlap.png
    • Border_LinearGradientBrush.png
    • Border_LinearGradientBrush.png-dark
    • Border_Simple.png-dark
    • Button_IsEnabled_Automated.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 226197 has failed on Uno.UI - CI.

@github-actions github-actions Bot added platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation labels Aug 7, 2026
@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 226281 has failed on Uno.UI - docs.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 226280 found UI Test snapshots differences: skia-linux-screenshots: 74, skia-windows-screenshots: 189

Details
  • skia-linux-screenshots: 74 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DynamicFont.png-dark
    • DamageRegion_ShadowChildPaintingCaster.png-dark
    • Gamepad_CurrentReading.png-dark
    • CalendarView_Theming.png-dark
    • ButtonClippingTestsControl.png-dark
    • Buttons.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ClipboardTests.png-dark
    • DoubleImageBrushInList.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • Gamepad_Enumeration.png-dark
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ImageBrushWithRotateTransform.png
    • ImageBrush_Stretch.png
    • DisplayInformation.png-dark
    • ButtonClippingTestsControl.png
    • Image_Margin_Large.png
  • skia-windows-screenshots: 189 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ColorPickerSample.png-dark
    • Gamepad_Enumeration.png-dark
    • Button_Enabled_Control_Disabled.png
    • ButtonClippingTestsControl.png-dark
    • ContentPresenter_NativeEmbedding_Android_FillType.png-dark
    • ContentPresenter_NativeEmbedding_ZIndex.png-dark
    • ContentPresenter_NativeEmbedding_ZIndex.png
    • Gamepad_CurrentReading.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Basics Pivot Test.png-dark
    • Basics Pivot Test.png
    • DynamicFont.png-dark
    • DynamicFont.png
    • Focus_FocusVisual_Properties.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ContentPresenter_TextProperties.png-dark
    • ContentPresenter_TextProperties.png
    • DropDownButtonPage.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 226280 has failed on Uno.UI - CI.

@MartinZikmund

Copy link
Copy Markdown
Member

@Xiaoy312 there is a cspell issue

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 226460 found UI Test snapshots differences: skia-linux-screenshots: 80, skia-windows-screenshots: 302

Details
  • skia-linux-screenshots: 80 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBar_KeyBoard.png
    • ButtonClippingTestsControl.png-dark
    • DropDownButtonPage.png-dark
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • EllipsemaskingEllipseGrid.png
    • Gamepad_CurrentReading.png-dark
    • ImageIconPage.png-dark
    • ImageBrushLocalAsset.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • CheckBox_Button.png-dark
    • CheckBox_Button.png
    • ColorPickerSample.png
    • DisplayInformation.png-dark
  • skia-windows-screenshots: 302 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AutomationProperties_AutomationId.png-dark
    • Buttons.png-dark
    • Buttons.png
    • DamageRegion_Static.png-dark
    • DamageRegion_Static.png
    • AuthenticationBroker_Demo.png
    • ApplicationViewMode.png-dark
    • AutomationProperties_AutomationId.png
    • Battery.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Button_Inside_Border.png-dark
    • Button_Inside_Border.png
    • DamageRegion_Scroll.png-dark
    • ContentPresenter_NativeEmbedding_Android_FillType.png
    • DamageRegion_Scroll.png
    • DamageRegion_Shadow.png-dark
    • DamageRegion_Shadow.png
    • Display.DisplayRequest.png-dark
    • Display.DisplayRequest.png

@MartinZikmund

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

auto-merge was automatically disabled August 10, 2026 07:57

Head branch was pushed to by a user without write access

Xiaoy312 and others added 20 commits August 11, 2026 10:47
Fills the empty else-branch in XamlFileGenerator.RewriteUri so a relative URI
on a Uri-typed property compiles to the MRT local-resource form WinUI produces
(a raw `ms-resource:///Files/` concat, leading '/' trimmed), and keys the
ms-appx special case on the property type - measured on WinAppSDK 1.7 for both
application and library XAML:

- property typed ImageSource (Image.Source, ImageBrush.ImageSource, a custom
  control's ImageSource DP) and BitmapImage.UriSource resolve against the base
  URI, so ImageBrush and custom ImageSource properties no longer fall through
  to the verbatim branch
- every other Uri-typed property (custom Uri DPs, Hyperlink[Button].NavigateUri,
  BitmapIcon/BitmapIconSource.UriSource, WebView2.Source) takes the
  ms-resource form

ImageSource resolution now maps `ms-resource:///Files/X` to `ms-appx:///X`, the
equivalent of MRT's Files subtree, so relative-URI BitmapIcon/BitmapIconSource
keep loading the same asset they load today - the value changes, the behavior
does not. ResourceDictionary.Source is untouched; it resolves through
RetrieveDictionaryForSource, not RewriteUri.

The owner-type check that used to carry the special case alone is kept beside
the new one, and is what holds SvgImageSource.UriSource on the ms-appx form
where WinUI emits ms-resource: the ms-resource form cannot carry the assembly
prefix a library's svg assets are resolved through.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Documents the compiled-value change for relative URIs on Uri-typed properties,
that images keep resolving through the ms-resource -> ms-appx mapping, and the
deliberate SvgImageSource divergence. Checks BC51 off the rollup spec with the
recorded decision and the WinUI measurements behind it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
FrameworkPropertyMetadata is Uno-only surface (the one other use in this project
sits behind #if HAS_UNO), so the test helper registers with PropertyMetadata
instead - it never needed framework metadata options.

Excludes from the native WinUI head every test that asserts an ms-appx value or
Uno's ms-resource -> ms-appx mapping, which has no WinUI analog and would
otherwise depend on how a library-contributed asset lands in the merged PRI.
Only the Uri-typed value assertions still run there, since those were the ones
measured against WinUI.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review found the ms-resource -> ms-appx mapping only covered the ImageSource
conversion, so a UriSource assigned directly - by the BitmapImage ctor, x:Bind,
a Style Setter for a Uri-typed property, or code-behind - reached the Skia
loader unmapped. It reads the UriSource property rather than the normalized
AbsoluteUri, and an ms-resource URI is absolute, so it cleared the guard and
then fell through to a network fetch instead of failing loudly. Maps at that
read and in LoadedImageSurface, the two places a raw URI is consumed.

When_Local_Resource_On_UriSource_Loads covers it: it times out waiting for a
non-zero ActualHeight without the mapping, which also shows the loading
assertions discriminate rather than measuring template size. Adds a loading
test for a library asset on an ImageSource-typed property, where the assembly
prefix is what makes it resolve.

NormalizeLocalResourceUri now traces the original/resolved pair at Debug, since
the value read back from the property is not the one being resolved, and stays
total when the remainder is not a valid URI (its callers are non-throwing).

The migration note claimed only readback changed. It also documents that a
relative value is now absolute at the point of use (WebView2.Source stops
throwing and silently navigates nowhere, a scheme-less NavigateUri reaches the
launcher as an unregistered scheme, a relative DefaultStyleResourceUri no
longer throws), and that in a library the two property kinds resolve
differently - the assembly prefix on ImageSource, the app root on Uri.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A path is free to contain a backslash, which the emitted regular string literal
read as an escape sequence - `ImageSource="Assets\x.png"` dropped the generated
file altogether. Both branches now go through one verbatim-literal helper.

NormalizeLocalResourceUri matches the parsed scheme and path instead of the
original string, so a leading whitespace or an upper-cased scheme the Uri parser
accepted resolves as well, and it keeps the query the way the neighbouring
TryGetMsAppxAssetPath does.

Drops the mapping in the Uri conversion operator: every UriSource assignment
reaches InitFromUri through OnUriSourceChanged, which already maps the value on
all targets. A converted ImageSource therefore reports the URI it was given, the
way WinUI reports a Uri-typed property.

Covers the cases the first round left untested: a rooted path on an ImageSource
property, SvgImageSource in the generator golden, a backslash in a path, the
value a converted ImageSource reports, and BitmapIconSource, whose value is
copied to a BitmapIcon through a binding.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
CA1845 is an error on the net10.0/net11.0 heads, but the span overload
does not exist on netstandard2.0, where this shared file also compiles
into Uno.UI.SourceGenerators. The generator never calls this method, so
scope it to the runtime heads.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The existing exclusion covered only the FrameBuffer job, so the X11 job
still hung to its 60-minute limit on a TCS that is never completed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The Win32 launcher extension called process.Start() unguarded, so an
unlaunchable URI threw Win32Exception into HyperlinkButton.OnClick -
async void with no try/catch - terminating the process on a click.
The sibling fallback in Launcher.skia.cs has always been wrapped.

Measured on WinAppSDK 1.7: Launcher.LaunchUriAsync never throws and
returns true for ms-resource, ms-appx and unregistered schemes alike;
the shell takes the request and discards it quietly. Match that.

BC51 makes this reachable on every click rather than occasionally,
since a relative NavigateUri now compiles to an ms-resource URI that
is never registered, where a relative path could previously resolve
against the working directory.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The rollup claimed the compiled value changes and the behavior does
not, which the migration note contradicts two files away: a relative
value is now absolute at the point of use, and in a library the two
property kinds resolve against different roots.

Records the WinAppSDK 1.7 measurement behind the first one - WinUI's
launcher is equally unable to service the emitted URI - so the silent
failure reads as parity rather than an unexplained regression.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
An ms-resource URI outside the Files/ subtree was returned untouched
and then resolved to no asset, with nothing raised and nothing logged
unless the app had subscribed to ImageFailed.

Only an ms-resource URI reaches that branch, so the warning cannot
fire for the ms-appx values every other load goes through.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A Setter resolves its property type from the style's target type, not
from the syntactic owner, so the rewrite could have keyed differently
there than inline. It does not: an ImageSource-typed property lands on
the base URI and a Uri-typed one on the local-resource form, matching
the inline golden for the same four properties.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
BitmapIcon.UriSource registers no changed callback - the value reaches
the image through the binding its constructor sets up, and the mapping
happens a layer later when the converted ImageSource initializes. Only
the compiled-XAML route was covered, so the route a Setter, x:Bind or
code-behind assignment takes had nothing pinning it.

Verified to discriminate: with the mapping disabled the new test fails
along with five others in this class.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three findings this pass did not survive verification: a generator
emission claim contradicted by its own golden, a crash attributed to
the diff that the pre-change value reached identically, and a
cross-branch CI comparison confounded by differing SDKs.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`LocalResourcePrefix` / `LocalResourceFolder` / `NormalizeLocalResourceUri`
all mean `ms-resource:///Files/`, three lines from `UriExtensions.IsLocalResource`,
which means `ms-appx`. Name them for the scheme they actually match.

Identifiers only - the emitted `ms-resource:///Files/` literal is unchanged, so
the generator goldens are untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`Uri.Scheme` throws `InvalidOperationException` on a relative URI, so
`IsAppData` threw where the neighbouring `IsLocalResource` - which carries the
`IsAbsoluteUri &&` guard - returns false. Apply the same guard.

Defensive hardening: no known caller reaches it with a relative URI today.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The mapping read `PathAndQuery`, which drops both the authority and the
fragment:

- `ms-resource://OtherPkg/Files/x.png` mapped to `ms-appx:///x.png` and so
  resolved the *app's* asset of that name - a wrong asset, not a missing one.
  It now stays untouched and warns.
- `ms-resource:///Files/icon.svg#layer1` lost `#layer1`, which `SvgImageSource`
  resolves against.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`Uri.IsLocalResource()` tests for the `ms-appx` scheme, but sat three lines
from the `ms-resource:///Files/` helpers on the other end of the same mapping -
one name for two opposite things. Renamed to say what it matches, with all 11
call sites updated. No forwarding shim; this is the breaking-changes branch.

Registered in PackageDiffIgnore, with the migration note and the BC51 spec
entry.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The ms-resource -> ms-appx mapping had no direct test; the runtime tests reach
it only through image loading. Covers the folder/scheme casing the comments
assert, the fragment and foreign-package cases just fixed, query and
percent-escape survival, and TryGetMsAppxAssetPath.

Discriminating: with the mapping neutered, 8 of the 21 rows fail.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Probed SvgImageSource on native WinUI (WinAppSDK 1.7), which the original BC51
measurements never covered. Two results:

- WinUI does compile SvgImageSource.UriSource to ms-resource, as the carve-out
  comment claimed without evidence.
- It also compiles `Image.Source="x.svg"` to ms-resource. So the deciding
  factor is the object the value lands in, not the property type - an
  ImageSource-typed property is not uniformly file-relative.

Uno keeps svg on ms-appx. The old justification - that ms-resource "cannot
carry the assembly prefix" - is wrong: an assembly-qualified ms-resource is
emitted for ResourceDictionary.Source. The real discriminator is how the sink
resolves the form, which is what decides the next carve-out.

Also corrects the affected-property list, which omitted the sinks that were
never asset-resolving, and names the assembly-root vs XAML-folder base URI
divergence instead of implying parity.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Xiaoy312
Xiaoy312 force-pushed the dev/xygu/20260804/bc51-ms-resource-uri-rewrite branch from bff1385 to 04fb866 Compare August 11, 2026 15:04
@Xiaoy312

Copy link
Copy Markdown
Contributor Author

Rebased onto feature/breakingchanges (96 commits, including the sweeping .skia.cs → .cs fold).

Two of this PR's files were folded away on the base, so their hunks were hand-applied to the merged files:

  • BitmapImage.skia.cs → BitmapImage.cs
  • LoadedImageSurface.skia.cs → LoadedImageSurface.cs

The other conflicts were append-vs-append in PackageDiffIgnore.xml and migrating-to-uno-7.md. No behavioral change — the branch's net contribution is byte-identical to the approved version apart from those two path renames.

Re-verified locally after the rebase: Given_XamlFilePathHelper (21/21), Given_RelativeUri generator snapshots (2/2), Given_RelativeUriRewrite runtime tests on Skia Desktop (11/11), Given_BitmapSource (14 passed, 1 pre-existing [Ignore] on #9080), and a clean SamplesApp.Skia.Generic build.

@Xiaoy312 Xiaoy312 removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 11, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 227017 found UI Test snapshots differences: skia-linux-screenshots: 74, skia-windows-screenshots: 92

Details
  • skia-linux-screenshots: 74 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • DamageRegion_ShadowChildPaintingCaster.png-dark
    • ElementLevelTheme.png-dark
    • DynamicFont.png-dark
    • ElementLevelTheme.png
    • DoubleImageBrushInList.png-dark
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ImageIconPage.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
  • skia-windows-screenshots: 92 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DisplayInformation.png-dark
    • Buttons.png-dark
    • DynamicFont.png-dark
    • DynamicFont.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • Examples.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Image_UseTargetSizeLate.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContentPresenter_Template.png-dark
    • ContentPresenter_Template.png
    • ExpanderColorValidationPage.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark

@mergify

mergify Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@Xiaoy312
Xiaoy312 merged commit 9601990 into feature/breakingchanges Aug 11, 2026
67 checks passed
@Xiaoy312
Xiaoy312 deleted the dev/xygu/20260804/bc51-ms-resource-uri-rewrite branch August 11, 2026 18:01
MartinZikmund added a commit to ramezgerges/uno that referenced this pull request Sep 21, 2026
…orm#23978/unoplatform#23660

Fold BitmapImage, BitmapSource, RenderTargetBitmap, SvgImageSource,
WriteableBitmap and LoadedImageSurface's resurrected .skia.cs partials
back into their base .cs files, matching master's single-file layout
while keeping the branch's neutral CompositionImageSurface/ITexture
types. Also restore the IsMsAppx/NormalizeMsResourceFilesUri call in
LoadedImageSurface.StartLoadFromUri that unoplatform#23978 added and the merge
dropped (BitmapImage/BitmapSource already had it). RenderTargetBitmap
keeps the branch's CPU-raster RenderOffscreen/SnapshotAsync path
rather than porting master's GRContext-based async picture-replay,
since that mechanism is Skia/GRContext-specific and can't exist in
SkiaSharp-free Uno.UI; see report for follow-up.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure area/code-generation Categorizes an issue or PR as relevant to code generation area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants