diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index ffddc9a0a..a5fcf2fd4 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -32,6 +32,7 @@ using System.Linq; namespace ArchiSteamFarm { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] + [SuppressMessage("ReSharper", "ConvertToConstant.Local")] [SuppressMessage("ReSharper", "ConvertToConstant.Global")] internal sealed class BotConfig { internal enum EFarmingOrder : byte { @@ -58,10 +59,6 @@ namespace ArchiSteamFarm { [JsonProperty] internal string SteamPassword { get; set; } - [JsonProperty(Required = Required.DisallowNull)] - [SuppressMessage("ReSharper", "ConvertToConstant.Local")] - private readonly CryptoHelper.ECryptoMethod PasswordFormat = CryptoHelper.ECryptoMethod.PlainText; - [JsonProperty] internal string SteamParentalPIN { get; set; } = "0"; @@ -128,6 +125,9 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal readonly HashSet GamesPlayedWhileIdle = new HashSet(); + [JsonProperty(Required = Required.DisallowNull)] + private readonly CryptoHelper.ECryptoMethod PasswordFormat = CryptoHelper.ECryptoMethod.PlainText; + internal static BotConfig Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { Logging.LogNullError(nameof(filePath)); diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs index 49273817b..1cee3982e 100644 --- a/ArchiSteamFarm/GlobalDatabase.cs +++ b/ArchiSteamFarm/GlobalDatabase.cs @@ -25,12 +25,11 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Threading; namespace ArchiSteamFarm { - internal sealed class GlobalDatabase { + internal sealed class GlobalDatabase : IDisposable { private static readonly JsonSerializerSettings CustomSerializerSettings = new JsonSerializerSettings { Converters = new List(2) { new IPAddressConverter(), @@ -56,7 +55,6 @@ namespace ArchiSteamFarm { } [JsonProperty(Required = Required.DisallowNull)] - [SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")] internal readonly InMemoryServerListProvider ServerListProvider = new InMemoryServerListProvider(); private readonly object FileLock = new object(); @@ -91,7 +89,7 @@ namespace ArchiSteamFarm { return globalDatabase; } - private void OnServerListUpdated(object sender, EventArgs e) => Save(); + public void Dispose() => ServerListProvider.Dispose(); // This constructor is used when creating new database private GlobalDatabase(string filePath) : this() { @@ -104,11 +102,12 @@ namespace ArchiSteamFarm { } // This constructor is used only by deserializer - [SuppressMessage("ReSharper", "UnusedMember.Local")] private GlobalDatabase() { ServerListProvider.ServerListUpdated += OnServerListUpdated; } + private void OnServerListUpdated(object sender, EventArgs e) => Save(); + private void Save() { string json = JsonConvert.SerializeObject(this, CustomSerializerSettings); if (string.IsNullOrEmpty(json)) { diff --git a/ArchiSteamFarm/InMemoryServerListProvider.cs b/ArchiSteamFarm/InMemoryServerListProvider.cs index 9d1965126..65905f866 100644 --- a/ArchiSteamFarm/InMemoryServerListProvider.cs +++ b/ArchiSteamFarm/InMemoryServerListProvider.cs @@ -30,7 +30,7 @@ using Newtonsoft.Json; using SteamKit2.Discovery; namespace ArchiSteamFarm { - internal sealed class InMemoryServerListProvider : IServerListProvider { + internal sealed class InMemoryServerListProvider : IDisposable, IServerListProvider { [JsonProperty(Required = Required.DisallowNull)] private readonly ConcurrentHashSet Servers = new ConcurrentHashSet(); @@ -53,5 +53,7 @@ namespace ArchiSteamFarm { ServerListUpdated(this, EventArgs.Empty); return Task.Delay(0); } + + public void Dispose() => Servers.Dispose(); } } diff --git a/ArchiSteamFarm/JSON/GitHub.cs b/ArchiSteamFarm/JSON/GitHub.cs index 25b595ba0..f18c63657 100644 --- a/ArchiSteamFarm/JSON/GitHub.cs +++ b/ArchiSteamFarm/JSON/GitHub.cs @@ -29,7 +29,6 @@ using Newtonsoft.Json; namespace ArchiSteamFarm.JSON { internal static class GitHub { [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] - [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")] internal sealed class ReleaseResponse { #pragma warning disable 649 internal sealed class Asset { diff --git a/ArchiSteamFarm/JSON/Steam.cs b/ArchiSteamFarm/JSON/Steam.cs index c78c934ab..e760446b6 100644 --- a/ArchiSteamFarm/JSON/Steam.cs +++ b/ArchiSteamFarm/JSON/Steam.cs @@ -343,7 +343,6 @@ namespace ArchiSteamFarm.JSON { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] - [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")] internal sealed class ConfirmationResponse { // Deserialized from JSON #pragma warning disable 649 [JsonProperty(PropertyName = "success", Required = Required.Always)] @@ -355,7 +354,6 @@ namespace ArchiSteamFarm.JSON { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] - [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")] internal sealed class ConfirmationDetails { // Deserialized from JSON internal enum EType : byte { Unknown, diff --git a/ArchiSteamFarm/MobileAuthenticator.cs b/ArchiSteamFarm/MobileAuthenticator.cs index 442058a82..c90b5212b 100644 --- a/ArchiSteamFarm/MobileAuthenticator.cs +++ b/ArchiSteamFarm/MobileAuthenticator.cs @@ -81,9 +81,7 @@ namespace ArchiSteamFarm { private Bot Bot; - private MobileAuthenticator() { - - } + private MobileAuthenticator() { } internal void Init(Bot bot) { if (bot == null) { diff --git a/ArchiSteamFarm/Utilities.cs b/ArchiSteamFarm/Utilities.cs index e55c272d0..84424008e 100644 --- a/ArchiSteamFarm/Utilities.cs +++ b/ArchiSteamFarm/Utilities.cs @@ -26,10 +26,12 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net; +using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace ArchiSteamFarm { internal static class Utilities { + [MethodImpl(MethodImplOptions.AggressiveInlining)] [SuppressMessage("ReSharper", "UnusedParameter.Global")] internal static void Forget(this Task task) { }