diff --git a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs index 7e8f4fca9..84d1b7a62 100644 --- a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs +++ b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ExamplePlugin.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Generic; using System.Composition; @@ -30,10 +33,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SteamKit2; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin { // In order for your plugin to work, it must export generic ASF's IPlugin interface [Export(typeof(IPlugin))] diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs index 3dddd7acd..ca60e1b27 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -36,10 +39,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SteamKit2; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { [Export(typeof(IPlugin))] internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotSteamClient, ISteamPICSChanges { diff --git a/ArchiSteamFarm.Tests/Bot.cs b/ArchiSteamFarm.Tests/Bot.cs index 0f98b5f41..815aefca9 100644 --- a/ArchiSteamFarm.Tests/Bot.cs +++ b/ArchiSteamFarm.Tests/Bot.cs @@ -19,16 +19,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Generic; using System.Linq; using ArchiSteamFarm.Json; using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm.Tests { [TestClass] public sealed class Bot { diff --git a/ArchiSteamFarm/Actions.cs b/ArchiSteamFarm/Actions.cs index af5b076d5..3402a125e 100644 --- a/ArchiSteamFarm/Actions.cs +++ b/ArchiSteamFarm/Actions.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Generic; using System.ComponentModel; @@ -36,11 +39,6 @@ using ArchiSteamFarm.Web; using JetBrains.Annotations; using SteamKit2; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; - -#endif - namespace ArchiSteamFarm { public sealed class Actions : IAsyncDisposable { private static readonly SemaphoreSlim GiftCardsSemaphore = new(1, 1); diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 4e9a4264c..9f503d72d 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -19,6 +19,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +using File = System.IO.File; +using Path = System.IO.Path; +#endif using System; using System.Collections; using System.Collections.Concurrent; @@ -47,13 +52,6 @@ using Newtonsoft.Json; using SteamKit2; using SteamKit2.Internal; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; - -using File = System.IO.File; -using Path = System.IO.Path; -#endif - namespace ArchiSteamFarm { public sealed class Bot : IAsyncDisposable { internal const ushort CallbackSleep = 500; // In milliseconds diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index ffb13e0b8..10522a947 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -21,7 +21,6 @@ #if NETFRAMEWORK using ArchiSteamFarm.RuntimeCompatibility; - using File = System.IO.File; #else using System.IO; diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 21f8d3570..86ac79bce 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -37,10 +40,6 @@ using JetBrains.Annotations; using Newtonsoft.Json; using SteamKit2; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm { public sealed class CardsFarmer : IAsyncDisposable { internal const byte DaysForRefund = 14; // In how many days since payment we're allowed to refund diff --git a/ArchiSteamFarm/Game.cs b/ArchiSteamFarm/Game.cs index 9022998c9..8115e6fb4 100644 --- a/ArchiSteamFarm/Game.cs +++ b/ArchiSteamFarm/Game.cs @@ -19,9 +19,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode; +#endif using System; using Newtonsoft.Json; -using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode; namespace ArchiSteamFarm { public sealed class Game : IEquatable { diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs index a2c8f8e11..0000df6f6 100644 --- a/ArchiSteamFarm/GlobalDatabase.cs +++ b/ArchiSteamFarm/GlobalDatabase.cs @@ -19,6 +19,12 @@ // 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.Concurrent; using System.Collections.Generic; @@ -33,13 +39,6 @@ using ArchiSteamFarm.SteamKit2; using JetBrains.Annotations; using Newtonsoft.Json; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -using File = System.IO.File; -#else -using System.IO; -#endif - namespace ArchiSteamFarm { public sealed class GlobalDatabase : SerializableFile { [JsonIgnore] diff --git a/ArchiSteamFarm/Helpers/SerializableFile.cs b/ArchiSteamFarm/Helpers/SerializableFile.cs index 52390014c..2f33f3563 100644 --- a/ArchiSteamFarm/Helpers/SerializableFile.cs +++ b/ArchiSteamFarm/Helpers/SerializableFile.cs @@ -20,9 +20,9 @@ // limitations under the License. using System; -using System.IO; using System.Threading; using System.Threading.Tasks; +using ArchiSteamFarm.RuntimeCompatibility; using Newtonsoft.Json; namespace ArchiSteamFarm.Helpers { @@ -79,12 +79,12 @@ namespace ArchiSteamFarm.Helpers { string newFilePath = FilePath + ".new"; // We always want to write entire content to temporary file first, in order to never load corrupted data, also when target file doesn't exist - 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); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs index 22455ca10..07741ef0a 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -33,10 +36,6 @@ using ArchiSteamFarm.Localization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm.IPC.Controllers.Api { [Route("Api/Bot")] public sealed class BotController : ArchiController { diff --git a/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs b/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs index 0033f1116..f5463f152 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -36,10 +39,6 @@ using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm.IPC.Controllers.Api { [Route("Api/NLog")] public sealed class NLogController : ArchiController { diff --git a/ArchiSteamFarm/IPC/Startup.cs b/ArchiSteamFarm/IPC/Startup.cs index a38d7ff0a..6620c5cca 100644 --- a/ArchiSteamFarm/IPC/Startup.cs +++ b/ArchiSteamFarm/IPC/Startup.cs @@ -19,6 +19,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +using Newtonsoft.Json.Converters; +using File = System.IO.File; +using Path = System.IO.Path; +#else +using System.IO; +#endif using System; using System.Collections.Generic; using System.Globalization; @@ -39,15 +47,6 @@ using Microsoft.OpenApi.Models; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -using Newtonsoft.Json.Converters; -using File = System.IO.File; -using Path = System.IO.Path; -#else -using System.IO; -#endif - namespace ArchiSteamFarm.IPC { internal sealed class Startup { private readonly IConfiguration Configuration; @@ -266,6 +265,7 @@ namespace ArchiSteamFarm.IPC { mvc.SetCompatibilityVersion(CompatibilityVersion.Latest); #if NETFRAMEWORK + // Add standard formatters mvc.AddFormatterMappings(); @@ -274,6 +274,7 @@ 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(); @@ -290,6 +291,7 @@ 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 bb42814e4..96298fe3e 100644 --- a/ArchiSteamFarm/OS.cs +++ b/ArchiSteamFarm/OS.cs @@ -19,6 +19,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +using File = System.IO.File; +#endif using System; using System.Diagnostics; using System.Globalization; @@ -32,11 +36,6 @@ using System.Threading.Tasks; using ArchiSteamFarm.Localization; using ArchiSteamFarm.Web; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -using File = System.IO.File; -#endif - namespace ArchiSteamFarm { internal static class OS { // We need to keep this one assigned and not calculated on-demand @@ -170,6 +169,7 @@ 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,7 +193,6 @@ namespace ArchiSteamFarm { _ => false }; #else - // This is .NET Core build, we support all scenarios return true; #endif diff --git a/ArchiSteamFarm/RuntimeCompatibility/Path.cs b/ArchiSteamFarm/RuntimeCompatibility/Path.cs index 60b53e49c..3b7bf63c7 100644 --- a/ArchiSteamFarm/RuntimeCompatibility/Path.cs +++ b/ArchiSteamFarm/RuntimeCompatibility/Path.cs @@ -19,11 +19,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using JetBrains.Annotations; - #if NETFRAMEWORK using System; #endif +using JetBrains.Annotations; namespace ArchiSteamFarm.RuntimeCompatibility { [PublicAPI] diff --git a/ArchiSteamFarm/RuntimeCompatibility/StaticHelpers.cs b/ArchiSteamFarm/RuntimeCompatibility/StaticHelpers.cs index 4fc058084..98c48050e 100644 --- a/ArchiSteamFarm/RuntimeCompatibility/StaticHelpers.cs +++ b/ArchiSteamFarm/RuntimeCompatibility/StaticHelpers.cs @@ -19,10 +19,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System; -using System.Diagnostics; -using JetBrains.Annotations; - #if NETFRAMEWORK using System.Collections.Generic; using System.IO; @@ -32,6 +28,9 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; #endif +using System; +using System.Diagnostics; +using JetBrains.Annotations; namespace ArchiSteamFarm.RuntimeCompatibility { [PublicAPI] diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index 2cd8f4afe..cf2b981b5 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -33,10 +36,6 @@ using ArchiSteamFarm.Localization; using ArchiSteamFarm.Web; using Newtonsoft.Json; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm { internal sealed class Statistics : IAsyncDisposable { private const ushort MaxItemsForFairBots = ArchiWebHandler.MaxItemsInSingleInventoryRequest * WebBrowser.MaxTries; // Determines which fair bots we'll deprioritize when matching due to excessive number of inventory requests they need to make, which are likely to fail in the process or cause excessive delays diff --git a/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs b/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs index 73427f6a6..e76f8fc55 100644 --- a/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs +++ b/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs @@ -19,11 +19,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode; +#endif using System; using System.ComponentModel; using Newtonsoft.Json; using SteamKit2; -using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode; namespace ArchiSteamFarm.SteamKit2 { internal sealed class ServerRecordEndPoint : IEquatable { diff --git a/ArchiSteamFarm/SteamSaleEvent.cs b/ArchiSteamFarm/SteamSaleEvent.cs index 713668dbe..736d762ef 100644 --- a/ArchiSteamFarm/SteamSaleEvent.cs +++ b/ArchiSteamFarm/SteamSaleEvent.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Immutable; using System.Globalization; @@ -27,10 +30,6 @@ using System.Threading.Tasks; using AngleSharp.Dom; using ArchiSteamFarm.Localization; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm { internal sealed class SteamSaleEvent : IAsyncDisposable { private const byte MaxSingleQueuesDaily = 3; // This is only a failsafe for infinite queue clearing (in case IsDiscoveryQueueAvailable() would fail us) diff --git a/ArchiSteamFarm/Trading.cs b/ArchiSteamFarm/Trading.cs index 84bf4a71f..d34bb8fee 100644 --- a/ArchiSteamFarm/Trading.cs +++ b/ArchiSteamFarm/Trading.cs @@ -19,6 +19,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.Collections.Generic; using System.Globalization; @@ -33,10 +36,6 @@ using ArchiSteamFarm.Plugins; using JetBrains.Annotations; using SteamKit2; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm { public sealed class Trading : IDisposable { internal const byte MaxItemsPerTrade = byte.MaxValue; // This is decided upon various factors, mainly stability of Steam servers when dealing with huge trade offers diff --git a/ArchiSteamFarm/Web/StreamResponse.cs b/ArchiSteamFarm/Web/StreamResponse.cs index 15bd78f19..971cf9e13 100644 --- a/ArchiSteamFarm/Web/StreamResponse.cs +++ b/ArchiSteamFarm/Web/StreamResponse.cs @@ -19,16 +19,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if NETFRAMEWORK +using ArchiSteamFarm.RuntimeCompatibility; +#endif using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using JetBrains.Annotations; -#if NETFRAMEWORK -using ArchiSteamFarm.RuntimeCompatibility; -#endif - namespace ArchiSteamFarm.Web { public sealed class StreamResponse : BasicResponse, IAsyncDisposable { [PublicAPI]