From a8e3bd6473b30fc4ed17357397342e4a0d662482 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 6 May 2021 21:00:21 +0200 Subject: [PATCH] Cleanup round --- ArchiSteamFarm/BotConfig.cs | 19 +++++++------------ ArchiSteamFarm/IPC/Startup.cs | 3 --- ArchiSteamFarm/OS.cs | 2 +- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index 10522a947..f63160104 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -19,12 +19,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -using File = System.IO.File; -#else -using System.IO; -#endif using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -35,6 +29,7 @@ using System.Threading; using System.Threading.Tasks; using ArchiSteamFarm.Json; using ArchiSteamFarm.Localization; +using ArchiSteamFarm.RuntimeCompatibility; using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -341,12 +336,12 @@ namespace ArchiSteamFarm { await WriteSemaphore.WaitAsync().ConfigureAwait(false); try { - await RuntimeCompatibility.File.WriteAllTextAsync(newFilePath, json).ConfigureAwait(false); + await File.WriteAllTextAsync(newFilePath, json).ConfigureAwait(false); - if (File.Exists(filePath)) { - File.Replace(newFilePath, filePath, null); + if (System.IO.File.Exists(filePath)) { + System.IO.File.Replace(newFilePath, filePath, null); } else { - File.Move(newFilePath, filePath); + System.IO.File.Move(newFilePath, filePath); } } catch (Exception e) { ASF.ArchiLogger.LogGenericException(e); @@ -430,14 +425,14 @@ namespace ArchiSteamFarm { throw new ArgumentNullException(nameof(filePath)); } - if (!File.Exists(filePath)) { + if (!System.IO.File.Exists(filePath)) { return null; } BotConfig? botConfig; try { - string json = await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false); + string json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false); if (string.IsNullOrEmpty(json)) { ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json))); diff --git a/ArchiSteamFarm/IPC/Startup.cs b/ArchiSteamFarm/IPC/Startup.cs index 6620c5cca..27621f983 100644 --- a/ArchiSteamFarm/IPC/Startup.cs +++ b/ArchiSteamFarm/IPC/Startup.cs @@ -265,7 +265,6 @@ namespace ArchiSteamFarm.IPC { mvc.SetCompatibilityVersion(CompatibilityVersion.Latest); #if NETFRAMEWORK - // Add standard formatters mvc.AddFormatterMappings(); @@ -274,7 +273,6 @@ namespace ArchiSteamFarm.IPC { #endif #if NETFRAMEWORK - // Add JSON formatters that will be used as default ones if no specific formatters are asked for mvc.AddJsonFormatters(); @@ -291,7 +289,6 @@ namespace ArchiSteamFarm.IPC { } #if NETFRAMEWORK - // .NET Framework serializes Version as object by default, serialize it as string just like .NET Core options.SerializerSettings.Converters.Add(new VersionConverter()); #endif diff --git a/ArchiSteamFarm/OS.cs b/ArchiSteamFarm/OS.cs index 96298fe3e..e79a65954 100644 --- a/ArchiSteamFarm/OS.cs +++ b/ArchiSteamFarm/OS.cs @@ -169,7 +169,6 @@ namespace ArchiSteamFarm { internal static bool VerifyEnvironment() { #if NETFRAMEWORK - // This is .NET Framework build, we support that one only on mono for platforms not supported by .NET Core // We're not going to analyze source builds, as we don't know what changes the author has made, assume they have a point @@ -193,6 +192,7 @@ namespace ArchiSteamFarm { _ => false }; #else + // This is .NET Core build, we support all scenarios return true; #endif