From 1db29193bc5d66fe0e640859a24234aca537e881 Mon Sep 17 00:00:00 2001 From: Youngbok Shin Date: Fri, 20 Nov 2020 15:00:08 +0900 Subject: [PATCH] [NUI] fix CA1801 build warnings (#2258) Fix CA1801 build warnings except auto-generated code by SWIG. Co-authored-by: Youngbok Shin Co-authored-by: woohyun --- src/Tizen.NUI/src/internal/DaliEnumConstants.cs | 4 ++-- .../internal/FrameBroker/FrameBrokerBaseErrorFactory.cs | 2 +- .../internal/FrameProvider/FrameProviderErrorFactory.cs | 2 +- .../src/internal/Xaml/ApplyPropertiesVisitor.cs | 16 ++++++++-------- src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs | 5 ++--- src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs | 4 ++-- .../src/internal/XamlBinding/BindingExpression.cs | 6 +++--- src/Tizen.NUI/src/internal/XamlBinding/Device.cs | 8 ++++---- .../src/internal/XamlBinding/StyleSheets/Style.cs | 2 ++ .../src/internal/XamlBinding/TemplateUtilities.cs | 7 +++---- src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs | 3 +++ .../src/public/Events/GestureDetectorManager.cs | 3 +++ src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs | 4 ++++ src/Tizen.NUI/src/public/Rectangle.cs | 1 + src/Tizen.NUI/src/public/Xaml/StaticResourceExtension.cs | 2 +- src/Tizen.NUI/src/public/Xaml/XamlFilePathAttribute.cs | 2 ++ src/Tizen.NUI/src/public/XamlBinding/Element.cs | 4 ---- 17 files changed, 42 insertions(+), 33 deletions(-) diff --git a/src/Tizen.NUI/src/internal/DaliEnumConstants.cs b/src/Tizen.NUI/src/internal/DaliEnumConstants.cs index ff90351..5c0a7cc 100755 --- a/src/Tizen.NUI/src/internal/DaliEnumConstants.cs +++ b/src/Tizen.NUI/src/internal/DaliEnumConstants.cs @@ -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 diff --git a/src/Tizen.NUI/src/internal/FrameBroker/FrameBrokerBaseErrorFactory.cs b/src/Tizen.NUI/src/internal/FrameBroker/FrameBrokerBaseErrorFactory.cs index d343120..83a1959 100755 --- a/src/Tizen.NUI/src/internal/FrameBroker/FrameBrokerBaseErrorFactory.cs +++ b/src/Tizen.NUI/src/internal/FrameBroker/FrameBrokerBaseErrorFactory.cs @@ -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: diff --git a/src/Tizen.NUI/src/internal/FrameProvider/FrameProviderErrorFactory.cs b/src/Tizen.NUI/src/internal/FrameProvider/FrameProviderErrorFactory.cs index a7adb1c..26a967f 100755 --- a/src/Tizen.NUI/src/internal/FrameProvider/FrameProviderErrorFactory.cs +++ b/src/Tizen.NUI/src/internal/FrameProvider/FrameProviderErrorFactory.cs @@ -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: diff --git a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs index 770fc51..ab01ef6 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs @@ -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; diff --git a/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs index b5f562f..c9d8c68 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs @@ -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); diff --git a/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs index ffccf1d..6ad4e8c 100755 --- a/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs @@ -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"; diff --git a/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs b/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs index e92af4e..e6df866 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs @@ -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; diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Device.cs b/src/Tizen.NUI/src/internal/XamlBinding/Device.cs index 10c2808..8dc1cec 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Device.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Device.cs @@ -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() diff --git a/src/Tizen.NUI/src/internal/XamlBinding/StyleSheets/Style.cs b/src/Tizen.NUI/src/internal/XamlBinding/StyleSheets/Style.cs index 1a9b353..f627240 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/StyleSheets/Style.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/StyleSheets/Style.cs @@ -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; } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/TemplateUtilities.cs b/src/Tizen.NUI/src/internal/XamlBinding/TemplateUtilities.cs index 75c653b..c35999b 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/TemplateUtilities.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/TemplateUtilities.cs @@ -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 diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index 9e09a23..aec6555 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -62,6 +62,9 @@ namespace Tizen.NUI.BaseComponents private void SendViewAddedEventToWindow(IntPtr data) { + // Unused parameter + _ = data; + NUIApplication.GetDefaultWindow()?.SendViewAdded(this); } diff --git a/src/Tizen.NUI/src/public/Events/GestureDetectorManager.cs b/src/Tizen.NUI/src/public/Events/GestureDetectorManager.cs index 55a85cd..99dec49 100755 --- a/src/Tizen.NUI/src/public/Events/GestureDetectorManager.cs +++ b/src/Tizen.NUI/src/public/Events/GestureDetectorManager.cs @@ -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; diff --git a/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs b/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs index 4172c3a..0a45cab 100755 --- a/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs +++ b/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs @@ -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(); } diff --git a/src/Tizen.NUI/src/public/Rectangle.cs b/src/Tizen.NUI/src/public/Rectangle.cs index 1080f8a..8e72321 100755 --- a/src/Tizen.NUI/src/public/Rectangle.cs +++ b/src/Tizen.NUI/src/public/Rectangle.cs @@ -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) diff --git a/src/Tizen.NUI/src/public/Xaml/StaticResourceExtension.cs b/src/Tizen.NUI/src/public/Xaml/StaticResourceExtension.cs index 0a97e21..0a5fbcc 100755 --- a/src/Tizen.NUI/src/public/Xaml/StaticResourceExtension.cs +++ b/src/Tizen.NUI/src/public/Xaml/StaticResourceExtension.cs @@ -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; } } diff --git a/src/Tizen.NUI/src/public/Xaml/XamlFilePathAttribute.cs b/src/Tizen.NUI/src/public/Xaml/XamlFilePathAttribute.cs index 1483402..ebb9496 100755 --- a/src/Tizen.NUI/src/public/Xaml/XamlFilePathAttribute.cs +++ b/src/Tizen.NUI/src/public/Xaml/XamlFilePathAttribute.cs @@ -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 diff --git a/src/Tizen.NUI/src/public/XamlBinding/Element.cs b/src/Tizen.NUI/src/public/XamlBinding/Element.cs index 30c2aca..2aa496c 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/Element.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/Element.cs @@ -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); -- 2.7.4