From: Jaehyun Cho Date: Thu, 6 Oct 2022 12:36:23 +0000 (+0900) Subject: [NUI] Fix Svace issues of dereferenced nullable variables X-Git-Tag: submit/tizen/20221012.094838~1^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa8769edd71409643b34f7edde88b4c76733059e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix Svace issues of dereferenced nullable variables Svace issues of dereferenced nullable variables have been fixed. --- diff --git a/src/Tizen.NUI.Components/Controls/AlertDialog.cs b/src/Tizen.NUI.Components/Controls/AlertDialog.cs index 5e98929c7..642bfaf63 100755 --- a/src/Tizen.NUI.Components/Controls/AlertDialog.cs +++ b/src/Tizen.NUI.Components/Controls/AlertDialog.cs @@ -119,9 +119,9 @@ namespace Tizen.NUI.Components } // Apply ItemSpacing. - if ((alertDialogStyle.ItemSpacing != null) && Layout is LinearLayout) + if ((alertDialogStyle.ItemSpacing != null) && (Layout is LinearLayout linearLayout)) { - (Layout as LinearLayout).CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height); + linearLayout.CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height); } // Apply Title style. @@ -553,9 +553,9 @@ namespace Tizen.NUI.Components VerticalAlignment = VerticalAlignment.Center, }; - if (styleApplied && (alertDialogStyle != null) && (alertDialogStyle.ItemSpacing != null) && (Layout is LinearLayout)) + if (styleApplied && (alertDialogStyle != null) && (alertDialogStyle.ItemSpacing != null) && (Layout is LinearLayout linearLayout)) { - (Layout as LinearLayout).CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height); + linearLayout.CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height); } this.Relayout += OnRelayout; diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs index ca69f12af..f22ffe0b9 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs @@ -67,9 +67,9 @@ namespace Tizen.NUI.Components public static readonly new BindableProperty PaddingProperty = BindableProperty.Create(nameof(Padding), typeof(Extents), typeof(FlexibleView), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (FlexibleView)bindable; - if (newValue != null) + if (newValue is Extents extents) { - instance.InternalPadding = newValue as Extents; + instance.InternalPadding = extents; } }, defaultValueCreator: (bindable) => diff --git a/src/Tizen.NUI.Components/Controls/Pagination.cs b/src/Tizen.NUI.Components/Controls/Pagination.cs index 5e6e78c43..2618c5cbc 100755 --- a/src/Tizen.NUI.Components/Controls/Pagination.cs +++ b/src/Tizen.NUI.Components/Controls/Pagination.cs @@ -710,9 +710,9 @@ namespace Tizen.NUI.Components return; } - if (container != null && container.Layout is LinearLayout) + if (container != null && (container.Layout is LinearLayout linearLayout)) { - (container.Layout as LinearLayout).CellPadding = new Size2D(indicatorSpacing, 0); + linearLayout.CellPadding = new Size2D(indicatorSpacing, 0); } for (int i = 0; i < indicatorList.Count; i++) diff --git a/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs b/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs index 606225ede..611f334d5 100755 --- a/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs +++ b/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs @@ -264,8 +264,7 @@ namespace Tizen.NUI.Wearable { for (int i = 0; i < Children.Count; i++) { - RecycleItem item = Children[i] as RecycleItem; - if (item.DataIndex == prevFocusedDataIndex) + if ((Children[i] is RecycleItem item) && (item.DataIndex == prevFocusedDataIndex)) { nextFocusedView = item; break; @@ -323,9 +322,9 @@ namespace Tizen.NUI.Wearable } focusedView = nextFocusedView; - if ((nextFocusedView as RecycleItem) != null) + if (nextFocusedView is RecycleItem item) { - prevFocusedDataIndex = (nextFocusedView as RecycleItem).DataIndex; + prevFocusedDataIndex = item.DataIndex; } ScrollTo(targetPosition, true); diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GetStaticObject.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GetStaticObject.cs index 8e91623f1..788cde137 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GetStaticObject.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GetStaticObject.cs @@ -54,11 +54,11 @@ namespace Tizen.NUI.EXaml if (null != fieldName) { - obj = type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public).GetValue(null); + obj = type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public)?.GetValue(null); } else { - obj = type.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public).GetValue(null); + obj = type.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public)?.GetValue(null); } } diff --git a/src/Tizen.NUI/src/internal/FrameBroker/DefaultFrameBroker.cs b/src/Tizen.NUI/src/internal/FrameBroker/DefaultFrameBroker.cs index d8314e1a4..90e04bf18 100755 --- a/src/Tizen.NUI/src/internal/FrameBroker/DefaultFrameBroker.cs +++ b/src/Tizen.NUI/src/internal/FrameBroker/DefaultFrameBroker.cs @@ -141,7 +141,10 @@ namespace Tizen.NUI private void TransitionSetFinished(object sender, EventArgs e) { - (sender as TransitionSet).Finished -= TransitionSetFinished; + if (sender is TransitionSet transitionSet) + { + transitionSet.Finished -= TransitionSetFinished; + } providerImage.Unparent(); providerImage.Dispose(); providerImage = null; diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index 26115841f..1499912a8 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -2530,9 +2530,15 @@ namespace Tizen.NUI.BaseComponents view.themeData?.selectorData?.BorderlineColor?.Reset(view); - Selector selector = newValue as Selector; - if (selector.HasAll()) view.SetBorderlineColor(selector.All); - else view.EnsureSelectorData().BorderlineColor = new TriggerableSelector(view, selector, view.SetBorderlineColor, true); + if (newValue is Selector selector) + { + if (selector.HasAll()) view.SetBorderlineColor(selector.All); + else view.EnsureSelectorData().BorderlineColor = new TriggerableSelector(view, selector, view.SetBorderlineColor, true); + } + else + { + view.SetBorderlineColor((Color)newValue); + } }, defaultValueCreator: (bindable) => { diff --git a/src/Tizen.NUI/src/public/Common/Container.cs b/src/Tizen.NUI/src/public/Common/Container.cs index a54c3afa4..da750959c 100755 --- a/src/Tizen.NUI/src/public/Common/Container.cs +++ b/src/Tizen.NUI/src/public/Common/Container.cs @@ -201,9 +201,8 @@ namespace Tizen.NUI if (null != parent) { - if (null != xNameToElements) + if ((null != xNameToElements) && (xNameToElements[pair.Key] is View holdedXElements)) { - var holdedXElements = xNameToElements[pair.Key] as View; holdedXElements.CopyBindingRelationShip(view); holdedXElements.CopyFrom(view);