Skip to content

[Windows]Fixed the MauiImage with logical name containing path issue#32864

Merged
kubaflo merged 3 commits intodotnet:inflight/currentfrom
sheiksyedm:fix_32356
Mar 29, 2026
Merged

[Windows]Fixed the MauiImage with logical name containing path issue#32864
kubaflo merged 3 commits intodotnet:inflight/currentfrom
sheiksyedm:fix_32356

Conversation

@sheiksyedm
Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Fixes issue #32356 where images with LogicalName containing path separators e.g., "challenges/groceries.png") failed to load on Windows platform.

Root Cause

The Windows implementation in FileImageSourceService.Windows.cs was directly concatenating the filename to the ms-appx:/// URI without extracting the filename from paths containing separators.

Fix details

Extract the filename using Path.GetFileName() before creating the URI, aligning Windows behavior with other platforms.

Fixes #32356

Copilot AI review requested due to automatic review settings November 26, 2025 07:38
@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 26, 2025
@sheiksyedm sheiksyedm added platform/windows area-image Image loading, sources, caching labels Nov 26, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #32356 where images with LogicalName containing path separators (e.g., "challenges/groceries.png") failed to load on Windows. The fix modifies the Windows-specific FileImageSourceService to extract just the filename from paths before creating the ms-appx URI.

Key changes:

  • Modified GetAppPackage() to use Path.GetFileName() to strip path information before URI construction
  • Added UI test case to verify images with path separators in LogicalName load correctly
  • Added test image resource with subdirectory structure

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Core/src/ImageSources/FileImageSourceService/FileImageSourceService.Windows.cs Modified to extract filename from paths containing separators before creating ms-appx URI
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32356.cs Added NUnit UI test to verify image loading with path in LogicalName
src/Controls/tests/TestCases.HostApp/Resources/Images/Challenges/groceries.png Added test image resource in subdirectory
src/Controls/tests/TestCases.HostApp/Issues/Issue32356.xaml.cs Added code-behind for test page with Issue attribute
src/Controls/tests/TestCases.HostApp/Issues/Issue32356.xaml Added XAML test page displaying image with path in LogicalName
src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj Added MauiImage configuration with LogicalName containing path separator

Comment on lines +46 to +48
// Extract just the filename since Windows app package has flattened resources
var resourceName = Path.GetFileName(filename);
return new BitmapImage(new Uri("ms-appx:///" + resourceName));
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix using Path.GetFileName() may be too aggressive. This approach strips all path information from the filename, which could break scenarios where the app package legitimately uses subdirectories.

Consider this scenario:

  • If the app package contains images/groceries.png AND challenges/groceries.png as separate files
  • With this fix, both would resolve to just groceries.png, causing conflicts

The comment states "Windows app package has flattened resources," but this assumption may not always be true. The build system might preserve directory structure in the app package.

Recommendation: Before applying this fix, verify whether Windows app packages actually flatten resources or preserve directory structure. If they preserve structure, the original path should be maintained and the issue should be investigated from a different angle (possibly in the build configuration or resource packaging).

Suggested change
// Extract just the filename since Windows app package has flattened resources
var resourceName = Path.GetFileName(filename);
return new BitmapImage(new Uri("ms-appx:///" + resourceName));
// Use the full path as provided, since Windows app package may preserve directory structure
var resourcePath = filename.Replace('\\', '/');
return new BitmapImage(new Uri("ms-appx:///" + resourcePath));

Copilot uses AI. Check for mistakes.
@sheiksyedm
Copy link
Copy Markdown
Contributor Author

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@sheiksyedm
Copy link
Copy Markdown
Contributor Author

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@sheiksyedm
Copy link
Copy Markdown
Contributor Author

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@karthikraja-arumugam karthikraja-arumugam added the community ✨ Community Contribution label Dec 4, 2025
@MauiBot MauiBot added s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Mar 20, 2026
@dotnet dotnet deleted a comment from MauiBot Mar 20, 2026
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 20, 2026

🤖 AI Summary

📊 Expand Full Review2fed15c · Added the output images
🔍 Pre-Flight — Context & Validation

Issue: #32356 - MauiImage with LogicalName containing path - is not working on Windows
PR: #32864 - [Windows] Fixed the MauiImage with logical name containing path issue
Platforms Affected: Windows (primary); test also runs on Android
Files Changed: 1 implementation, 5 test (including binary snapshots and image asset)

Key Findings

  • On Windows, FileImageSourceService.GetAppPackage() directly concatenated the filename to ms-appx:///, creating ms-appx:///challenges/grocery.png
  • The Windows App SDK build system flattens all MauiImage resources to the package root (TargetPath is %(Filename)%(Extension) — no subdirectory). Confirmed in Microsoft.Maui.Resizetizer.After.targets line 694.
  • So the actual resource URI should be ms-appx:///grocery.png, not ms-appx:///challenges/grocery.png
  • The fix calls Path.GetFileName() to strip path prefix before building the URI
  • iOS/MacCatalyst had a similar fix applied earlier in PR [iOS] - Fixed ImageSource.FromFile fails when image in subfolder #31258; test uses #if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST to correctly exclude those platforms
  • The TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST pattern: Windows defines BOTH constants, Android defines BOTH — test runs on Windows & Android; iOS/Mac do NOT define both, so test is excluded there
  • Pre-existing related issue: ImageExtensions.ToIconSource() (line 49 of ImageExtensions.cs) also creates ms-appx:/// + fis.File without path handling — same class of bug, not addressed by this PR
  • An existing copilot review comment suggests using filename.Replace('\\', '/') instead, which is incorrect — it doesn't address the root cause (path prefix vs. flattened resource storage)

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #32864 Path.GetFileName(filename) before building ms-appx:/// URI ✅ PASSED (Gate) FileImageSourceService.Windows.cs Original PR fix

🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #32864 Path.GetFileName(filename) inside GetAppPackage() ✅ PASSED (Gate) 1 file Most concise; idiomatic .NET
1 try-fix (Opus) LastIndexOfAny(new[] {'/', '\\'}) + Substring in GetImageSourceAsync() before GetAppPackage ✅ PASS 1 file Works but adds complexity at caller layer
2 try-fix (Sonnet) Uri.Segments[^1] in GetAppPackage() after normalizing \ to / ✅ PASS 1 file URI-semantic approach; correct but more verbose
3 try-fix (Codex) Path.GetFileName at top of GetImageSourceAsync(), creating appPackageFilename variable ✅ PASS 1 file Same API as PR but applied at higher layer
4 try-fix (GPT-5.4) Span-based ReadOnlySpan<char>.LastIndexOfAny + string.Create in GetAppPackage() ✅ PASS 1 file Zero-alloc but over-engineered for this use case

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No NO NEW IDEAS — all meaningful structural variations exhausted

Exhausted: Yes

Selected Fix: PR's fix — Path.GetFileName(filename) in GetAppPackage()Reason: Most concise (1-line change), uses the most idiomatic .NET API for extracting a filename, applied at exactly the right scope (the method that builds the URI), and well-commented. Attempt 3 (Path.GetFileName in GetImageSourceAsync) is close but changes the wrong layer — it would also affect the GetLocal() path unnecessarily. The PR fix keeps concerns local to GetAppPackage.


📋 Report — Final Recommendation

✅ Final Recommendation: APPROVE

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #32356, Windows-only image loading bug
Gate ✅ PASSED windows
Try-Fix ✅ COMPLETE 4 attempts, 4 passing
Report ✅ COMPLETE

Summary

PR #32864 fixes a Windows-only bug where MauiImage resources with a LogicalName containing path separators (e.g., challenges/grocery.png) fail to load. The fix is correct, minimal, and well-targeted. All 4 independent try-fix attempts confirmed the approach is sound — no better alternative was found.

Root Cause

The Windows App SDK build system flattens all MauiImage resources into the package root (confirmed in Microsoft.Maui.Resizetizer.After.targets line 694: <TargetPath>%(_ResizetizerCollectedImages.Filename)%(_ResizetizerCollectedImages.Extension)</TargetPath>). A resource declared with LogicalName="challenges/grocery.png" is stored at ms-appx:///grocery.png, not ms-appx:///challenges/grocery.png. The old code concatenated the full logical name to the URI prefix, causing a 404 on load.

Fix Quality

Selected Fix: PRPath.GetFileName(filename) in GetAppPackage() is the best approach:

  • Correct: Strips the path prefix before building the ms-appx:/// URI, matching where Windows actually stores the resource
  • Minimal: 1-line code change (+3 lines with comment)
  • Idiomatic: Uses standard System.IO.Path.GetFileName() — the canonical .NET API for this operation
  • Well-scoped: Fix lives inside GetAppPackage() where the URI is built, not at a higher layer that would affect GetLocal() unnecessarily
  • Both separator styles handled: Path.GetFileName handles both / and \

Tests: A UI test (Issue32356) was added that loads an image via Source="challenges/grocery.png" and verifies it renders correctly via VerifyScreenshot(). The #if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST guard is correct — Windows and Android define both constants, so the test runs on those platforms; iOS/MacCatalyst (where the issue was already fixed in PR #31258) are excluded.

Pre-existing issue noted (not a blocker): ImageExtensions.ToIconSource() (line 49 of ImageExtensions.cs) also constructs ms-appx:/// + fis.File without path-stripping. This is the same class of bug but out of scope for this PR.

Prior review comment (copilot-pull-request-reviewer): Suggested using filename.Replace('\\', '/') instead — this is incorrect advice. It doesn't address the root cause (the path prefix vs. flattened resource storage). The Windows app package flattening is confirmed by the build system source code.


@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR and removed s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) labels Mar 20, 2026
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please try the AI's suggestions?

@MauiBot MauiBot added the s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) label Mar 20, 2026
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 29, 2026

🚦 Gate — Test Verification

📊 Expand Full Gate2fed15c · Added the output images

Gate Result: ✅ PASSED

Platform: WINDOWS · Base: main · Merge base: 720a9d4a

Test Without Fix (expect FAIL) With Fix (expect PASS)
🖥️ Issue32356 Issue32356 ✅ FAIL — 580s ✅ PASS — 464s
🔴 Without fix — 🖥️ Issue32356: FAIL ✅ · 580s
  Determining projects to restore...
  Restored D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj (in 43.8 sec).
  Restored D:\a\1\s\src\Controls\Maps\src\Controls.Maps.csproj (in 43.86 sec).
  Restored D:\a\1\s\src\Controls\Foldable\src\Controls.Foldable.csproj (in 231 ms).
  Restored D:\a\1\s\src\BlazorWebView\src\Maui\Microsoft.AspNetCore.Components.WebView.Maui.csproj (in 3.73 sec).
  Restored D:\a\1\s\src\Graphics\src\Graphics.Win2D\Graphics.Win2D.csproj (in 12 ms).
  Restored D:\a\1\s\src\Essentials\src\Essentials.csproj (in 20 ms).
  Restored D:\a\1\s\src\Graphics\src\Graphics\Graphics.csproj (in 3.73 sec).
  Restored D:\a\1\s\src\Core\maps\src\Maps.csproj (in 21 ms).
  Restored D:\a\1\s\src\Core\src\Core.csproj (in 49 ms).
  Restored D:\a\1\s\src\Controls\src\Xaml\Controls.Xaml.csproj (in 25 ms).
  Restored D:\a\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj (in 2.49 sec).
  3 of 14 projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Graphics -> D:\a\1\s\artifacts\bin\Graphics\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Essentials -> D:\a\1\s\artifacts\bin\Essentials\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Graphics.Win2D -> D:\a\1\s\artifacts\bin\Graphics.Win2D\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Graphics.Win2D.WinUI.Desktop.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Core -> D:\a\1\s\artifacts\bin\Core\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.dll
  Controls.BindingSourceGen -> D:\a\1\s\artifacts\bin\Controls.BindingSourceGen\Debug\netstandard2.0\Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Maps -> D:\a\1\s\artifacts\bin\Maps\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Maps.dll
  Controls.Core -> D:\a\1\s\artifacts\bin\Controls.Core\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Controls.Xaml -> D:\a\1\s\artifacts\bin\Controls.Xaml\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.Xaml.dll
  Microsoft.AspNetCore.Components.WebView.Maui -> D:\a\1\s\artifacts\bin\Microsoft.AspNetCore.Components.WebView.Maui\Debug\net10.0-windows10.0.19041.0\Microsoft.AspNetCore.Components.WebView.Maui.dll
  Controls.Maps -> D:\a\1\s\artifacts\bin\Controls.Maps\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.Maps.dll
  Controls.Foldable -> D:\a\1\s\artifacts\bin\Controls.Foldable\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.Foldable.dll
  Controls.TestCases.HostApp -> D:\a\1\s\artifacts\bin\Controls.TestCases.HostApp\Debug\net10.0-windows10.0.19041.0\win-x64\Controls.TestCases.HostApp.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:06:06.01
  Determining projects to restore...
  Restored D:\a\1\s\src\Controls\tests\CustomAttributes\Controls.CustomAttributes.csproj (in 956 ms).
  Restored D:\a\1\s\src\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj (in 3 ms).
  Restored D:\a\1\s\src\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj (in 4.1 sec).
  Restored D:\a\1\s\src\Controls\tests\TestCases.WinUI.Tests\Controls.TestCases.WinUI.Tests.csproj (in 7 sec).
  Restored D:\a\1\s\src\TestUtils\src\UITest.Core\UITest.Core.csproj (in 3 ms).
  Restored D:\a\1\s\src\TestUtils\src\UITest.Appium\UITest.Appium.csproj (in 8 ms).
  Restored D:\a\1\s\src\TestUtils\src\UITest.NUnit\UITest.NUnit.csproj (in 1.98 sec).
  Restored D:\a\1\s\src\TestUtils\src\UITest.Analyzers\UITest.Analyzers.csproj (in 5.56 sec).
  7 of 15 projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Graphics -> D:\a\1\s\artifacts\bin\Graphics\Debug\net10.0\Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Essentials -> D:\a\1\s\artifacts\bin\Essentials\Debug\net10.0\Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Controls.CustomAttributes -> D:\a\1\s\artifacts\bin\Controls.CustomAttributes\Debug\net10.0\Controls.CustomAttributes.dll
  Core -> D:\a\1\s\artifacts\bin\Core\Debug\net10.0\Microsoft.Maui.dll
  Controls.Core.Design -> D:\a\1\s\artifacts\bin\Controls.Core.Design\Debug\net472\Microsoft.Maui.Controls.DesignTools.dll
  Controls.BindingSourceGen -> D:\a\1\s\artifacts\bin\Controls.BindingSourceGen\Debug\netstandard2.0\Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Controls.Core -> D:\a\1\s\artifacts\bin\Controls.Core\Debug\net10.0\Microsoft.Maui.Controls.dll
  UITest.Core -> D:\a\1\s\artifacts\bin\UITest.Core\Debug\net10.0\UITest.Core.dll
  UITest.Appium -> D:\a\1\s\artifacts\bin\UITest.Appium\Debug\net10.0\UITest.Appium.dll
  UITest.NUnit -> D:\a\1\s\artifacts\bin\UITest.NUnit\Debug\net10.0\UITest.NUnit.dll
  VisualTestUtils -> D:\a\1\s\artifacts\bin\VisualTestUtils\Debug\netstandard2.0\VisualTestUtils.dll
  VisualTestUtils.MagickNet -> D:\a\1\s\artifacts\bin\VisualTestUtils.MagickNet\Debug\netstandard2.0\VisualTestUtils.MagickNet.dll
  UITest.Analyzers -> D:\a\1\s\artifacts\bin\UITest.Analyzers\Debug\netstandard2.0\UITest.Analyzers.dll
  Controls.TestCases.WinUI.Tests -> D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll
Test run for D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll
NUnit Adapter 4.5.0.0: Test execution started
Running selected tests in D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll
   NUnit3TestExecutor discovered 1 of 1 NUnit test cases using Current Discovery mode, Non-Explicit run
>>>>> 3/29/2026 12:28:54 AM FixtureSetup for Issue32356(Windows)
>>>>> 3/29/2026 12:29:03 AM ImageWithPathInLogicalNameShouldLoad Start
>>>>> 3/29/2026 12:29:05 AM ImageWithPathInLogicalNameShouldLoad Stop
>>>>> 3/29/2026 12:29:05 AM Log types: 
  Failed ImageWithPathInLogicalNameShouldLoad [2 s]
  Error Message:
   VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: ImageWithPathInLogicalNameShouldLoad.png (5.30% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow

  Stack Trace:
     at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay, Nullable`1 retryTimeout, Int32 cropLeft, Int32 cropRight, Int32 cropTop, Int32 cropBottom, Double tolerance, Boolean includeTitleBar) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 309
   at Microsoft.Maui.TestCases.Tests.Issues.Issue32356.ImageWithPathInLogicalNameShouldLoad() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32356.cs:line 25
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

NUnit Adapter 4.5.0.0: Test execution complete
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.11]   Discovering: Controls.TestCases.WinUI.Tests
[xUnit.net 00:00:00.31]   Discovered:  Controls.TestCases.WinUI.Tests

Total tests: 1
     Failed: 1
Test Run Failed.
 Total time: 34.6974 Seconds

🟢 With fix — 🖥️ Issue32356: PASS ✅ · 464s
  Determining projects to restore...
  All projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Graphics -> D:\a\1\s\artifacts\bin\Graphics\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Essentials -> D:\a\1\s\artifacts\bin\Essentials\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Essentials.dll
  Graphics.Win2D -> D:\a\1\s\artifacts\bin\Graphics.Win2D\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Graphics.Win2D.WinUI.Desktop.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Core -> D:\a\1\s\artifacts\bin\Core\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.dll
  Controls.BindingSourceGen -> D:\a\1\s\artifacts\bin\Controls.BindingSourceGen\Debug\netstandard2.0\Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Maps -> D:\a\1\s\artifacts\bin\Maps\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Maps.dll
  Controls.Core -> D:\a\1\s\artifacts\bin\Controls.Core\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Controls.Xaml -> D:\a\1\s\artifacts\bin\Controls.Xaml\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.Xaml.dll
  Microsoft.AspNetCore.Components.WebView.Maui -> D:\a\1\s\artifacts\bin\Microsoft.AspNetCore.Components.WebView.Maui\Debug\net10.0-windows10.0.19041.0\Microsoft.AspNetCore.Components.WebView.Maui.dll
  Controls.Foldable -> D:\a\1\s\artifacts\bin\Controls.Foldable\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.Foldable.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Controls.Maps -> D:\a\1\s\artifacts\bin\Controls.Maps\Debug\net10.0-windows10.0.19041.0\Microsoft.Maui.Controls.Maps.dll
  Controls.TestCases.HostApp -> D:\a\1\s\artifacts\bin\Controls.TestCases.HostApp\Debug\net10.0-windows10.0.19041.0\win-x64\Controls.TestCases.HostApp.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:05:42.80
  Determining projects to restore...
  All projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Graphics -> D:\a\1\s\artifacts\bin\Graphics\Debug\net10.0\Microsoft.Maui.Graphics.dll
  Controls.CustomAttributes -> D:\a\1\s\artifacts\bin\Controls.CustomAttributes\Debug\net10.0\Controls.CustomAttributes.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Essentials -> D:\a\1\s\artifacts\bin\Essentials\Debug\net10.0\Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Core -> D:\a\1\s\artifacts\bin\Core\Debug\net10.0\Microsoft.Maui.dll
  Controls.Core.Design -> D:\a\1\s\artifacts\bin\Controls.Core.Design\Debug\net472\Microsoft.Maui.Controls.DesignTools.dll
  Controls.BindingSourceGen -> D:\a\1\s\artifacts\bin\Controls.BindingSourceGen\Debug\netstandard2.0\Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.60-ci+azdo.13681899
  Controls.Core -> D:\a\1\s\artifacts\bin\Controls.Core\Debug\net10.0\Microsoft.Maui.Controls.dll
  UITest.Core -> D:\a\1\s\artifacts\bin\UITest.Core\Debug\net10.0\UITest.Core.dll
  VisualTestUtils -> D:\a\1\s\artifacts\bin\VisualTestUtils\Debug\netstandard2.0\VisualTestUtils.dll
  UITest.Appium -> D:\a\1\s\artifacts\bin\UITest.Appium\Debug\net10.0\UITest.Appium.dll
  VisualTestUtils.MagickNet -> D:\a\1\s\artifacts\bin\VisualTestUtils.MagickNet\Debug\netstandard2.0\VisualTestUtils.MagickNet.dll
  UITest.NUnit -> D:\a\1\s\artifacts\bin\UITest.NUnit\Debug\net10.0\UITest.NUnit.dll
  UITest.Analyzers -> D:\a\1\s\artifacts\bin\UITest.Analyzers\Debug\netstandard2.0\UITest.Analyzers.dll
  Controls.TestCases.WinUI.Tests -> D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll
Test run for D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll
NUnit Adapter 4.5.0.0: Test execution started
Running selected tests in D:\a\1\s\artifacts\bin\Controls.TestCases.WinUI.Tests\Debug\net10.0\Controls.TestCases.WinUI.Tests.dll
   NUnit3TestExecutor discovered 1 of 1 NUnit test cases using Current Discovery mode, Non-Explicit run
>>>>> 3/29/2026 12:36:40 AM FixtureSetup for Issue32356(Windows)
>>>>> 3/29/2026 12:36:49 AM ImageWithPathInLogicalNameShouldLoad Start
>>>>> 3/29/2026 12:36:51 AM ImageWithPathInLogicalNameShouldLoad Stop
  Passed ImageWithPathInLogicalNameShouldLoad [1 s]
NUnit Adapter 4.5.0.0: Test execution complete
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.11]   Discovering: Controls.TestCases.WinUI.Tests
[xUnit.net 00:00:00.33]   Discovered:  Controls.TestCases.WinUI.Tests

Test Run Successful.
Total tests: 1
     Passed: 1
 Total time: 26.5915 Seconds

📁 Fix files reverted (2 files)
  • eng/pipelines/ci-copilot.yml
  • src/Core/src/ImageSources/FileImageSourceService/FileImageSourceService.Windows.cs

@MauiBot MauiBot added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-changes-requested AI agent recommends changes - found a better alternative or issues labels Mar 29, 2026
@MauiBot MauiBot removed the s/agent-fix-win AI found a better alternative fix than the PR label Mar 29, 2026
@kubaflo kubaflo changed the base branch from main to inflight/current March 29, 2026 12:31
@kubaflo kubaflo merged commit 79182b7 into dotnet:inflight/current Mar 29, 2026
151 of 164 checks passed
PureWeen pushed a commit that referenced this pull request Apr 8, 2026
…32864)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fixes issue #32356 where images with LogicalName containing path
separators e.g., "challenges/groceries.png") failed to load on Windows
platform.

###  Root Cause

The Windows implementation in FileImageSourceService.Windows.cs was
directly concatenating the filename to the ms-appx:/// URI without
extracting the filename from paths containing separators.

### Fix details 

Extract the filename using Path.GetFileName() before creating the URI,
aligning Windows behavior with other platforms.

Fixes #32356

---------
devanathan-vaithiyanathan pushed a commit to devanathan-vaithiyanathan/maui that referenced this pull request Apr 9, 2026
…otnet#32864)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fixes issue dotnet#32356 where images with LogicalName containing path
separators e.g., "challenges/groceries.png") failed to load on Windows
platform.

###  Root Cause

The Windows implementation in FileImageSourceService.Windows.cs was
directly concatenating the filename to the ms-appx:/// URI without
extracting the filename from paths containing separators.

### Fix details 

Extract the filename using Path.GetFileName() before creating the URI,
aligning Windows behavior with other platforms.

Fixes dotnet#32356

---------
PureWeen pushed a commit that referenced this pull request Apr 14, 2026
…32864)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fixes issue #32356 where images with LogicalName containing path
separators e.g., "challenges/groceries.png") failed to load on Windows
platform.

###  Root Cause

The Windows implementation in FileImageSourceService.Windows.cs was
directly concatenating the filename to the ms-appx:/// URI without
extracting the filename from paths containing separators.

### Fix details 

Extract the filename using Path.GetFileName() before creating the URI,
aligning Windows behavior with other platforms.

Fixes #32356

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-image Image loading, sources, caching community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MauiImage with LogicalName containing path - is not working on Windows

6 participants