Cleanup round

This commit is contained in:
JustArchi
2021-05-06 20:44:17 +02:00
parent ef52e076d3
commit aed11c59ee
21 changed files with 75 additions and 88 deletions

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Composition; using System.Composition;
@@ -30,10 +33,6 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using SteamKit2; using SteamKit2;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin { namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin {
// In order for your plugin to work, it must export generic ASF's IPlugin interface // In order for your plugin to work, it must export generic ASF's IPlugin interface
[Export(typeof(IPlugin))] [Export(typeof(IPlugin))]

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@@ -36,10 +39,6 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using SteamKit2; using SteamKit2;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
[Export(typeof(IPlugin))] [Export(typeof(IPlugin))]
internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotSteamClient, ISteamPICSChanges { internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotSteamClient, ISteamPICSChanges {

View File

@@ -19,16 +19,15 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ArchiSteamFarm.Json; using ArchiSteamFarm.Json;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm.Tests { namespace ArchiSteamFarm.Tests {
[TestClass] [TestClass]
public sealed class Bot { public sealed class Bot {

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -36,11 +39,6 @@ using ArchiSteamFarm.Web;
using JetBrains.Annotations; using JetBrains.Annotations;
using SteamKit2; using SteamKit2;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
public sealed class Actions : IAsyncDisposable { public sealed class Actions : IAsyncDisposable {
private static readonly SemaphoreSlim GiftCardsSemaphore = new(1, 1); private static readonly SemaphoreSlim GiftCardsSemaphore = new(1, 1);

View File

@@ -19,6 +19,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File;
using Path = System.IO.Path;
#endif
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@@ -47,13 +52,6 @@ using Newtonsoft.Json;
using SteamKit2; using SteamKit2;
using SteamKit2.Internal; using SteamKit2.Internal;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File;
using Path = System.IO.Path;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
public sealed class Bot : IAsyncDisposable { public sealed class Bot : IAsyncDisposable {
internal const ushort CallbackSleep = 500; // In milliseconds internal const ushort CallbackSleep = 500; // In milliseconds

View File

@@ -21,7 +21,6 @@
#if NETFRAMEWORK #if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility; using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File; using File = System.IO.File;
#else #else
using System.IO; using System.IO;

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@@ -37,10 +40,6 @@ using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using SteamKit2; using SteamKit2;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
public sealed class CardsFarmer : IAsyncDisposable { public sealed class CardsFarmer : IAsyncDisposable {
internal const byte DaysForRefund = 14; // In how many days since payment we're allowed to refund internal const byte DaysForRefund = 14; // In how many days since payment we're allowed to refund

View File

@@ -19,9 +19,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode;
#endif
using System; using System;
using Newtonsoft.Json; using Newtonsoft.Json;
using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
public sealed class Game : IEquatable<Game> { public sealed class Game : IEquatable<Game> {

View File

@@ -19,6 +19,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File;
#else
using System.IO;
#endif
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@@ -33,13 +39,6 @@ using ArchiSteamFarm.SteamKit2;
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File;
#else
using System.IO;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
public sealed class GlobalDatabase : SerializableFile { public sealed class GlobalDatabase : SerializableFile {
[JsonIgnore] [JsonIgnore]

View File

@@ -20,9 +20,9 @@
// limitations under the License. // limitations under the License.
using System; using System;
using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ArchiSteamFarm.RuntimeCompatibility;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace ArchiSteamFarm.Helpers { namespace ArchiSteamFarm.Helpers {
@@ -79,12 +79,12 @@ namespace ArchiSteamFarm.Helpers {
string newFilePath = FilePath + ".new"; 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 // 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)) { if (System.IO.File.Exists(FilePath)) {
File.Replace(newFilePath, FilePath!, null); System.IO.File.Replace(newFilePath, FilePath!, null);
} else { } else {
File.Move(newFilePath, FilePath!); System.IO.File.Move(newFilePath, FilePath!);
} }
} catch (Exception e) { } catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e); ASF.ArchiLogger.LogGenericException(e);

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
@@ -33,10 +36,6 @@ using ArchiSteamFarm.Localization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm.IPC.Controllers.Api { namespace ArchiSteamFarm.IPC.Controllers.Api {
[Route("Api/Bot")] [Route("Api/Bot")]
public sealed class BotController : ArchiController { public sealed class BotController : ArchiController {

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@@ -36,10 +39,6 @@ using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm.IPC.Controllers.Api { namespace ArchiSteamFarm.IPC.Controllers.Api {
[Route("Api/NLog")] [Route("Api/NLog")]
public sealed class NLogController : ArchiController { public sealed class NLogController : ArchiController {

View File

@@ -19,6 +19,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
@@ -39,15 +47,6 @@ using Microsoft.OpenApi.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; 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 { namespace ArchiSteamFarm.IPC {
internal sealed class Startup { internal sealed class Startup {
private readonly IConfiguration Configuration; private readonly IConfiguration Configuration;
@@ -266,6 +265,7 @@ namespace ArchiSteamFarm.IPC {
mvc.SetCompatibilityVersion(CompatibilityVersion.Latest); mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
#if NETFRAMEWORK #if NETFRAMEWORK
// Add standard formatters // Add standard formatters
mvc.AddFormatterMappings(); mvc.AddFormatterMappings();
@@ -274,6 +274,7 @@ namespace ArchiSteamFarm.IPC {
#endif #endif
#if NETFRAMEWORK #if NETFRAMEWORK
// Add JSON formatters that will be used as default ones if no specific formatters are asked for // Add JSON formatters that will be used as default ones if no specific formatters are asked for
mvc.AddJsonFormatters(); mvc.AddJsonFormatters();
@@ -290,6 +291,7 @@ namespace ArchiSteamFarm.IPC {
} }
#if NETFRAMEWORK #if NETFRAMEWORK
// .NET Framework serializes Version as object by default, serialize it as string just like .NET Core // .NET Framework serializes Version as object by default, serialize it as string just like .NET Core
options.SerializerSettings.Converters.Add(new VersionConverter()); options.SerializerSettings.Converters.Add(new VersionConverter());
#endif #endif

View File

@@ -19,6 +19,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File;
#endif
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
@@ -32,11 +36,6 @@ using System.Threading.Tasks;
using ArchiSteamFarm.Localization; using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Web; using ArchiSteamFarm.Web;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal static class OS { internal static class OS {
// We need to keep this one assigned and not calculated on-demand // We need to keep this one assigned and not calculated on-demand
@@ -170,6 +169,7 @@ namespace ArchiSteamFarm {
internal static bool VerifyEnvironment() { internal static bool VerifyEnvironment() {
#if NETFRAMEWORK #if NETFRAMEWORK
// This is .NET Framework build, we support that one only on mono for platforms not supported by .NET Core // 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 // 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 _ => false
}; };
#else #else
// This is .NET Core build, we support all scenarios // This is .NET Core build, we support all scenarios
return true; return true;
#endif #endif

View File

@@ -19,11 +19,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
using JetBrains.Annotations;
#if NETFRAMEWORK #if NETFRAMEWORK
using System; using System;
#endif #endif
using JetBrains.Annotations;
namespace ArchiSteamFarm.RuntimeCompatibility { namespace ArchiSteamFarm.RuntimeCompatibility {
[PublicAPI] [PublicAPI]

View File

@@ -19,10 +19,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
using System;
using System.Diagnostics;
using JetBrains.Annotations;
#if NETFRAMEWORK #if NETFRAMEWORK
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -32,6 +28,9 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
#endif #endif
using System;
using System.Diagnostics;
using JetBrains.Annotations;
namespace ArchiSteamFarm.RuntimeCompatibility { namespace ArchiSteamFarm.RuntimeCompatibility {
[PublicAPI] [PublicAPI]

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
@@ -33,10 +36,6 @@ using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Web; using ArchiSteamFarm.Web;
using Newtonsoft.Json; using Newtonsoft.Json;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal sealed class Statistics : IAsyncDisposable { 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 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

View File

@@ -19,11 +19,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode;
#endif
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using Newtonsoft.Json; using Newtonsoft.Json;
using SteamKit2; using SteamKit2;
using HashCode = ArchiSteamFarm.RuntimeCompatibility.HashCode;
namespace ArchiSteamFarm.SteamKit2 { namespace ArchiSteamFarm.SteamKit2 {
internal sealed class ServerRecordEndPoint : IEquatable<ServerRecordEndPoint> { internal sealed class ServerRecordEndPoint : IEquatable<ServerRecordEndPoint> {

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Globalization; using System.Globalization;
@@ -27,10 +30,6 @@ using System.Threading.Tasks;
using AngleSharp.Dom; using AngleSharp.Dom;
using ArchiSteamFarm.Localization; using ArchiSteamFarm.Localization;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal sealed class SteamSaleEvent : IAsyncDisposable { 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) private const byte MaxSingleQueuesDaily = 3; // This is only a failsafe for infinite queue clearing (in case IsDiscoveryQueueAvailable() would fail us)

View File

@@ -19,6 +19,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
@@ -33,10 +36,6 @@ using ArchiSteamFarm.Plugins;
using JetBrains.Annotations; using JetBrains.Annotations;
using SteamKit2; using SteamKit2;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
public sealed class Trading : IDisposable { 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 internal const byte MaxItemsPerTrade = byte.MaxValue; // This is decided upon various factors, mainly stability of Steam servers when dealing with huge trade offers

View File

@@ -19,16 +19,15 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
using System; using System;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
#endif
namespace ArchiSteamFarm.Web { namespace ArchiSteamFarm.Web {
public sealed class StreamResponse : BasicResponse, IAsyncDisposable { public sealed class StreamResponse : BasicResponse, IAsyncDisposable {
[PublicAPI] [PublicAPI]