Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/Controls/src/Xaml/ApplyPropertiesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,6 @@ void ProvideValue(ref object value, ElementNode node, object source, XmlName pro
}
catch (Exception e)
{
// StaticResourceExtension must always rethrow even when a handler is present —
// unlike other markup extensions, swallowing this exception would silently apply
// an invalid value to the property. Notify the handler first to log the error.
if (markupExtension is StaticResourceExtension)
{
Context.ExceptionHandler?.Invoke(e);
throw;
}

if (Context.ExceptionHandler != null)
Context.ExceptionHandler(e);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ public object ProvideValue(IServiceProvider serviceProvider)
&& !TryGetApplicationLevelResource(Key, out resource, out resourceDictionary))
{
var xmlLineInfo = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) is IXmlLineInfoProvider xmlLineInfoProvider ? xmlLineInfoProvider.XmlLineInfo : null;
var ex = new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
if (Controls.Internals.ResourceLoader.ExceptionHandler2 is var ehandler && ehandler != null)
{
var ex = new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
var rootObjectProvider = (IRootObjectProvider)serviceProvider.GetService(typeof(IRootObjectProvider));
var root = rootObjectProvider.RootObject;
ehandler.Invoke((ex, XamlFilePathAttribute.GetFilePathForObject(root)));
return null;
}
// Throw an exception when the key is not found
throw ex;
else
throw new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
}

Diagnostics.ResourceDictionaryDiagnostics.OnStaticResourceResolved(resourceDictionary, Key, valueProvider.TargetObject, valueProvider.TargetProperty);
Expand Down
50 changes: 0 additions & 50 deletions src/Controls/tests/DeviceTests/Xaml/StaticResourceTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ internal void MissingResourceExceptionAreHandled(XamlInflator inflator)
handled = true;
Assert.Equal(13, xpe.XmlInfo.LinePosition);
}

};

// Now expect the exception to be thrown (after handler is invoked)
var exception = Assert.Throws<XamlParseException>(() => new HotReloadStaticResourceException(inflator));

// Verify handler was invoked and exception details are correct
Assert.True(handled, "Exception handler was not invoked");
Assert.Contains("StaticResource not found for key MissingResource", exception.Message, System.StringComparison.Ordinal);
var page = new HotReloadStaticResourceException(inflator);
Assert.True(handled, "Exception was not handled");
}
#else
[Fact(Skip = "This test runs only in debug")]
Expand Down
Loading