[NUI] fix CA1801 build warnings (#2258)
authorYoungbok Shin <id213sin@gmail.com>
Fri, 20 Nov 2020 06:00:08 +0000 (15:00 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Thu, 26 Nov 2020 08:19:50 +0000 (17:19 +0900)
Fix CA1801 build warnings except auto-generated code by SWIG.

Co-authored-by: Youngbok Shin <youngb.shin@samsung.com>
Co-authored-by: woohyun <woo_hyun0705@naver.com>
17 files changed:
src/Tizen.NUI/src/internal/DaliEnumConstants.cs
src/Tizen.NUI/src/internal/FrameBroker/FrameBrokerBaseErrorFactory.cs
src/Tizen.NUI/src/internal/FrameProvider/FrameProviderErrorFactory.cs
src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs
src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs
src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs
src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs
src/Tizen.NUI/src/internal/XamlBinding/Device.cs
src/Tizen.NUI/src/internal/XamlBinding/StyleSheets/Style.cs
src/Tizen.NUI/src/internal/XamlBinding/TemplateUtilities.cs
src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs
src/Tizen.NUI/src/public/Events/GestureDetectorManager.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs
src/Tizen.NUI/src/public/Rectangle.cs
src/Tizen.NUI/src/public/Xaml/StaticResourceExtension.cs
src/Tizen.NUI/src/public/Xaml/XamlFilePathAttribute.cs
src/Tizen.NUI/src/public/XamlBinding/Element.cs

index ff90351..5c0a7cc 100755 (executable)
@@ -243,8 +243,8 @@ namespace Tizen.NUI
 #if !(NUI_DEBUG_ON)
     internal class tlog
     {
-        internal static void Fatal(string tag, string msg) { }
-        internal static void Error(string tag, string msg) { }
+        internal static void Fatal(string tag, string msg) { _ = tag; _ = msg; }
+        internal static void Error(string tag, string msg) { _ = tag; _ = msg; }
     }
 #endif
 
index d343120..83a1959 100755 (executable)
@@ -26,7 +26,7 @@ namespace Tizen.NUI
 
         internal static Exception GetException(Interop.FrameBroker.ErrorCode err, string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
         {
-            Log.Error(LogTag, memberName + "(" + lineNumber + ") " + message);
+            Log.Error(LogTag, memberName + "@" + filePath + "(" + lineNumber + ") " + message);
             switch (err)
             {
                 case Interop.FrameBroker.ErrorCode.InvalidParameter:
index a7adb1c..26a967f 100755 (executable)
@@ -25,7 +25,7 @@ namespace Tizen.NUI
 
         internal static Exception GetException(Interop.FrameProvider.ErrorCode err, string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
         {
-            Log.Error(LogTag, memberName + "(" + lineNumber + ") " + message);
+            Log.Error(LogTag, memberName + "@" + filePath + "(" + lineNumber + ") " + message);
             switch (err)
             {
                 case Interop.FrameProvider.ErrorCode.InvalidParameter:
index 770fc51..ab01ef6 100755 (executable)
@@ -371,12 +371,12 @@ namespace Tizen.NUI.Xaml
                 return;
 
             //If value is BindingBase, SetBinding
-            if (xpe == null && TrySetBinding(xamlelement, property, localName, value, lineInfo, out xpe))
+            if (xpe == null && TrySetBinding(xamlelement, property, value, lineInfo, out xpe))
                 return;
 
             //Call TrySetProperty first and then TrySetValue to keep the code logic consistent whether it is through xaml or code.
             //If we can assign that value to a normal property, let's do it
-            if (xpe == null && TrySetProperty(xamlelement, localName, value, lineInfo, serviceProvider, context, out xpe))
+            if (xpe == null && TrySetProperty(xamlelement, localName, value, serviceProvider, context, out xpe))
                 return;
 
             //If it's a BindableProberty, SetValue
@@ -407,11 +407,11 @@ namespace Tizen.NUI.Xaml
             var property = GetBindableProperty(bpOwnerType, localName, lineInfo, false);
 
             //If it's a BindableProberty, GetValue
-            if (xpe == null && TryGetValue(xamlElement, property, attached, out value, lineInfo, out xpe, out targetProperty))
+            if (xpe == null && TryGetValue(xamlElement, property, out value, out xpe, out targetProperty))
                 return value;
 
             //If it's a normal property, get it
-            if (xpe == null && TryGetProperty(xamlElement, localName, out value, lineInfo, context, out xpe, out targetProperty))
+            if (xpe == null && TryGetProperty(xamlElement, localName, out value, context, out xpe, out targetProperty))
                 return value;
 
             xpe = xpe ?? new XamlParseException($"Property {localName} is not found or does not have an accessible getter", lineInfo);
@@ -477,7 +477,7 @@ namespace Tizen.NUI.Xaml
             return true;
         }
 
-        static bool TrySetBinding(object element, BindableProperty property, string localName, object value, IXmlLineInfo lineInfo, out Exception exception)
+        static bool TrySetBinding(object element, BindableProperty property, object value, IXmlLineInfo lineInfo, out Exception exception)
         {
             exception = null;
 
@@ -543,7 +543,7 @@ namespace Tizen.NUI.Xaml
             return false;
         }
 
-        static bool TryGetValue(object element, BindableProperty property, bool attached, out object value, IXmlLineInfo lineInfo, out Exception exception, out object targetProperty)
+        static bool TryGetValue(object element, BindableProperty property, out object value, out Exception exception, out object targetProperty)
         {
             exception = null;
             value = null;
@@ -561,7 +561,7 @@ namespace Tizen.NUI.Xaml
             return true;
         }
 
-        static bool TrySetProperty(object element, string localName, object value, IXmlLineInfo lineInfo, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
+        static bool TrySetProperty(object element, string localName, object value, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
         {
             exception = null;
 
@@ -629,7 +629,7 @@ namespace Tizen.NUI.Xaml
             }
         }
 
-        static bool TryGetProperty(object element, string localName, out object value, IXmlLineInfo lineInfo, HydrationContext context, out Exception exception, out object targetProperty)
+        static bool TryGetProperty(object element, string localName, out object value, HydrationContext context, out Exception exception, out object targetProperty)
         {
             exception = null;
             value = null;
index b5f562f..c9d8c68 100755 (executable)
@@ -52,7 +52,7 @@ namespace Tizen.NUI.Xaml
 
             var markupString = markupnode.MarkupString;
             var node =
-                ParseExpression(ref markupString, markupnode.NamespaceResolver, markupnode, markupnode, parentNode) as IElementNode;
+                ParseExpression(ref markupString, markupnode.NamespaceResolver, markupnode) as IElementNode;
             if (node != null)
             {
                 ((IElementNode)parentNode).Properties[propertyName] = node;
@@ -72,8 +72,7 @@ namespace Tizen.NUI.Xaml
         {
         }
 
-        INode ParseExpression(ref string expression, IXmlNamespaceResolver nsResolver, IXmlLineInfo xmlLineInfo, INode node,
-            INode parentNode)
+        INode ParseExpression(ref string expression, IXmlNamespaceResolver nsResolver, INode node)
         {
             if (expression.StartsWith("{}", StringComparison.Ordinal))
                 return new ValueNode(expression.Substring(2), null);
index ffccf1d..6ad4e8c 100755 (executable)
@@ -33,7 +33,7 @@ namespace Tizen.NUI.Xaml
 
         public void Visit(ElementNode node, INode parentNode)
         {
-            var ns = parentNode == null || IsDataTemplate(node, parentNode) || IsStyle(node, parentNode) || IsVisualStateGroupList(node)
+            var ns = parentNode == null || IsDataTemplate(node, parentNode) || IsStyle(parentNode) || IsVisualStateGroupList(node)
                 ? new NameScope()
                 : scopes[parentNode];
             node.Namescope = ns;
@@ -62,7 +62,7 @@ namespace Tizen.NUI.Xaml
             return false;
         }
 
-        static bool IsStyle(INode node, INode parentNode)
+        static bool IsStyle(INode parentNode)
         {
             var pnode = parentNode as ElementNode;
             return pnode != null && pnode.XmlType.Name == "Style";
index e92af4e..e6df866 100755 (executable)
@@ -164,7 +164,7 @@ namespace Tizen.NUI.Binding
                 else
                     value = property.DefaultValue;
 
-                if (!TryConvert(part, ref value, property.ReturnType, true))
+                if (!TryConvert(ref value, property.ReturnType, true))
                 {
                     Console.WriteLine("Binding", "{0} can not be converted to type '{1}'", value, property.ReturnType);
                     return;
@@ -176,7 +176,7 @@ namespace Tizen.NUI.Binding
             {
                 object value = Binding.GetTargetValue(target.GetValue(property), part.SetterType);
 
-                if (!TryConvert(part, ref value, part.SetterType, false))
+                if (!TryConvert(ref value, part.SetterType, false))
                 {
                     Console.WriteLine("Binding", "{0} can not be converted to type '{1}'", value, part.SetterType);
                     return;
@@ -422,7 +422,7 @@ namespace Tizen.NUI.Binding
         }
         static Type[] DecimalTypes = new[] { typeof(float), typeof(decimal), typeof(double) };
 
-        bool TryConvert(BindingExpressionPart part, ref object value, Type convertTo, bool toTarget)
+        bool TryConvert(ref object value, Type convertTo, bool toTarget)
         {
             if (value == null)
                 return true;
index 10c2808..8dc1cec 100755 (executable)
@@ -111,10 +111,10 @@ namespace Tizen.NUI.Binding
             return iOS;
         }
 
-        public static void OpenUri(Uri uri)
-        {
-            // PlatformServices?.OpenUriAction(uri);
-        }
+        // public static void OpenUri(Uri uri)
+        // {
+        //     PlatformServices?.OpenUriAction(uri);
+        // }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static Assembly[] GetAssemblies()
index 1a9b353..f627240 100755 (executable)
@@ -94,6 +94,8 @@ namespace Tizen.NUI.StyleSheets
                                                     ?? property.DeclaringType.GetRuntimeMethod("Get" + property.PropertyName, new[] { typeof(BindableObject) }) as MemberInfo;
             var serviceProvider = new StyleSheetServiceProvider(target, property);
             // return value.ConvertTo(property.ReturnType, minforetriever, serviceProvider);
+            // Unused parameter
+            _ = value;
             return null;
         }
 
index 75c653b..c35999b 100755 (executable)
@@ -44,12 +44,11 @@ namespace Tizen.NUI.Binding
             return tcs.Task;
         }
 
-        public static void OnContentChanged(BindableObject bindable, object oldValue, object newValue)
-        {
-        }
-
         public static void OnControlTemplateChanged(BindableObject bindable, object oldValue, object newValue)
         {
+            // Unused parameter
+            _ = newValue;
+
             var self = (IControlTemplated)bindable;
 
             // First make sure any old ContentPresenters are no longer bound up. This MUST be
index 9e09a23..aec6555 100755 (executable)
@@ -62,6 +62,9 @@ namespace Tizen.NUI.BaseComponents
 
         private void SendViewAddedEventToWindow(IntPtr data)
         {
+            // Unused parameter
+            _ = data;
+
             NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
         }
 
index 55a85cd..99dec49 100755 (executable)
@@ -150,6 +150,9 @@ namespace Tizen.NUI.Events
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void FeedTouchEvent(object sender, View.TouchEventArgs e, object userData)
         {
+            // Unused parameter
+            _ = sender;
+
             mUserData = userData;
             mTapGestureDetector.Detected -= InternalOnTap;
             mLongGestureDetector.Detected -= InternalOnLongPress;
index 4172c3a..0a45cab 100755 (executable)
@@ -642,6 +642,10 @@ namespace Tizen.NUI
         }
         internal static void OnChildPropertyChanged(Binding.BindableObject bindable, object oldValue, object newValue)
         {
+            // Unused parameters
+            _ = oldValue;
+            _ = newValue;
+
             View view = bindable as View;
             view?.Layout?.RequestLayout();
         }
index 1080f8a..8e72321 100755 (executable)
@@ -65,6 +65,7 @@ namespace Tizen.NUI
 
         internal Rectangle(RectangleChangedCallback cb) : this()
         {
+            callback = cb;
         }
 
         internal Rectangle(RectangleChangedCallback cb, Rectangle other) : this(cb, other.x, other.y, other.width, other.height)
index 0a97e21..0a5fbcc 100755 (executable)
@@ -104,7 +104,7 @@ namespace Tizen.NUI.Xaml
         {
             object resource = null;
             if (Application.Current == null || !((IResourcesProvider)Application.Current).IsResourcesCreated || !Application.Current.XamlResources.TryGetValue(Key, out resource))
-                throw new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
+                throw new XamlParseException($"StaticResource not found for key {key}", xmlLineInfo);
             return resource;
         }
     }
index 1483402..ebb9496 100755 (executable)
@@ -13,6 +13,8 @@ namespace Tizen.NUI.Xaml
         [EditorBrowsable(EditorBrowsableState.Never)]
         public XamlFilePathAttribute([CallerFilePath] string filePath = "")
         {
+            // Unused parameter
+            _ = filePath;
         }
     }
 }
\ No newline at end of file
index 30c2aca..2aa496c 100755 (executable)
@@ -492,10 +492,6 @@ namespace Tizen.NUI.Binding
 
         internal event EventHandler ParentSet;
 
-        internal static void SetFlowDirectionFromParent(Element child)
-        {
-        }
-
         internal virtual void SetChildInheritedBindingContext(Element child, object context)
         {
             SetInheritedBindingContext(child, context);