From 340fdda2032d20946fd44fc2d7cfc66e7b2e92d6 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Thu, 21 Nov 2024 13:38:59 +0800 Subject: [PATCH] Don't require obsolete ISystemResourcesProvider Fixes #24216 --- src/Controls/src/Core/Application/Application.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Controls/src/Core/Application/Application.cs b/src/Controls/src/Core/Application/Application.cs index ae9524897d65..5bde671e5db3 100644 --- a/src/Controls/src/Core/Application/Application.cs +++ b/src/Controls/src/Core/Application/Application.cs @@ -21,7 +21,7 @@ public partial class Application : Element, IResourcesProvider, IApplicationCont readonly Lazy> _platformConfigurationRegistry; #pragma warning disable CS0612 // Type or member is obsolete - readonly Lazy _systemResources; + readonly Lazy _systemResources; #pragma warning restore CS0612 // Type or member is obsolete IAppIndexingProvider? _appIndexProvider; @@ -40,10 +40,13 @@ internal Application(bool setCurrentApplication) SetCurrentApplication(this); #pragma warning disable CS0612 // Type or member is obsolete - _systemResources = new Lazy(() => + _systemResources = new Lazy(() => { var systemResources = DependencyService.Get().GetSystemResources(); - systemResources.ValuesChanged += OnParentResourcesChanged; + if (systemResources is not null) + { + systemResources.ValuesChanged += OnParentResourcesChanged; + } return systemResources; }); #pragma warning restore CS0612 // Type or member is obsolete @@ -127,7 +130,7 @@ public Page? MainPage [EditorBrowsable(EditorBrowsableState.Never)] public NavigationProxy? NavigationProxy { get; private set; } - internal IResourceDictionary SystemResources => _systemResources.Value; + internal IResourceDictionary? SystemResources => _systemResources.Value; /// [EditorBrowsable(EditorBrowsableState.Never)]