From: Jiyun Yang Date: Wed, 9 Dec 2020 03:55:07 +0000 (+0900) Subject: [NUI] Fix CA2214 X-Git-Tag: accepted/tizen/unified/20210219.040944~203 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1626bb7206ff99fa62553db1480ec8690142368e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix CA2214 CA2214 Do not call overridable methods in constructors. * View.cs * In the current design, it is hard to remove virtual method call in View constructor. * So the patch moved method calling to the private method newly defined. * ControlStyle.cs * TextFieldStyle.cs * ImageViewStyle.cs * TextLabelStyle.cs * Removed unnecessary constructors. Signed-off-by: Jiyun Yang --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index 373d73e..56a329e 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -269,10 +269,6 @@ namespace Tizen.NUI.BaseComponents private readonly TriggerableSelector resourceUrlSelector = new TriggerableSelector(ResourceUrlProperty); private readonly TriggerableSelector borderSelector = new TriggerableSelector(BorderProperty); - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ImageViewStyle Style => new ImageViewStyle(this); - /// /// Creates an initialized ImageView. /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs index 43c7d1e..625ddff 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs @@ -130,15 +130,6 @@ namespace Tizen.NUI.BaseComponents { } - /// - /// Create an instance and set properties from the given ImageView. - /// - /// The ImageView instance that includes property data. - [EditorBrowsable(EditorBrowsableState.Never)] - public ImageViewStyle(ImageView imageView) : base(imageView) - { - } - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public bool? PreMultipliedAlpha diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs index d969960..5669eda 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs @@ -534,15 +534,6 @@ namespace Tizen.NUI.BaseComponents { } - /// - /// Create an instance and set properties from the given TextField. - /// - /// The TextField instance that includes property data. - [EditorBrowsable(EditorBrowsableState.Never)] - public TextFieldStyle(TextField textField) : base(textField) - { - } - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public Selector TranslatableText diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs index b2bd019..3aff814 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs @@ -327,15 +327,6 @@ namespace Tizen.NUI.BaseComponents { } - /// - /// Create an instance and set properties from the given TextLabel. - /// - /// The TextLabel instance that includes property data. - [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabelStyle(TextLabel textLabel) : base(textLabel) - { - } - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public Selector TranslatableText diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs index c7e6a6a..782e050 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs @@ -99,16 +99,6 @@ namespace Tizen.NUI.BaseComponents CopyFrom(viewAttributes); } - /// - /// Create an instance and set properties from the given view. - /// - /// The View that includes property data. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewStyle(View view) - { - CopyPropertiesFromView(view); - } - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public string StyleName diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index cf58f2b..8908d7f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -38,10 +38,6 @@ namespace Tizen.NUI.BaseComponents static TextField() { } - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public TextFieldStyle Style => new TextFieldStyle(this); - /// /// Creates the TextField control. /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 8dd7322..2e034e5 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -81,16 +81,6 @@ namespace Tizen.NUI.BaseComponents private TextLabelSelectorData selectorData; /// - /// Return a copied Style instance of the TextLabel. - /// - /// - /// It returns copied style instance so that changing it does not effect to the view. - /// Style setting is possible by using constructor or the function of . - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabelStyle Style => new TextLabelStyle(this); - - /// /// Creates the TextLabel control. /// /// 3 diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 0e55f65..1d22d93 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -124,10 +124,7 @@ namespace Tizen.NUI.BaseComponents internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown) { - if (!ThemeManager.ThemeApplied) return; - - if (viewStyle == null) UpdateStyle(); // Use style in the current theme - else ApplyStyle(viewStyle.Clone()); // Use given style + InitializeStyle(viewStyle); } internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.View.Upcast(cPtr), cMemoryOwn) diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index 47735cd..6355c83 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -1399,5 +1399,13 @@ namespace Tizen.NUI.BaseComponents { return false; } + + private void InitializeStyle(ViewStyle style) + { + if (!ThemeManager.ThemeApplied) return; + + if (viewStyle == null) UpdateStyle(); // Use style in the current theme + else ApplyStyle(viewStyle.Clone()); // Use given style + } } }