From 38bab0f6e717800d9e4c90dbe43408b185a506d7 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa Date: Mon, 4 Nov 2024 12:41:02 +0200 Subject: [PATCH] chore: build errors --- src/Uno.UI/UI/Xaml/DependencyObjectStore.cs | 38 ++++++++------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs b/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs index ff467575f3db..a22c07b07591 100644 --- a/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs +++ b/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs @@ -107,13 +107,6 @@ public static class TraceProvider /// private SpecializedResourceDictionary.ResourceKey? _themeLastUsed; - private const bool _validatePropertyOwner = -#if DEBUG - true; -#else - false; -#endif - #if UNO_HAS_ENHANCED_LIFECYCLE internal bool IsDisposed => _isDisposed; #endif @@ -797,25 +790,24 @@ private void WritePropertyEventTrace(int eventId, DependencyProperty property, D [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ValidatePropertyOwner(DependencyProperty property) { - if (_validatePropertyOwner) - { - var isFrameworkElement = _originalObjectType.Is(typeof(FrameworkElement)); - var isMixinFrameworkElement = _originalObjectRef.Target is IFrameworkElement && !isFrameworkElement; +#if DEBUG + var isFrameworkElement = _originalObjectType.Is(typeof(FrameworkElement)); + var isMixinFrameworkElement = _originalObjectRef.Target is IFrameworkElement && !isFrameworkElement; - if ( - !_originalObjectType.Is(property.OwnerType) - && !property.IsAttached + if ( + !_originalObjectType.Is(property.OwnerType) + && !property.IsAttached - // Don't fail validation for properties that are located on non-FrameworkElement types - // e.g. ScrollContentPresenter, for which using the Name property should not fail. - && !isMixinFrameworkElement - ) - { - throw new InvalidOperationException( - $"The Dependency Property [{property.Name}] is owned by [{property.OwnerType}] and cannot be used on [{_originalObjectType}]" - ); - } + // Don't fail validation for properties that are located on non-FrameworkElement types + // e.g. ScrollContentPresenter, for which using the Name property should not fail. + && !isMixinFrameworkElement + ) + { + throw new InvalidOperationException( + $"The Dependency Property [{property.Name}] is owned by [{property.OwnerType}] and cannot be used on [{_originalObjectType}]" + ); } +#endif } public long RegisterPropertyChangedCallback(DependencyProperty property, DependencyPropertyChangedCallback callback)