[NUI] Fix CA2214
authorJiyun Yang <ji.yang@samsung.com>
Wed, 9 Dec 2020 03:55:07 +0000 (12:55 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 15 Dec 2020 06:33:59 +0000 (15:33 +0900)
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 <ji.yang@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs
src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs
src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs
src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs

index 373d73e..56a329e 100755 (executable)
@@ -269,10 +269,6 @@ namespace Tizen.NUI.BaseComponents
         private readonly TriggerableSelector<string> resourceUrlSelector = new TriggerableSelector<string>(ResourceUrlProperty);
         private readonly TriggerableSelector<Rectangle> borderSelector = new TriggerableSelector<Rectangle>(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);
-
         /// <summary>
         /// Creates an initialized ImageView.
         /// </summary>
index 43c7d1e..625ddff 100755 (executable)
@@ -130,15 +130,6 @@ namespace Tizen.NUI.BaseComponents
         {
         }
 
-        /// <summary>
-        /// Create an instance and set properties from the given ImageView.
-        /// </summary>
-        /// <param name="imageView">The ImageView instance that includes property data.</param>
-        [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
index d969960..5669eda 100755 (executable)
@@ -534,15 +534,6 @@ namespace Tizen.NUI.BaseComponents
         {
         }
 
-        /// <summary>
-        /// Create an instance and set properties from the given TextField.
-        /// </summary>
-        /// <param name="textField">The TextField instance that includes property data.</param>
-        [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<string> TranslatableText
index b2bd019..3aff814 100755 (executable)
@@ -327,15 +327,6 @@ namespace Tizen.NUI.BaseComponents
         {
         }
 
-        /// <summary>
-        /// Create an instance and set properties from the given TextLabel.
-        /// </summary>
-        /// <param name="textLabel">The TextLabel instance that includes property data.</param>
-        [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<string> TranslatableText
index c7e6a6a..782e050 100755 (executable)
@@ -99,16 +99,6 @@ namespace Tizen.NUI.BaseComponents
             CopyFrom(viewAttributes);
         }
 
-        /// <summary>
-        /// Create an instance and set properties from the given view.
-        /// </summary>
-        /// <param name="view">The View that includes property data.</param>
-        [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
index cf58f2b..8908d7f 100755 (executable)
@@ -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);
-
         /// <summary>
         /// Creates the TextField control.
         /// </summary>
index 8dd7322..2e034e5 100755 (executable)
@@ -81,16 +81,6 @@ namespace Tizen.NUI.BaseComponents
         private TextLabelSelectorData selectorData;
 
         /// <summary>
-        /// Return a copied Style instance of the TextLabel.
-        /// </summary>
-        /// <remarks>
-        /// 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 <see cref="View.ApplyStyle"/>.
-        /// </remarks>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public TextLabelStyle Style => new TextLabelStyle(this);
-
-        /// <summary>
         /// Creates the TextLabel control.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
index 0e55f65..1d22d93 100755 (executable)
@@ -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)
index 47735cd..6355c83 100755 (executable)
@@ -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
+        }
     }
 }