mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
.NET 8 (#3005)
* Initial .NET 8 * Make it compile in release mode ignoring warnings for now * First round of improvements * Second round of improvements * Third round of improvements * Use new throws * Fix .NET Framework, YAY, thanks madness! Madness devs are awesome * Misc * Misc * AF_NETLINK might be required for some http calls No clue why * Fix service files Doesn't do what it should * Update CardsFarmer.cs * New improvements * Address feedback * Misc * Misc * Misc refactor * Misc
This commit is contained in:
committed by
GitHub
parent
1e04acb904
commit
b34f18497d
@@ -47,9 +47,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> BotDelete(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -69,9 +67,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, Bot>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public ActionResult<GenericResponse> BotGet(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -90,10 +86,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, bool>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> BotPost(string botNames, [FromBody] BotRequest request) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
if (Bot.Bots == null) {
|
||||
@@ -108,7 +101,7 @@ public sealed class BotController : ArchiController {
|
||||
|
||||
request.BotConfig.Saving = true;
|
||||
|
||||
HashSet<string> bots = botNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToHashSet(Bot.BotsComparer);
|
||||
HashSet<string> bots = botNames.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries).ToHashSet(Bot.BotsComparer);
|
||||
|
||||
if (bots.Any(static botName => !ASF.IsValidBotName(botName))) {
|
||||
return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(botNames))));
|
||||
@@ -165,9 +158,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundDelete(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -187,9 +178,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GamesToRedeemInBackgroundResponse>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundGet(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -217,10 +206,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, IOrderedDictionary>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundPost(string botNames, [FromBody] BotGamesToRedeemInBackgroundRequest request) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
if (request.GamesToRedeemInBackground.Count == 0) {
|
||||
@@ -258,10 +244,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> InputPost(string botNames, [FromBody] BotInputRequest request) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
if ((request.Type == ASF.EUserInputType.None) || !Enum.IsDefined(request.Type) || string.IsNullOrEmpty(request.Value)) {
|
||||
@@ -287,10 +270,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> PausePost(string botNames, [FromBody] BotPauseRequest request) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
@@ -316,10 +296,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, IReadOnlyDictionary<string, CStore_RegisterCDKey_Response>>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> RedeemPost(string botNames, [FromBody] BotRedeemRequest request) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
if (request.KeysToRedeem.Count == 0) {
|
||||
@@ -358,10 +335,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> RenamePost(string botName, [FromBody] BotRenameRequest request) {
|
||||
if (string.IsNullOrEmpty(botName)) {
|
||||
throw new ArgumentNullException(nameof(botName));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botName);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
if (Bot.Bots == null) {
|
||||
@@ -388,9 +362,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> ResumePost(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -410,9 +382,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> StartPost(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -432,9 +402,7 @@ public sealed class BotController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> StopPost(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
|
||||
@@ -60,9 +60,7 @@ public sealed class GitHubController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)]
|
||||
public async Task<ActionResult<GenericResponse>> GitHubReleaseGet(string version) {
|
||||
if (string.IsNullOrEmpty(version)) {
|
||||
throw new ArgumentNullException(nameof(version));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(version);
|
||||
|
||||
GitHub.ReleaseResponse? releaseResponse;
|
||||
|
||||
@@ -95,9 +93,7 @@ public sealed class GitHubController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)]
|
||||
public async Task<ActionResult<GenericResponse>> GitHubWikiHistoryGet(string page) {
|
||||
if (string.IsNullOrEmpty(page)) {
|
||||
throw new ArgumentNullException(nameof(page));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(page);
|
||||
|
||||
Dictionary<string, DateTime>? revisions = await GitHub.GetWikiHistory(page).ConfigureAwait(false);
|
||||
|
||||
@@ -116,9 +112,7 @@ public sealed class GitHubController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)]
|
||||
public async Task<ActionResult<GenericResponse>> GitHubWikiPageGet(string page, [FromQuery] string? revision = null) {
|
||||
if (string.IsNullOrEmpty(page)) {
|
||||
throw new ArgumentNullException(nameof(page));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(page);
|
||||
|
||||
string? html = await GitHub.GetWikiPage(page, revision).ConfigureAwait(false);
|
||||
|
||||
|
||||
@@ -51,9 +51,7 @@ public sealed class IPCBansController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public ActionResult<GenericResponse> DeleteSpecific(string ipAddress) {
|
||||
if (string.IsNullOrEmpty(ipAddress)) {
|
||||
throw new ArgumentNullException(nameof(ipAddress));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(ipAddress);
|
||||
|
||||
if (!IPAddress.TryParse(ipAddress, out IPAddress? remoteAddress)) {
|
||||
return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(ipAddress))));
|
||||
|
||||
@@ -163,11 +163,7 @@ public sealed class NLogController : ArchiController {
|
||||
|
||||
private static async Task PostLoggedJsonUpdate(WebSocket webSocket, string json, SemaphoreSlim sendSemaphore, CancellationToken cancellationToken) {
|
||||
ArgumentNullException.ThrowIfNull(webSocket);
|
||||
|
||||
if (string.IsNullOrEmpty(json)) {
|
||||
throw new ArgumentNullException(nameof(json));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(json);
|
||||
ArgumentNullException.ThrowIfNull(sendSemaphore);
|
||||
|
||||
if (cancellationToken.IsCancellationRequested || (webSocket.State != WebSocketState.Open)) {
|
||||
@@ -203,11 +199,7 @@ public sealed class NLogController : ArchiController {
|
||||
|
||||
private static async Task PostLoggedMessageUpdate(WebSocket webSocket, string loggedMessage, SemaphoreSlim sendSemaphore, CancellationToken cancellationToken) {
|
||||
ArgumentNullException.ThrowIfNull(webSocket);
|
||||
|
||||
if (string.IsNullOrEmpty(loggedMessage)) {
|
||||
throw new ArgumentNullException(nameof(loggedMessage));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(loggedMessage);
|
||||
ArgumentNullException.ThrowIfNull(sendSemaphore);
|
||||
|
||||
if (cancellationToken.IsCancellationRequested || (webSocket.State != WebSocketState.Open)) {
|
||||
|
||||
@@ -36,9 +36,7 @@ public sealed class StorageController : ArchiController {
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
public ActionResult<GenericResponse> StorageDelete(string key) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(key);
|
||||
|
||||
if (ASF.GlobalDatabase == null) {
|
||||
throw new InvalidOperationException(nameof(ASF.GlobalDatabase));
|
||||
@@ -55,9 +53,7 @@ public sealed class StorageController : ArchiController {
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(GenericResponse<JToken>), (int) HttpStatusCode.OK)]
|
||||
public ActionResult<GenericResponse> StorageGet(string key) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(key);
|
||||
|
||||
if (ASF.GlobalDatabase == null) {
|
||||
throw new InvalidOperationException(nameof(ASF.GlobalDatabase));
|
||||
@@ -75,10 +71,7 @@ public sealed class StorageController : ArchiController {
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
public ActionResult<GenericResponse> StoragePost(string key, [FromBody] JToken value) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(key);
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
|
||||
if (ASF.GlobalDatabase == null) {
|
||||
|
||||
@@ -40,9 +40,7 @@ public sealed class StructureController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<object>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public ActionResult<GenericResponse> StructureGet(string structure) {
|
||||
if (string.IsNullOrEmpty(structure)) {
|
||||
throw new ArgumentNullException(nameof(structure));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(structure);
|
||||
|
||||
Type? targetType = WebUtilities.ParseType(structure);
|
||||
|
||||
|
||||
@@ -45,9 +45,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<IReadOnlyCollection<Confirmation>>>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> ConfirmationsGet(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -75,10 +73,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<IReadOnlyCollection<Confirmation>>>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> ConfirmationsPost(string botNames, [FromBody] TwoFactorAuthenticationConfirmationsRequest request) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(request.AcceptedType.Value))) {
|
||||
@@ -110,9 +105,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> Delete(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
@@ -140,10 +133,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> Post(string botNames, [FromBody] MobileAuthenticator authenticator) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
ArgumentNullException.ThrowIfNull(authenticator);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
@@ -171,9 +161,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> TokenGet(string botNames) {
|
||||
if (string.IsNullOrEmpty(botNames)) {
|
||||
throw new ArgumentNullException(nameof(botNames));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
|
||||
@@ -45,9 +45,7 @@ public sealed class TypeController : ArchiController {
|
||||
[ProducesResponseType(typeof(GenericResponse<TypeResponse>), (int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
|
||||
public ActionResult<GenericResponse> TypeGet(string type) {
|
||||
if (string.IsNullOrEmpty(type)) {
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(type);
|
||||
|
||||
Type? targetType = WebUtilities.ParseType(type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user