From 148ad19fae91419987ca1d6dc5043196dd4e0873 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Fri, 24 Feb 2023 20:51:23 +0600 Subject: [PATCH] warnings fixed --- DTLib.Dtsod/DtsodV21.cs | 7 ++++--- DTLib.Dtsod/DtsodV23.cs | 9 +++++++-- DTLib.Logging/DependencyInjection/LoggerService.cs | 4 +--- DTLib.Logging/DependencyInjection/MyLoggerWrapper.cs | 1 + DTLib.Logging/LogFormats/DefaultLogFormat.cs | 2 +- DTLib/Extensions/StringConverter.cs | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/DTLib.Dtsod/DtsodV21.cs b/DTLib.Dtsod/DtsodV21.cs index 5541c38..569293c 100644 --- a/DTLib.Dtsod/DtsodV21.cs +++ b/DTLib.Dtsod/DtsodV21.cs @@ -261,7 +261,7 @@ public class DtsodV21 : Dictionary, IDtsod break; default: throw new Exception($"Dtsod.Parse.ReadValue() error: value= wrong type "); - }; + } } // short; long; int else @@ -278,7 +278,7 @@ public class DtsodV21 : Dictionary, IDtsod break; } break; - }; + } } StringBuilder defaultValueBuilder = new(); @@ -303,7 +303,8 @@ public class DtsodV21 : Dictionary, IDtsod case ValueType.Default: ParseValueToRightType(defaultValueBuilder.ToString()); break; - }; + } + return value; case '[': value = ReadList(); diff --git a/DTLib.Dtsod/DtsodV23.cs b/DTLib.Dtsod/DtsodV23.cs index 481552f..40f4f50 100644 --- a/DTLib.Dtsod/DtsodV23.cs +++ b/DTLib.Dtsod/DtsodV23.cs @@ -202,10 +202,15 @@ public class DtsodV23 : DtsodDict, IDtsod : throw new Exception("can't parse value:" + value_str); default: if (value_str.Contains('.')) - return (object)(value_str.ToDouble()); + // ReSharper disable once RedundantCast + return (object)value_str.ToDouble(); else { - try { return (object)(value_str.ToInt()); } + try + { + // ReSharper disable once RedundantCast + return (object)value_str.ToInt(); + } catch (FormatException) { Log("r", $"can't parse value: {value_str}"); diff --git a/DTLib.Logging/DependencyInjection/LoggerService.cs b/DTLib.Logging/DependencyInjection/LoggerService.cs index c544609..bbe9669 100644 --- a/DTLib.Logging/DependencyInjection/LoggerService.cs +++ b/DTLib.Logging/DependencyInjection/LoggerService.cs @@ -4,12 +4,10 @@ namespace DTLib.Logging.DependencyInjection; public class LoggerService : ServiceDescriptor { - DTLib.Logging.New.ILogger _logger; - + // ReSharper disable once RedundantNameQualifier public LoggerService(DTLib.Logging.New.ILogger logger) : base( typeof(Microsoft.Extensions.Logging.ILogger), new MyLoggerWrapper(logger)) { - _logger = logger; } } \ No newline at end of file diff --git a/DTLib.Logging/DependencyInjection/MyLoggerWrapper.cs b/DTLib.Logging/DependencyInjection/MyLoggerWrapper.cs index 98bbbef..885b028 100644 --- a/DTLib.Logging/DependencyInjection/MyLoggerWrapper.cs +++ b/DTLib.Logging/DependencyInjection/MyLoggerWrapper.cs @@ -1,5 +1,6 @@ using DTLib.Logging.New; using Microsoft.Extensions.Logging; +// ReSharper disable RedundantNameQualifier namespace DTLib.Logging.DependencyInjection; diff --git a/DTLib.Logging/LogFormats/DefaultLogFormat.cs b/DTLib.Logging/LogFormats/DefaultLogFormat.cs index a51344f..586d341 100644 --- a/DTLib.Logging/LogFormats/DefaultLogFormat.cs +++ b/DTLib.Logging/LogFormats/DefaultLogFormat.cs @@ -27,7 +27,7 @@ public class DefaultLogFormat : ILogFormat sb.Append('[').Append(severity.ToString()).Append(']'); if (sb.Length != 0) sb.Append(": "); - sb.Append(message.ToString()); + sb.Append(message); sb.Append('\n'); return sb.ToString(); } diff --git a/DTLib/Extensions/StringConverter.cs b/DTLib/Extensions/StringConverter.cs index 898d437..f9fc8ca 100644 --- a/DTLib/Extensions/StringConverter.cs +++ b/DTLib/Extensions/StringConverter.cs @@ -162,7 +162,7 @@ public static class StringConverter public static List SplitToList(this string s, int length) { List parts = new(); - int max = (int)(s.Length / length); + int max = s.Length / length; for (int i = 0; i < max; i++) parts.Add(s.Substring(i * length, length)); if (max * length != s.Length) parts.Add(s.Substring(max * length, s.Length - max * length));