diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 922316009..8f6056b46 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -287,7 +287,7 @@ namespace ArchiSteamFarm { } // Auto update logic starts here - if (releaseResponse.Assets == null) { + if (releaseResponse.Assets.IsEmpty) { ArchiLogger.LogGenericWarning(Strings.ErrorUpdateNoAssets); return null; diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index 7beda062d..2bed1379d 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -170,7 +170,7 @@ namespace ArchiSteamFarm { yield break; } - if ((response.Content.Assets == null) || (response.Content.Assets.Count == 0) || (response.Content.Descriptions == null) || (response.Content.Descriptions.Count == 0)) { + if ((response.Content.Assets.Count == 0) || (response.Content.Descriptions.Count == 0)) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response.Content.Assets) + " || " + nameof(response.Content.Descriptions))); } diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index 707004fa6..f0769f873 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -297,7 +297,6 @@ namespace ArchiSteamFarm { private string? BackingSteamPassword = DefaultSteamPassword; [JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamMasterClanID), Required = Required.DisallowNull)] - private string SSteamMasterClanID { get => SteamMasterClanID.ToString(CultureInfo.InvariantCulture); @@ -313,7 +312,7 @@ namespace ArchiSteamFarm { } [JsonConstructor] - private BotConfig() { } + internal BotConfig() { } internal (bool Valid, string? ErrorMessage) CheckValidation() { if (BotBehaviour > EBotBehaviour.All) { diff --git a/ArchiSteamFarm/GitHub.cs b/ArchiSteamFarm/GitHub.cs index 3f7d79526..3c918fd46 100644 --- a/ArchiSteamFarm/GitHub.cs +++ b/ArchiSteamFarm/GitHub.cs @@ -101,7 +101,7 @@ namespace ArchiSteamFarm { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class ReleaseResponse { [JsonProperty(PropertyName = "assets", Required = Required.Always)] - internal readonly ImmutableHashSet? Assets; + internal readonly ImmutableHashSet Assets = ImmutableHashSet.Empty; [JsonProperty(PropertyName = "prerelease", Required = Required.Always)] internal readonly bool IsPreRelease; @@ -110,7 +110,7 @@ namespace ArchiSteamFarm { internal readonly DateTime PublishedAt; [JsonProperty(PropertyName = "tag_name", Required = Required.Always)] - internal readonly string? Tag; + internal readonly string Tag = ""; internal string? ChangelogHTML { get { diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index 31611aabe..b09f401fc 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -283,7 +283,6 @@ namespace ArchiSteamFarm { private string? BackingWebProxyPassword = DefaultWebProxyPassword; [JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamOwnerID), Required = Required.DisallowNull)] - private string SSteamOwnerID { get => SteamOwnerID.ToString(CultureInfo.InvariantCulture); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs index 38870d561..fac9a0e8c 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs @@ -109,10 +109,6 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { throw new InvalidOperationException(nameof(ASF.GlobalConfig)); } - if (request.GlobalConfig == null) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.GlobalConfig)))); - } - (bool valid, string? errorMessage) = request.GlobalConfig.CheckValidation(); if (!valid) { diff --git a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs index 93382f2da..e141fc986 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/BotController.cs @@ -97,10 +97,6 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { throw new InvalidOperationException(nameof(Bot.Bots)); } - if (request.BotConfig == null) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.BotConfig)))); - } - (bool valid, string? errorMessage) = request.BotConfig.CheckValidation(); if (!valid) { @@ -225,7 +221,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { throw new ArgumentNullException(nameof(request)); } - if ((request.GamesToRedeemInBackground == null) || (request.GamesToRedeemInBackground.Count == 0)) { + if (request.GamesToRedeemInBackground.Count == 0) { return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.GamesToRedeemInBackground)))); } @@ -330,7 +326,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { throw new ArgumentNullException(nameof(request)); } - if ((request.KeysToRedeem == null) || (request.KeysToRedeem.Count == 0)) { + if (request.KeysToRedeem.Count == 0) { return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.KeysToRedeem)))); } @@ -482,7 +478,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { return BadRequest(new GenericResponse>(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames))); } - IList<(bool Success, string Message)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.HandleTwoFactorAuthenticationConfirmations(request.Accept, request.AcceptedType, request.AcceptedCreatorIDs?.Count > 0 ? request.AcceptedCreatorIDs : null, request.WaitIfNeeded))).ConfigureAwait(false); + IList<(bool Success, string Message)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.HandleTwoFactorAuthenticationConfirmations(request.Accept, request.AcceptedType, request.AcceptedCreatorIDs.Count > 0 ? request.AcceptedCreatorIDs : null, request.WaitIfNeeded))).ConfigureAwait(false); Dictionary result = new(bots.Count, Bot.BotsComparer); diff --git a/ArchiSteamFarm/IPC/Requests/ASFEncryptRequest.cs b/ArchiSteamFarm/IPC/Requests/ASFEncryptRequest.cs index d18f48aed..ee3ba0661 100644 --- a/ArchiSteamFarm/IPC/Requests/ASFEncryptRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/ASFEncryptRequest.cs @@ -38,7 +38,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public string? StringToEncrypt { get; private set; } + public string StringToEncrypt { get; private set; } = ""; [JsonConstructor] private ASFEncryptRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/ASFHashRequest.cs b/ArchiSteamFarm/IPC/Requests/ASFHashRequest.cs index 4db98705f..df96d1c74 100644 --- a/ArchiSteamFarm/IPC/Requests/ASFHashRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/ASFHashRequest.cs @@ -38,7 +38,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public string? StringToHash { get; private set; } + public string StringToHash { get; private set; } = ""; [JsonConstructor] private ASFHashRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/ASFRequest.cs b/ArchiSteamFarm/IPC/Requests/ASFRequest.cs index 9f742997b..e40bfcbf2 100644 --- a/ArchiSteamFarm/IPC/Requests/ASFRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/ASFRequest.cs @@ -31,7 +31,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public GlobalConfig? GlobalConfig { get; private set; } + public GlobalConfig GlobalConfig { get; private set; } = new(); [JsonConstructor] private ASFRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/BotGamesToRedeemInBackgroundRequest.cs b/ArchiSteamFarm/IPC/Requests/BotGamesToRedeemInBackgroundRequest.cs index 3f79f6237..2c0b26b4b 100644 --- a/ArchiSteamFarm/IPC/Requests/BotGamesToRedeemInBackgroundRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/BotGamesToRedeemInBackgroundRequest.cs @@ -36,7 +36,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public OrderedDictionary? GamesToRedeemInBackground { get; private set; } + public OrderedDictionary GamesToRedeemInBackground { get; private set; } = new(); [JsonConstructor] private BotGamesToRedeemInBackgroundRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/BotInputRequest.cs b/ArchiSteamFarm/IPC/Requests/BotInputRequest.cs index 49393664f..d9ab09be8 100644 --- a/ArchiSteamFarm/IPC/Requests/BotInputRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/BotInputRequest.cs @@ -35,7 +35,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// Specifies the value for given input type (declared in ) /// [JsonProperty(Required = Required.Always)] - public string? Value { get; private set; } + public string Value { get; private set; } = ""; [JsonConstructor] private BotInputRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/BotRedeemRequest.cs b/ArchiSteamFarm/IPC/Requests/BotRedeemRequest.cs index 7e39c5f98..48e052a46 100644 --- a/ArchiSteamFarm/IPC/Requests/BotRedeemRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/BotRedeemRequest.cs @@ -32,7 +32,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public ImmutableHashSet? KeysToRedeem { get; private set; } + public ImmutableHashSet KeysToRedeem { get; private set; } = ImmutableHashSet.Empty; [JsonConstructor] private BotRedeemRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/BotRenameRequest.cs b/ArchiSteamFarm/IPC/Requests/BotRenameRequest.cs index a789dc351..428068548 100644 --- a/ArchiSteamFarm/IPC/Requests/BotRenameRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/BotRenameRequest.cs @@ -31,7 +31,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public string? NewName { get; private set; } + public string NewName { get; private set; } = ""; [JsonConstructor] private BotRenameRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/BotRequest.cs b/ArchiSteamFarm/IPC/Requests/BotRequest.cs index 8038f6cdd..29144716b 100644 --- a/ArchiSteamFarm/IPC/Requests/BotRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/BotRequest.cs @@ -31,7 +31,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public BotConfig? BotConfig { get; private set; } + public BotConfig BotConfig { get; private set; } = new(); [JsonConstructor] private BotRequest() { } diff --git a/ArchiSteamFarm/IPC/Requests/CommandRequest.cs b/ArchiSteamFarm/IPC/Requests/CommandRequest.cs index bfbeece99..7a523e897 100644 --- a/ArchiSteamFarm/IPC/Requests/CommandRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/CommandRequest.cs @@ -32,7 +32,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [JsonProperty(Required = Required.Always)] [Required] - public string? Command { get; private set; } + public string Command { get; private set; } = ""; internal CommandRequest(string command) { if (string.IsNullOrEmpty(command)) { diff --git a/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs b/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs index 3b16f6342..3f954915b 100644 --- a/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs @@ -40,12 +40,12 @@ namespace ArchiSteamFarm.IPC.Requests { /// Specifies IDs of the confirmations that we're supposed to handle. CreatorID of the confirmation is equal to ID of the object that triggered it - e.g. ID of the trade offer, or ID of the market listing. If not provided, or empty array, all confirmation IDs are considered for an action. /// [JsonProperty(Required = Required.DisallowNull)] - public ImmutableHashSet? AcceptedCreatorIDs { get; private set; } + public ImmutableHashSet AcceptedCreatorIDs { get; private set; } = ImmutableHashSet.Empty; /// /// Specifies the type of confirmations to handle. If not provided, all confirmation types are considered for an action. /// - [JsonProperty(Required = Required.DisallowNull)] + [JsonProperty] public MobileAuthenticator.Confirmation.EType? AcceptedType { get; private set; } /// diff --git a/ArchiSteamFarm/IPC/Requests/WWWSendRequest.cs b/ArchiSteamFarm/IPC/Requests/WWWSendRequest.cs index 85002de75..6fff02313 100644 --- a/ArchiSteamFarm/IPC/Requests/WWWSendRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/WWWSendRequest.cs @@ -34,7 +34,7 @@ namespace ArchiSteamFarm.IPC.Requests { /// [Required] [JsonProperty(Required = Required.Always)] - public string? URL { get; private set; } + public string URL { get; private set; } = ""; [JsonConstructor] private WWWSendRequest() { } diff --git a/ArchiSteamFarm/IPC/Responses/GitHubReleaseResponse.cs b/ArchiSteamFarm/IPC/Responses/GitHubReleaseResponse.cs index 0a8add30b..54ecee1d4 100644 --- a/ArchiSteamFarm/IPC/Responses/GitHubReleaseResponse.cs +++ b/ArchiSteamFarm/IPC/Responses/GitHubReleaseResponse.cs @@ -30,7 +30,7 @@ namespace ArchiSteamFarm.IPC.Responses { /// [JsonProperty(Required = Required.Always)] [Required] - public string? ChangelogHTML { get; private set; } + public string ChangelogHTML { get; private set; } /// /// Date of the release. @@ -51,14 +51,14 @@ namespace ArchiSteamFarm.IPC.Responses { /// [JsonProperty(Required = Required.Always)] [Required] - public string? Version { get; private set; } + public string Version { get; private set; } internal GitHubReleaseResponse(GitHub.ReleaseResponse releaseResponse) { if (releaseResponse == null) { throw new ArgumentNullException(nameof(releaseResponse)); } - ChangelogHTML = releaseResponse.ChangelogHTML; + ChangelogHTML = releaseResponse.ChangelogHTML ?? ""; ReleasedAt = releaseResponse.PublishedAt; Stable = !releaseResponse.IsPreRelease; Version = releaseResponse.Tag; diff --git a/ArchiSteamFarm/Json/Steam.cs b/ArchiSteamFarm/Json/Steam.cs index 09689bf98..e5e063b8e 100644 --- a/ArchiSteamFarm/Json/Steam.cs +++ b/ArchiSteamFarm/Json/Steam.cs @@ -253,11 +253,11 @@ namespace ArchiSteamFarm.Json { public sealed class Tag { [JsonProperty(PropertyName = "category", Required = Required.Always)] [PublicAPI] - public string? Identifier { get; private set; } + public string Identifier { get; private set; } = ""; [JsonProperty(PropertyName = "internal_name", Required = Required.Always)] [PublicAPI] - public string? Value { get; private set; } + public string Value { get; private set; } = ""; internal Tag(string identifier, string value) { Identifier = !string.IsNullOrEmpty(identifier) ? identifier : throw new ArgumentNullException(nameof(identifier)); @@ -366,13 +366,13 @@ namespace ArchiSteamFarm.Json { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class InventoryResponse : EResultResponse { [JsonProperty(PropertyName = "assets", Required = Required.DisallowNull)] - internal readonly ImmutableHashSet? Assets; + internal readonly ImmutableHashSet Assets = ImmutableHashSet.Empty; [JsonProperty(PropertyName = "descriptions", Required = Required.DisallowNull)] - internal readonly ImmutableHashSet? Descriptions; + internal readonly ImmutableHashSet Descriptions = ImmutableHashSet.Empty; [JsonProperty(PropertyName = "error", Required = Required.DisallowNull)] - internal readonly string? Error; + internal readonly string Error = ""; [JsonProperty(PropertyName = "total_inventory_count", Required = Required.DisallowNull)] internal readonly uint TotalInventoryCount; @@ -414,10 +414,6 @@ namespace ArchiSteamFarm.Json { internal sealed class Description { internal Asset.ERarity Rarity { get { - if (Tags == null) { - return Asset.ERarity.Unknown; - } - foreach (Asset.Tag tag in Tags) { switch (tag.Identifier) { case "droprate": @@ -444,10 +440,6 @@ namespace ArchiSteamFarm.Json { internal uint RealAppID { get { - if (Tags == null) { - return 0; - } - foreach (Asset.Tag tag in Tags) { switch (tag.Identifier) { case "Game": @@ -475,10 +467,6 @@ namespace ArchiSteamFarm.Json { internal Asset.EType Type { get { - if (Tags == null) { - return Asset.EType.Unknown; - } - Asset.EType type = Asset.EType.Unknown; foreach (Asset.Tag tag in Tags) { @@ -554,7 +542,7 @@ namespace ArchiSteamFarm.Json { internal bool Marketable { get; set; } [JsonProperty(PropertyName = "tags", Required = Required.DisallowNull)] - internal ImmutableHashSet? Tags { get; set; } + internal ImmutableHashSet Tags { get; set; } = ImmutableHashSet.Empty; internal bool Tradable { get; set; } @@ -620,7 +608,7 @@ namespace ArchiSteamFarm.Json { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class NewDiscoveryQueueResponse { [JsonProperty(PropertyName = "queue", Required = Required.Always)] - internal readonly ImmutableHashSet? Queue; + internal readonly ImmutableHashSet Queue = ImmutableHashSet.Empty; [JsonConstructor] private NewDiscoveryQueueResponse() { } @@ -629,7 +617,7 @@ namespace ArchiSteamFarm.Json { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class RedeemWalletResponse : EResultResponse { [JsonProperty(PropertyName = "detail", Required = Required.DisallowNull)] - internal readonly EPurchaseResultDetail? PurchaseResultDetail; + internal readonly EPurchaseResultDetail PurchaseResultDetail; [JsonConstructor] private RedeemWalletResponse() { } @@ -638,7 +626,7 @@ namespace ArchiSteamFarm.Json { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class TradeOfferAcceptResponse { [JsonProperty(PropertyName = "strError", Required = Required.DisallowNull)] - internal readonly string? ErrorText; + internal readonly string ErrorText = ""; [JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)] internal readonly bool RequiresMobileConfirmation; @@ -698,7 +686,7 @@ namespace ArchiSteamFarm.Json { internal readonly ECommentPermission CommentPermission; [JsonProperty(PropertyName = "PrivacySettings", Required = Required.Always)] - internal readonly PrivacySettings? Settings; + internal readonly PrivacySettings Settings = new(); // Constructed from privacy change request internal UserPrivacy(PrivacySettings settings, ECommentPermission commentPermission) { @@ -763,7 +751,7 @@ namespace ArchiSteamFarm.Json { } [JsonConstructor] - private PrivacySettings() { } + internal PrivacySettings() { } } internal enum ECommentPermission : byte { diff --git a/ArchiSteamFarm/MobileAuthenticator.cs b/ArchiSteamFarm/MobileAuthenticator.cs index 2ae1dfbb7..494448b1f 100644 --- a/ArchiSteamFarm/MobileAuthenticator.cs +++ b/ArchiSteamFarm/MobileAuthenticator.cs @@ -57,12 +57,12 @@ namespace ArchiSteamFarm { #pragma warning disable 649 [JsonProperty(PropertyName = "identity_secret", Required = Required.Always)] - private readonly string? IdentitySecret; + private readonly string IdentitySecret = ""; #pragma warning restore 649 #pragma warning disable 649 [JsonProperty(PropertyName = "shared_secret", Required = Required.Always)] - private readonly string? SharedSecret; + private readonly string SharedSecret = ""; #pragma warning restore 649 private Bot? Bot; diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index 92d9f1775..4021a2ee7 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -716,7 +716,7 @@ namespace ArchiSteamFarm { #pragma warning disable 649 [JsonProperty(PropertyName = "trade_token", Required = Required.Always)] - internal readonly string? TradeToken; + internal readonly string TradeToken = ""; #pragma warning restore 649 internal float Score => GamesCount / (float) ItemsCount; diff --git a/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs b/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs index d3105b998..817930faa 100644 --- a/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs +++ b/ArchiSteamFarm/SteamKit2/ServerRecordEndPoint.cs @@ -27,7 +27,7 @@ using SteamKit2; namespace ArchiSteamFarm.SteamKit2 { internal sealed class ServerRecordEndPoint : IEquatable { [JsonProperty(Required = Required.Always)] - internal readonly string? Host; + internal readonly string Host = ""; [JsonProperty(Required = Required.Always)] internal readonly ushort Port;