Skip to content

Revert "[Android, iOS] Throw exceptions consistently for invalid StaticResource references to prevent relaunch crashes (#33859)"#35130

Merged
PureWeen merged 1 commit into
release/10.0.1xx-sr6from
revert-33859-sr6
Apr 24, 2026
Merged

Revert "[Android, iOS] Throw exceptions consistently for invalid StaticResource references to prevent relaunch crashes (#33859)"#35130
PureWeen merged 1 commit into
release/10.0.1xx-sr6from
revert-33859-sr6

Conversation

@PureWeen
Copy link
Copy Markdown
Member

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

Reverts #33859 on the release/10.0.1xx-sr6 branch due to a regression.

This change introduced consistent exception throwing for invalid StaticResource references, but it is causing regressions in production scenarios.

…icResource references to prevent relaunch crashes (#33859)"

This reverts commit 6874c80.
Copilot AI review requested due to automatic review settings April 24, 2026 13:59
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35130

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35130"

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

Reverts the behavior introduced in #33859 on release/10.0.1xx-sr6, restoring prior handling for invalid {StaticResource ...} lookups to avoid production regressions.

Changes:

  • Restore {StaticResource} behavior to return null (after invoking ResourceLoader.ExceptionHandler2) instead of always throwing.
  • Remove the ApplyPropertiesVisitor special-case that forced StaticResourceExtension to rethrow even when an exception handler is present.
  • Update/remove tests that were asserting the “always throw” behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/Controls/tests/Xaml.UnitTests/HotReloadStaticResourceException.xaml.cs Updates the debug/hot reload unit test to validate handler invocation without expecting a thrown exception.
src/Controls/tests/DeviceTests/Xaml/StaticResourceTests.cs Removes the device test that asserted missing StaticResource always throws with an exception handler present.
src/Controls/src/Xaml/MarkupExtensions/StaticResourceExtension.cs Restores prior behavior: invoke ExceptionHandler2 (with file path) and return null; otherwise throw XamlParseException.
src/Controls/src/Xaml/ApplyPropertiesVisitor.cs Removes the forced-rethrow path for StaticResourceExtension, returning to generic exception-handler behavior.
Comments suppressed due to low confidence (1)

src/Controls/src/Xaml/ApplyPropertiesVisitor.cs:287

  • In this catch block, throw e; resets the exception stack trace to this location. With the StaticResourceExtension special-casing removed above, missing StaticResource exceptions will now typically be rethrown via this path (when Context.ExceptionHandler is null), which makes diagnosing the original XAML failure harder. Please rethrow while preserving the original stack trace (e.g., use a bare throw; here).
			{
				if (Context.ExceptionHandler != null)
					Context.ExceptionHandler(e);
				else
					throw e;

@PureWeen PureWeen merged commit 6c514cc into release/10.0.1xx-sr6 Apr 24, 2026
46 checks passed
@PureWeen PureWeen deleted the revert-33859-sr6 branch April 24, 2026 16:16
@github-actions github-actions Bot added this to the .NET 10 SR6 milestone Apr 24, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants