[NUI] Fix Accessibility warning messages (#2705)
authorSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Mon, 8 Mar 2021 01:17:45 +0000 (10:17 +0900)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Mon, 8 Mar 2021 08:29:15 +0000 (17:29 +0900)
* [NUI] Fix Accessibility warning messages

 - CA1066 : Implemented `IEquatable` interface to GestureInfoType structure.
 - CA1034 : Added public types to replace nested types of events.

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
* [NUI] Update properties of EventArgs according to reviews

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ViewAccessibilityEvent.cs

index 3052cc4..9fda02b 100755 (executable)
@@ -25,7 +25,8 @@ namespace Tizen.NUI.BaseComponents
 {
     [EditorBrowsable(EditorBrowsableState.Never)]
     [StructLayout(LayoutKind.Sequential)]
-    public struct GestureInfoType {
+    public struct GestureInfoType : IEquatable<GestureInfoType>
+    {
         [EditorBrowsable(EditorBrowsableState.Never)]
         public AccessibilityGesture type { get; set; }
 
@@ -50,10 +51,19 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public override bool Equals(System.Object obj)
         {
-            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
+            if(obj is GestureInfoType)
+            {
+                return this.Equals((GestureInfoType)obj);
+            }
+            return false;
+        }
+
+        public bool Equals(GestureInfoType other)
+        {
+            if ((other == null) || !this.GetType().Equals(other.GetType()))
                 return false;
 
-            GestureInfoType sec = (GestureInfoType)obj;
+            GestureInfoType sec = (GestureInfoType)other;
             return
               type == sec.type &&
               xBeg == sec.xBeg &&
@@ -65,12 +75,46 @@ namespace Tizen.NUI.BaseComponents
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
+        public static bool operator ==(GestureInfoType arg1, GestureInfoType arg2)
+        {
+            return arg1.Equals(arg2);
+        }
+
+        /// <summary>
+        /// The != operator.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static bool operator !=(GestureInfoType arg1, GestureInfoType arg2)
+        {
+            return !arg1.Equals(arg2);
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override int GetHashCode()
         {
             return Tuple.Create((int)type, xBeg, xEnd, yBeg, yEnd, (int)state, eventTime).GetHashCode();
         }
     }
 
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class GestureInfoEventArgs : EventArgs
+    {
+        public GestureInfoType GestureInfo { get; internal set; }
+        public int Consumed { get; set; }
+    }
+
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class GetDescriptionEventArgs : EventArgs
+    {
+        public string Description { get; internal set; }
+    }
+
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class GetNameEventArgs : EventArgs
+    {
+        public string Description { get; internal set; }
+    }
+
     /// <summary>
     /// View is the base class for all views.
     /// </summary>
@@ -110,13 +154,6 @@ namespace Tizen.NUI.BaseComponents
         private GestureInfoHandlerType gestureInfoCallback;
         private EventHandler<GestureInfoEventArgs> gestureInfoHandler;
 
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public class GestureInfoEventArgs : EventArgs
-        {
-            public GestureInfoType gestureInfo { get; internal set; }
-            public int boolValue { get; set; }
-        }
-
         private void OnGestureInfoEvent(IntPtr data) {
             if (data == IntPtr.Zero)
                 return;
@@ -127,12 +164,12 @@ namespace Tizen.NUI.BaseComponents
 
             var arg = new GestureInfoEventArgs();
 
-            arg.boolValue = AccessibilityDoGestureSignal.GetResult(data);
-            arg.gestureInfo = (GestureInfoType)Marshal.PtrToStructure(data, typeof(GestureInfoType));
+            arg.Consumed = AccessibilityDoGestureSignal.GetResult(data);
+            arg.GestureInfo = (GestureInfoType)Marshal.PtrToStructure(data, typeof(GestureInfoType));
 
             gestureInfoHandler?.Invoke(this, arg);
 
-            AccessibilityDoGestureSignal.SetResult(data, Convert.ToInt32(arg.boolValue));
+            AccessibilityDoGestureSignal.SetResult(data, Convert.ToInt32(arg.Consumed));
         }
 
         // This uses DoGestureInfo signal from C++ API.
@@ -167,18 +204,12 @@ namespace Tizen.NUI.BaseComponents
         private GetDescriptionHandlerType getDescriptionCallback;
         private EventHandler<GetDescriptionEventArgs> getDescriptionHandler;
 
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public class GetDescriptionEventArgs : EventArgs
-        {
-            public string description { get; internal set; }
-        }
-
         private void OnGetDescriptionEvent(IntPtr data) {
             if (data == IntPtr.Zero)
                 return;
 
             var arg = new GetDescriptionEventArgs();
-            arg.description = StringToVoidSignal.ConvertParam1(data);
+            arg.Description = StringToVoidSignal.ConvertParam1(data);
 
             getDescriptionHandler?.Invoke(this, arg);
         }
@@ -215,18 +246,12 @@ namespace Tizen.NUI.BaseComponents
         private GetNameHandlerType getNameCallback;
         private EventHandler<GetNameEventArgs> getNameHandler;
 
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public class GetNameEventArgs : EventArgs
-        {
-            public string description { get; internal set; }
-        }
-
         private void OnGetNameEvent(IntPtr data) {
             if (data == IntPtr.Zero)
                 return;
 
             var arg = new GetNameEventArgs();
-            arg.description = StringToVoidSignal.ConvertParam1(data);
+            arg.Description = StringToVoidSignal.ConvertParam1(data);
 
             getNameHandler?.Invoke(this, arg);
         }