From 74fd861b8728a4eec1a2e7a484a6f629d6d9e1b7 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Wed, 10 Jul 2019 16:35:18 +0200 Subject: [PATCH] R# code review --- .../ExamplePlugin.cs | 1 + ArchiSteamFarm/Collections/ConcurrentHashSet.cs | 3 +-- ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs | 8 ++++---- ArchiSteamFarm/NLog/Logging.cs | 6 ++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs index 751563f8a..8e725fe44 100644 --- a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs +++ b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs @@ -35,6 +35,7 @@ namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin { // Your plugin class should inherit the plugin interfaces it wants to handle // If you do not want to handle a particular action (e.g. OnBotMessage that is offered in IBotMessage), it's the best idea to not inherit it at all // This will keep your code compact, efficient and less dependent. You can always add additional interfaces when you'll need them, this example project will inherit quite a bit of them to show you potential usage + // ReSharper disable once UnusedMember.Global - this is example plugin class that isn't used in our main code internal sealed class ExamplePlugin : IASF, IBot, IBotCommand, IBotConnection, IBotFriendRequest, IBotMessage, IBotModules, IBotTradeOffer { // This is used for identification purposes, typically you want to use a friendly name of your plugin here, such as the name of your main class // Please note that this property can have direct dependencies only on structures that were initialized by the constructor, as it's possible to be called before OnLoaded() takes place diff --git a/ArchiSteamFarm/Collections/ConcurrentHashSet.cs b/ArchiSteamFarm/Collections/ConcurrentHashSet.cs index 7b92e4a50..9db493ead 100644 --- a/ArchiSteamFarm/Collections/ConcurrentHashSet.cs +++ b/ArchiSteamFarm/Collections/ConcurrentHashSet.cs @@ -127,8 +127,7 @@ namespace ArchiSteamFarm.Collections { } } - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - void ICollection.Add(T item) => Add(item); + void ICollection.Add([NotNull] T item) => Add(item); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs b/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs index 6386e1080..3a6e57667 100644 --- a/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs +++ b/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs @@ -22,7 +22,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Threading; using JetBrains.Annotations; @@ -75,7 +74,7 @@ namespace ArchiSteamFarm.Collections { } } - public void CopyTo(T[] array, int arrayIndex) { + public void CopyTo([NotNull] T[] array, int arrayIndex) { CollectionSemaphore.Wait(); try { @@ -97,6 +96,7 @@ namespace ArchiSteamFarm.Collections { } } + [NotNull] public IEnumerator GetEnumerator() => new ConcurrentEnumerator(BackingCollection, CollectionSemaphore); public void IntersectWith(IEnumerable other) { @@ -199,9 +199,9 @@ namespace ArchiSteamFarm.Collections { } } - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - void ICollection.Add(T item) => Add(item); + void ICollection.Add([NotNull] T item) => Add(item); + [NotNull] IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); internal void ReplaceWith([NotNull] IEnumerable other) { diff --git a/ArchiSteamFarm/NLog/Logging.cs b/ArchiSteamFarm/NLog/Logging.cs index 7a97ccc51..56c49d5eb 100644 --- a/ArchiSteamFarm/NLog/Logging.cs +++ b/ArchiSteamFarm/NLog/Logging.cs @@ -375,10 +375,8 @@ namespace ArchiSteamFarm.NLog { bool reconfigure = false; - foreach (LoggingRule consoleLoggingRule in ConsoleLoggingRules) { - if (LogManager.Configuration.LoggingRules.Remove(consoleLoggingRule)) { - reconfigure = true; - } + foreach (LoggingRule _ in ConsoleLoggingRules.Where(consoleLoggingRule => LogManager.Configuration.LoggingRules.Remove(consoleLoggingRule))) { + reconfigure = true; } if (reconfigure) {