[NUI] Remove various build warnings (phase 1)
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 2 Aug 2024 06:26:48 +0000 (15:26 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Tue, 13 Aug 2024 06:45:22 +0000 (15:45 +0900)
Found some build warning list by below command

dotnet build /p:BuildWithAnalyzer=True -consoleloggerparameters:NoSummary

Their are too many warnings occurs, let we remove them by multiple phases.

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
20 files changed:
src/Tizen.NUI/src/internal/Common/DefaultItemLayoutProperty.cs
src/Tizen.NUI/src/internal/Common/RenderTask.cs
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs
src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/Common/Matrix.cs
src/Tizen.NUI/src/public/Common/Matrix3.cs
src/Tizen.NUI/src/public/Common/RelativeVector3.cs
src/Tizen.NUI/src/public/Common/TimePeriod.cs
src/Tizen.NUI/src/public/Common/WeakEvent.cs
src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs
src/Tizen.NUI/src/public/Images/ImageUrl.cs
src/Tizen.NUI/src/public/Images/PixelData.cs
src/Tizen.NUI/src/public/Images/PixelFormat.cs
src/Tizen.NUI/src/public/Rendering/VertexBuffer.cs
src/Tizen.NUI/src/public/Theme/ThemeManager.cs
src/Tizen.NUI/src/public/Utility/Capture.cs
src/Tizen.NUI/src/public/Utility/RenderEffect.cs

index ffec5b015d321bd58b0a058044d39bdcf186b500..64cd221d92006035b67e80334c35f21c78fa2d8f 100755 (executable)
@@ -21,6 +21,7 @@ namespace Tizen.NUI
 {
     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
     [EditorBrowsable(EditorBrowsableState.Never)]
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
     public enum DefaultItemLayoutProperty
     {
         /// <summary>
index ac8fbca7986a810953cc398f38e62ec6cefe67e4..99e65e28025179ec9ee6384348d79739c07a2ffa 100755 (executable)
@@ -66,6 +66,7 @@ namespace Tizen.NUI
             internal static readonly int RequiresSync = Interop.RenderTask.RequiresSyncGet();
         }
 
+#pragma warning disable CA1707
         internal static SWIGTYPE_p_f_r_Dali__Vector2__bool DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION
         {
             get
@@ -148,6 +149,7 @@ namespace Tizen.NUI
                 return ret;
             }
         }
+#pragma warning restore CA1707
 
         public RenderTask() : this(Interop.RenderTask.NewRenderTask(), true)
         {
@@ -405,6 +407,7 @@ namespace Tizen.NUI
         }
 
         /// <since_tizen> 3 </since_tizen>
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
         public enum RefreshRate
         {
             REFRESH_ONCE = 0,
index 9db7ef81c9eecf72675e0502f8a081a9affa07cd..f8b162623ca3c2832f4c4657d3c4c6d1e0a8f966 100755 (executable)
@@ -2085,7 +2085,7 @@ namespace Tizen.NUI.BaseComponents
         /// (Example : if we change SynchronousLoading property from 'true' to 'false', or if we call this function during UpdateImage)
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual void UpdateImage(int key, PropertyValue value, bool requiredVisualCreation = true)
+        protected void UpdateImage(int key, PropertyValue value, bool requiredVisualCreation = true)
         {
             // Update image property map value as inputed value.
             if (key != 0)
index 0c90bc22f6d4aa625e1bbc364f79ea44ab1848a8..215002124496dadf2d9192e71d37a9ecb0b1fb9f 100755 (executable)
@@ -1507,7 +1507,6 @@ namespace Tizen.NUI.BaseComponents
         };
         private states currentStates;
 
-        private const string tag = "NUITEST";
         private event EventHandler finishedEventHandler;
 
         private void OnFinished()
index b1255b0141894e8a1645655f311ff02233922f39..e7deb1ed7c7bedd5a743960cce74122be377ed28 100755 (executable)
@@ -1214,11 +1214,16 @@ namespace Tizen.NUI.BaseComponents
         /// <summary>
         /// Copy the previously selected text from the text control into the clipboard.
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when argument is null. </exception>
         /// <param name="textEditor">The textEditor control from which the text is copied.</param>
         /// <returns>The copied text.</returns>
         /// <since_tizen> 9 </since_tizen>
         public static string CopyToClipboard(TextEditor textEditor)
         {
+            if (textEditor == null)
+            {
+                throw new ArgumentNullException(nameof(textEditor), "TextEditor should not be null.");
+            }
             string copiedText = Interop.TextEditor.CopyText(textEditor.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return copiedText;
@@ -1227,11 +1232,16 @@ namespace Tizen.NUI.BaseComponents
         /// <summary>
         /// Copy the previously selected text from the text control into the clipboard.
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when argument is null. </exception>
         /// <param name="textField">The textField control from which the text is copied.</param>
         /// <returns>The copied text.</returns>
         /// <since_tizen> 9 </since_tizen>
         public static string CopyToClipboard(TextField textField)
         {
+            if (textField == null)
+            {
+                throw new ArgumentNullException(nameof(textField), "TextField should not be null.");
+            }
             string copiedText = Interop.TextField.CopyText(textField.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return copiedText;
@@ -1240,11 +1250,16 @@ namespace Tizen.NUI.BaseComponents
         /// <summary>
         /// Cut the previously selected text from the text control into the clipboard.
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when argument is null. </exception>
         /// <param name="textEditor">The textEditor control from which the text is cut.</param>
         /// <returns>The cut text.</returns>
         /// <since_tizen> 9 </since_tizen>
         public static string CutToClipboard(TextEditor textEditor)
         {
+            if (textEditor == null)
+            {
+                throw new ArgumentNullException(nameof(textEditor), "TextEditor should not be null.");
+            }
             string cutText = Interop.TextEditor.CutText(textEditor.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return cutText;
@@ -1253,11 +1268,16 @@ namespace Tizen.NUI.BaseComponents
         /// <summary>
         /// Cut the previously selected text from the text control into the clipboard.
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when argument is null. </exception>
         /// <param name="textField">The textField control from which the text is cut.</param>
         /// <returns>The cut text.</returns>
         /// <since_tizen> 9 </since_tizen>
         public static string CutToClipboard(TextField textField)
         {
+            if (textField == null)
+            {
+                throw new ArgumentNullException(nameof(textField), "TextField should not be null.");
+            }
             string cutText = Interop.TextField.CutText(textField.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return cutText;
@@ -1271,10 +1291,15 @@ namespace Tizen.NUI.BaseComponents
         /// the text will be appended to the last cursor position and the text control will gain focus.
         /// If some text inside the text control is selected, it will be replaced by the pasted text.
         /// </remarks>
+        /// <exception cref="ArgumentNullException"> Thrown when argument is null. </exception>
         /// <param name="textEditor">The textEditor control into which the text is pasted.</param>
         /// <since_tizen> 9 </since_tizen>
         public static void PasteTo(TextEditor textEditor)
         {
+            if (textEditor == null)
+            {
+                throw new ArgumentNullException(nameof(textEditor), "TextEditor should not be null.");
+            }
             Interop.TextEditor.PasteText(textEditor.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
@@ -1287,10 +1312,15 @@ namespace Tizen.NUI.BaseComponents
         /// the text will be appended to the last cursor position and the text control will gain focus.
         /// If some text inside the text control is selected, it will be replaced by the pasted text.
         /// </remarks>
+        /// <exception cref="ArgumentNullException"> Thrown when argument is null. </exception>
         /// <param name="textField">The textField control into which the text is pasted.</param>
         /// <since_tizen> 9 </since_tizen>
         public static void PasteTo(TextField textField)
         {
+            if (textField == null)
+            {
+                throw new ArgumentNullException(nameof(textField), "TextEditor should not be null.");
+            }
             Interop.TextField.PasteText(textField.SwigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
index 59740e6cce407500492494edec26cf27acf3d8f8..d0fa08a5587e15fec172ebcdff599d0587523002 100755 (executable)
@@ -637,6 +637,7 @@ namespace Tizen.NUI.BaseComponents
         /// If the classes that are not derived from Control (such as View, ImageView and TextLabel) want to use this system,
         /// please set <see cref="EnableControlState"/> to true.
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when set null. </exception>
         /// 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 ControlState ControlState
@@ -651,6 +652,10 @@ namespace Tizen.NUI.BaseComponents
                 {
                     return;
                 }
+                if (value == null)
+                {
+                    throw new ArgumentNullException(nameof(value), "ControlState should not be null.");
+                }
 
                 var prevState = ControlState;
 
index 5a5f90b8ef4a1b6c47ee672e5b781dcd86010f83..e0a94fdef3566dfd9de1b2c732895bec680250be 100755 (executable)
@@ -1801,7 +1801,7 @@ namespace Tizen.NUI.BaseComponents
         /// Apply initial style to the view.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual void InitializeStyle(ViewStyle style = null)
+        protected void InitializeStyle(ViewStyle style = null)
         {
             if (style == null && ThemeManager.InitialThemeDisabled)
             {
index 55e67607fd40e1ed9b8f66bd591d708132dd477b..6b28fe08bf4cb704aefdae0fb8f05068323dc0c8 100755 (executable)
@@ -128,6 +128,7 @@ namespace Tizen.NUI
         /// </code>
         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1065: Do not raise exceptions in unexpected locations")]
         public static Matrix Identity
         {
             get
index ffba8b569e7f9ded55fbad823f6abb1e69eadd7c..2adeeb2e079a298a6ba7da444af1f7c53f7b45ef 100755 (executable)
@@ -135,6 +135,7 @@ namespace Tizen.NUI
         /// </code>
         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1065: Do not raise exceptions in unexpected locations")]
         public static Matrix3 Identity
         {
             get
index 744632f3bc6aee5d82dfebe3104b20599746c3ed..3e24d233259fa44817570ecdb4ea3fbcb422bb8c 100755 (executable)
@@ -246,6 +246,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Vector3(RelativeVector3 relativeVector3)
         {
+            if (relativeVector3 == null) return null;
             return new Vector3(relativeVector3.X, relativeVector3.Y, relativeVector3.Z);
         }
 
@@ -254,6 +255,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator RelativeVector3(Vector3 vec)
         {
+            if (vec == null) return null;
             return new RelativeVector3(vec.X, vec.Y, vec.Z);
         }
 
index 028eb925fc74ca05b535120c71190c97bf838eb2..0e1add1d0442f728dcbcb9c201e26bd59962f838 100755 (executable)
@@ -55,6 +55,7 @@ namespace Tizen.NUI
         /// A delay before the time period in milliseconds
         /// </summary>
         /// <since_tizen> 9 </since_tizen>
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1065: Do not raise exceptions in unexpected locations")]
         public int DelayMilliseconds
         {
             set
@@ -74,6 +75,7 @@ namespace Tizen.NUI
         /// The duration of the time period in milliseconds
         /// </summary>
         /// <since_tizen> 9 </since_tizen>
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1065: Do not raise exceptions in unexpected locations")]
         public int DurationMilliseconds
         {
             set
index 1a24c9c8cdfeaa203e69d5a984ed25a452a2fed5..c57e7e6912457d84d0c5f36768e4c64ac7442824 100755 (executable)
@@ -45,6 +45,11 @@ namespace Tizen.NUI
         /// <since_tizen> 12 </since_tizen>
         public virtual void Add(T handler)
         {
+            if (handler == null)
+            {
+                // Do nothing.
+                return;
+            }
             handlers.Add(new WeakHandler<T>(handler));
             OnCountIncreased();
 
@@ -57,6 +62,12 @@ namespace Tizen.NUI
         /// <since_tizen> 12 </since_tizen>
         public virtual void Remove(T handler)
         {
+            if (handler == null)
+            {
+                // Do nothing.
+                return;
+            }
+
             int lastIndex = handlers.FindLastIndex(item => item.Equals(handler));
 
             if (lastIndex >= 0)
index c2ad8a358a52da29f8e2c3775c5aacb1068be754..b37a11c2afc8d0fb313f7074bc59ec1e0cc99a70 100755 (executable)
@@ -230,9 +230,9 @@ namespace Tizen.NUI
         /// Removes listener for drop targets
         /// </summary>
         /// <param name="targetView">The target view</param>
-        /// <param name="callback">The callback function to remove</param>
+        /// <param name="_">The callback function to remove(Not used)</param>
         /// <since_tizen> 10 </since_tizen>
-        public void RemoveListener(View targetView, DragAndDropEventHandler callback)
+        public void RemoveListener(View targetView, DragAndDropEventHandler _)
         {
             if (!targetEventDictionary.ContainsKey(targetView))
             {
@@ -300,9 +300,9 @@ namespace Tizen.NUI
         /// Removes listener for drop targets
         /// </summary>
         /// <param name="targetWindow">The target window</param>
-        /// <param name="callback">The callback function to remove</param>
+        /// <param name="_">The callback function to remove(Not used)</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public void RemoveListener(Window targetWindow, DragAndDropWindowEventHandler callback)
+        public void RemoveListener(Window targetWindow, DragAndDropWindowEventHandler _)
         {
             if (!targetWindowEventDictionary.ContainsKey(targetWindow))
             {
index 120803c30c66fbb412de6f691015f4e0766b05a9..e68c713800b0cd242fc8122f1a6fc5e02131249f 100644 (file)
@@ -66,6 +66,7 @@ namespace Tizen.NUI
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1065: Do not raise exceptions in unexpected locations")]
         public override string ToString()
         {
             string ret = Interop.ImageUrl.GetUrl(SwigCPtr);
index 9f915ad4b2a3bf79f5fb20cd8a246d222f1ca47c..fc824ab82e7e0cb1912efda7fe98bd784d4974ec 100755 (executable)
@@ -45,11 +45,12 @@ namespace Tizen.NUI
         /// <param name="width">Buffer width in pixels.</param>
         /// <param name="height">Buffer height in pixels.</param>
         /// <param name="pixelFormat">The pixel format.</param>
-        /// <param name="releaseFunction">The function used to release the memory.</param>
+        /// <param name="_">Not used parameter.</param>
         /// <since_tizen> 5 </since_tizen>
         /// This will be deprecated after API level 9. ReleaseFunction is not useful in C#.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat, PixelData.ReleaseFunction releaseFunction) : this(Interop.PixelData.New(buffer, bufferSize, width, height, (int)pixelFormat), true)
+        [Obsolete("Do not use this constructor. Use PixelData(byte[], uint, uint, uint, PixelFormat).")]
+        public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat, PixelData.ReleaseFunction _) : this(Interop.PixelData.New(buffer, bufferSize, width, height, (int)pixelFormat), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
index d9392cd872c50644d8fdbaf4aea43d078f1db1e7..9e2754c68def48e31fe51cf3e9642d06fe116fa2 100755 (executable)
@@ -21,7 +21,8 @@ namespace Tizen.NUI
     /// Enumeration for Pixel formats.<br />
     /// Pixel format, default color depth is RGBA 32 bit with alpha.
     /// </summary>
-    /// /// <since_tizen> 3 </since_tizen>
+    /// <since_tizen> 3 </since_tizen>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
     public enum PixelFormat
     {
         /// <summary>
index 25dd5d2d1cdc551daa5e8ffaf0ef787b29e10765..3e8542a3142ecac4ab0afcbdb60eb1ff7d0f5183 100755 (executable)
@@ -52,7 +52,7 @@ namespace Tizen.NUI
         /// <exception cref="ArgumentNullException"> Thrown when vertices is null or length of the vertices is 0. </exception>
         /// <exception cref="OverflowException"> Thrown when length of the vertices is overflow. </exception>
         /// <since_tizen> 8 </since_tizen>
-
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1715: Identifiers should have correct prefix")]
         public void SetData<VertexType>(VertexType[] vertices) where VertexType : struct
         {
             if (null == vertices || vertices.Length == 0)
index 9c3ae1201b20782a8febecd7cdb7bf2537996dee..df6cddfa9358f4972dcca2bc957b3e1b37c7b23b 100755 (executable)
@@ -36,7 +36,9 @@ namespace Tizen.NUI
     /// </example>
     /// <summary></summary>
     /// <since_tizen> 9 </since_tizen>
+#pragma warning disable CA1724
     public static class ThemeManager
+#pragma warning restore CA1724
     {
         /// <summary>
         /// The default light theme name preloaded in platform.
index 9bd506b0d30fbbfdc409e2c09e8b2bd10cc1084b..d74d7a71b8f824ee99f22d9ae6ac98e1c419f1ef 100755 (executable)
@@ -139,7 +139,7 @@ namespace Tizen.NUI
             }
             else if (null == path)
             {
-                throw new ArgumentNullException("path should not be null");
+                throw new ArgumentNullException(nameof(path), "path should not be null");
             }
             else if (null == position)
             {
@@ -183,7 +183,7 @@ namespace Tizen.NUI
             }
             else if (null == path)
             {
-                throw new ArgumentNullException("path should not be null");
+                throw new ArgumentNullException(nameof(path), "path should not be null");
             }
             else if (quality > 100)
             {
@@ -226,7 +226,7 @@ namespace Tizen.NUI
             }
             else if (null == path)
             {
-                throw new ArgumentNullException("path should not be null");
+                throw new ArgumentNullException(nameof(path), "path should not be null");
             }
             else if (null == color)
             {
@@ -267,7 +267,7 @@ namespace Tizen.NUI
             }
             else if (null == path)
             {
-                throw new ArgumentNullException("path should not be null");
+                throw new ArgumentNullException(nameof(path), "path should not be null");
             }
 
             if (source is View || source is Layer)
index 9ff734f2d58526d3a6b3d5eca948f7d8b9dc2057..cd409bdb90bd6928b3f422541ff4296b957ed8bf 100644 (file)
@@ -60,6 +60,7 @@ namespace Tizen.NUI
     /// <code>
     /// RenderEffect.CreateBackgroundBlurEffect(blurRadius);
     /// </code>
+    /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
     sealed class BackgroundBlurEffect : RenderEffect
     {