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
// 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))]

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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

View File

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

View File

@@ -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

View File

@@ -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<Game> {

View File

@@ -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]

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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

View File

@@ -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

View File

@@ -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]

View File

@@ -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]

View File

@@ -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

View File

@@ -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<ServerRecordEndPoint> {

View File

@@ -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)

View File

@@ -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

View File

@@ -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]