From e9d02f3f58a7d181fca84399810bcbe5a5c176dc Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 7 Jul 2021 15:40:32 +0200 Subject: [PATCH] fix: Use explicit Lazy initializer Previously DXamlCore and CoreServices used Lazy without explicit initializer parameter. While this worked for debug build, linker removed the "unused" parameterless constructors for these types and reflection then could not find and use them. Using the explicit initializer ensures the constructor is explicitly used and is not linked away. --- src/Uno.UI/DirectUI/DXamlCore.cs | 2 +- src/Uno.UI/UI/Xaml/Internal/CoreServices.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI/DirectUI/DXamlCore.cs b/src/Uno.UI/DirectUI/DXamlCore.cs index 49b07eb49d..ae07ee3593 100644 --- a/src/Uno.UI/DirectUI/DXamlCore.cs +++ b/src/Uno.UI/DirectUI/DXamlCore.cs @@ -14,7 +14,7 @@ namespace DirectUI { internal class DXamlCore { - private static readonly Lazy _current = new Lazy(); + private static readonly Lazy _current = new Lazy(() => new DXamlCore()); private BuildTreeService? _buildTreeService; private BudgetManager? _budgetManager; diff --git a/src/Uno.UI/UI/Xaml/Internal/CoreServices.cs b/src/Uno.UI/UI/Xaml/Internal/CoreServices.cs index ca9e9f119e..6600aea5ca 100644 --- a/src/Uno.UI/UI/Xaml/Internal/CoreServices.cs +++ b/src/Uno.UI/UI/Xaml/Internal/CoreServices.cs @@ -13,7 +13,7 @@ namespace Uno.UI.Xaml.Core { internal class CoreServices { - private static Lazy _instance = new Lazy(); + private static Lazy _instance = new Lazy(() => new CoreServices()); private VisualTree? _mainVisualTree = null;