.NET 8 code enhancements

This commit is contained in:
Archi 2023-12-11 23:55:13 +01:00
parent cc3a0a4144
commit 40ab1d848c
No known key found for this signature in database
GPG key ID: 6B138B4C64555AEA
30 changed files with 333 additions and 327 deletions

View file

@ -36,7 +36,7 @@ csharp_prefer_simple_default_expression = true:warning
csharp_prefer_simple_using_statement = true:warning
csharp_prefer_static_local_function = true:warning
csharp_preferred_modifier_order = public, protected, internal, private, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:warning
csharp_preferred_modifier_order = public, protected, internal, private, file, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, required, volatile, async:warning
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
@ -79,15 +79,27 @@ csharp_style_expression_bodied_properties = true:warning
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
csharp_style_inlined_variable_declaration = true:warning
csharp_style_pattern_local_over_anonymous_function = true:warning
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_prefer_extended_property_pattern = true:warning
dotnet_style_prefer_foreach_explicit_cast_in_source = always:warning
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_local_over_anonymous_function = true:warning
csharp_style_prefer_method_group_conversion = true:warning
csharp_style_prefer_not_pattern = true:warning
csharp_style_prefer_null_check_over_type_check = true:warning
csharp_style_prefer_pattern_matching = true:warning
csharp_style_prefer_primary_constructors = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_prefer_readonly_struct = true:warning
csharp_style_prefer_readonly_struct_member = true:warning
csharp_style_prefer_switch_expression = true:warning
csharp_style_prefer_top_level_statements = false:warning
csharp_style_prefer_tuple_swap = true:warning
csharp_style_prefer_utf8_string_literals = true:warning
csharp_style_throw_expression = true:warning
@ -98,7 +110,7 @@ csharp_style_var_elsewhere = false:warning
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = false:warning
csharp_using_directive_placement = outside_namespace
csharp_using_directive_placement = outside_namespace:warning
###############################
# .NET Coding Conventions #
@ -186,6 +198,7 @@ dotnet_sort_system_directives_first = true
dotnet_style_coalesce_expression = true:warning
dotnet_style_collection_initializer = true:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_namespace_match_folder = true:warning
dotnet_style_null_propagation = true:warning
dotnet_style_object_initializer = true:warning

View file

@ -35,7 +35,7 @@ namespace ArchiSteamFarm.OfficialPlugins.ItemsMatcher;
internal sealed class BotCache : SerializableFile {
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ConcurrentList<AssetForListing> LastAnnouncedAssetsForListing = new();
internal readonly ConcurrentList<AssetForListing> LastAnnouncedAssetsForListing = [];
internal string? LastAnnouncedTradeToken {
get => BackingLastAnnouncedTradeToken;

View file

@ -112,7 +112,7 @@ internal static class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => ResponseMatch(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}

View file

@ -278,7 +278,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
uint index = 0;
ulong previousAssetID = 0;
List<AssetForListing> assetsForListing = new();
List<AssetForListing> assetsForListing = [];
Dictionary<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity), bool> tradableSets = new();
@ -372,7 +372,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
if (!matchEverything) {
// We should deduplicate our sets before sending them to the server, for doing that we'll use ASFB set parts data
HashSet<uint> realAppIDs = new();
HashSet<uint> realAppIDs = [];
Dictionary<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity), Dictionary<ulong, uint>> state = new();
foreach (AssetForListing asset in assetsForListing) {
@ -446,7 +446,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
Dictionary<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity), HashSet<ulong>> databaseSets = setPartsResponse.Content.Result.GroupBy(static setPart => (setPart.RealAppID, setPart.Type, setPart.Rarity)).ToDictionary(static group => group.Key, static group => group.Select(static setPart => setPart.ClassID).ToHashSet());
HashSet<(ulong ClassID, uint Amount)> setCopy = new();
HashSet<(ulong ClassID, uint Amount)> setCopy = [];
foreach (((uint RealAppID, Asset.EType Type, Asset.ERarity Rarity) key, Dictionary<ulong, uint> set) in state) {
if (!databaseSets.TryGetValue(key, out HashSet<ulong>? databaseSet)) {
@ -483,7 +483,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
}
}
HashSet<AssetForListing> assetsForListingFiltered = new();
HashSet<AssetForListing> assetsForListingFiltered = [];
foreach (AssetForListing asset in assetsForListing.Where(asset => state.TryGetValue((asset.RealAppID, asset.Type, asset.Rarity), out Dictionary<ulong, uint>? setState) && setState.TryGetValue(asset.ClassID, out uint targetAmount) && (targetAmount > 0)).OrderByDescending(static asset => asset.Tradable).ThenByDescending(static asset => asset.Index)) {
(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity) key = (asset.RealAppID, asset.Type, asset.Rarity);
@ -1031,16 +1031,16 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
}
}
matchActivelyTradeOfferIDs ??= new HashSet<ulong>();
matchActivelyTradeOfferIDs ??= [];
HashSet<ulong> deprioritizedSteamIDs = new();
HashSet<ulong> deprioritizedSteamIDs = [];
if (matchActivelyTradeOfferIDs.Count > 0) {
// This is not a mandatory step, we allow it to fail
HashSet<TradeOffer>? sentTradeOffers = await Bot.ArchiWebHandler.GetTradeOffers(true, false, true, false).ConfigureAwait(false);
if (sentTradeOffers != null) {
HashSet<ulong> activeTradeOfferIDs = new();
HashSet<ulong> activeTradeOfferIDs = [];
foreach (TradeOffer tradeOffer in sentTradeOffers.Where(tradeOffer => (tradeOffer.State == ETradeOfferState.Active) && matchActivelyTradeOfferIDs.Contains(tradeOffer.TradeOfferID))) {
deprioritizedSteamIDs.Add(tradeOffer.OtherSteamID64);
@ -1062,7 +1062,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
}
}
HashSet<ulong> pendingMobileTradeOfferIDs = new();
HashSet<ulong> pendingMobileTradeOfferIDs = [];
byte maxTradeHoldDuration = ASF.GlobalConfig?.MaxTradeHoldDuration ?? GlobalConfig.DefaultMaxTradeHoldDuration;
@ -1109,13 +1109,13 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
continue;
}
HashSet<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity)> skippedSetsThisUser = new();
HashSet<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity)> skippedSetsThisUser = [];
Dictionary<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity), Dictionary<ulong, uint>> theirTradableState = Trading.GetTradableInventoryState(theirInventory);
for (byte i = 0; i < Trading.MaxTradesPerAccount; i++) {
byte itemsInTrade = 0;
HashSet<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity)> skippedSetsThisTrade = new();
HashSet<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity)> skippedSetsThisTrade = [];
Dictionary<ulong, uint> classIDsToGive = new();
Dictionary<ulong, uint> classIDsToReceive = new();

View file

@ -220,7 +220,7 @@ internal static class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => ResponseTwoFactorFinalize(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot, activationCode))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -313,7 +313,7 @@ internal static class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => ResponseTwoFactorFinalized(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot, activationCode))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -392,7 +392,7 @@ internal static class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => ResponseTwoFactorInit(Steam.Interaction.Commands.GetProxyAccess(bot, access, steamID), bot))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}

View file

@ -324,7 +324,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC
packageIDs ??= bot.OwnedPackageIDs.Where(static package => (Config?.SecretPackageIDs.Contains(package.Key) != true) && ((package.Value.PaymentMethod != EPaymentMethod.AutoGrant) || (Config?.SkipAutoGrantPackages == false))).Select(static package => package.Key).ToHashSet();
HashSet<uint> appIDsToRefresh = new();
HashSet<uint> appIDsToRefresh = [];
foreach (uint packageID in packageIDs.Where(static packageID => Config?.SecretPackageIDs.Contains(packageID) != true)) {
if (!ASF.GlobalDatabase.PackagesDataReadOnly.TryGetValue(packageID, out PackageData? packageData) || (packageData.AppIDs == null)) {
@ -576,7 +576,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC
Utilities.InBackground(static () => SubmitData());
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}

View file

@ -39,7 +39,7 @@ public sealed class Bot {
{ 43, MinCardsPerBadge + 1 }
};
HashSet<Asset> items = new();
HashSet<Asset> items = [];
foreach ((uint appID, byte cards) in itemsPerSet) {
for (byte i = 1; i <= cards; i++) {
@ -59,10 +59,10 @@ public sealed class Bot {
public void MaxItemsTooSmall() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID),
CreateCard(2, appID)
};
];
GetItemsForFullBadge(items, 2, appID, MinCardsPerBadge - 1);
@ -73,12 +73,12 @@ public sealed class Bot {
public void MoreCardsThanNeeded() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID),
CreateCard(1, appID),
CreateCard(2, appID),
CreateCard(3, appID)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
@ -95,12 +95,12 @@ public sealed class Bot {
public void MultipleSets() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID),
CreateCard(1, appID),
CreateCard(2, appID),
CreateCard(2, appID)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
@ -116,11 +116,11 @@ public sealed class Bot {
public void MultipleSetsDifferentAmount() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, 2),
CreateCard(2, appID),
CreateCard(2, appID)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
@ -136,7 +136,7 @@ public sealed class Bot {
public void MutliRarityAndType() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, type: Asset.EType.TradingCard, rarity: Asset.ERarity.Common),
CreateCard(2, appID, type: Asset.EType.TradingCard, rarity: Asset.ERarity.Common),
@ -158,7 +158,7 @@ public sealed class Bot {
CreateCard(2, appID, type: Asset.EType.Unknown, rarity: Asset.ERarity.Rare),
CreateCard(3, appID, type: Asset.EType.Unknown, rarity: Asset.ERarity.Rare),
CreateCard(4, appID, type: Asset.EType.Unknown, rarity: Asset.ERarity.Rare)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
@ -177,10 +177,10 @@ public sealed class Bot {
public void NotAllCardsPresent() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID),
CreateCard(2, appID)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
@ -192,10 +192,10 @@ public sealed class Bot {
public void OneSet() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID),
CreateCard(2, appID)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
@ -212,10 +212,10 @@ public sealed class Bot {
const uint appID0 = 42;
const uint appID1 = 43;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID0),
CreateCard(1, appID1)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(
items, new Dictionary<uint, byte> {
@ -237,10 +237,10 @@ public sealed class Bot {
const uint appID0 = 42;
const uint appID1 = 43;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID0),
CreateCard(1, appID1)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(
items, new Dictionary<uint, byte> {
@ -260,14 +260,14 @@ public sealed class Bot {
const uint appID1 = 43;
const uint appID2 = 44;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID0),
CreateCard(2, appID0),
CreateCard(1, appID1),
CreateCard(2, appID1),
CreateCard(3, appID1)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(
items, new Dictionary<uint, byte> {
@ -290,10 +290,10 @@ public sealed class Bot {
public void OtherRarityFullSets() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, rarity: Asset.ERarity.Common),
CreateCard(1, appID, rarity: Asset.ERarity.Rare)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 1, appID);
@ -308,10 +308,10 @@ public sealed class Bot {
public void OtherRarityNoSets() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, rarity: Asset.ERarity.Common),
CreateCard(1, appID, rarity: Asset.ERarity.Rare)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
@ -324,13 +324,13 @@ public sealed class Bot {
public void OtherRarityOneSet() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, rarity: Asset.ERarity.Common),
CreateCard(2, appID, rarity: Asset.ERarity.Common),
CreateCard(1, appID, rarity: Asset.ERarity.Uncommon),
CreateCard(2, appID, rarity: Asset.ERarity.Uncommon),
CreateCard(3, appID, rarity: Asset.ERarity.Uncommon)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
@ -347,10 +347,10 @@ public sealed class Bot {
public void OtherTypeFullSets() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, type: Asset.EType.TradingCard),
CreateCard(1, appID, type: Asset.EType.FoilTradingCard)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 1, appID);
@ -365,10 +365,10 @@ public sealed class Bot {
public void OtherTypeNoSets() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, type: Asset.EType.TradingCard),
CreateCard(1, appID, type: Asset.EType.FoilTradingCard)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
@ -381,13 +381,13 @@ public sealed class Bot {
public void OtherTypeOneSet() {
const uint appID = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID, type: Asset.EType.TradingCard),
CreateCard(2, appID, type: Asset.EType.TradingCard),
CreateCard(1, appID, type: Asset.EType.FoilTradingCard),
CreateCard(2, appID, type: Asset.EType.FoilTradingCard),
CreateCard(3, appID, type: Asset.EType.FoilTradingCard)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
@ -404,10 +404,10 @@ public sealed class Bot {
public void TooHighAmount() {
const uint appID0 = 42;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID0, 2),
CreateCard(2, appID0)
};
];
HashSet<Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID0);
@ -423,7 +423,7 @@ public sealed class Bot {
public void TooManyCardsForSingleTrade() {
const uint appID = 42;
HashSet<Asset> items = new();
HashSet<Asset> items = [];
for (byte i = 0; i < Steam.Exchange.Trading.MaxItemsPerTrade; i++) {
items.Add(CreateCard(1, appID));
@ -440,7 +440,7 @@ public sealed class Bot {
const uint appID0 = 42;
const uint appID1 = 43;
HashSet<Asset> items = new();
HashSet<Asset> items = [];
for (byte i = 0; i < 100; i++) {
items.Add(CreateCard(1, appID0));
@ -466,12 +466,12 @@ public sealed class Bot {
const uint appID1 = 43;
const uint appID2 = 44;
HashSet<Asset> items = new() {
HashSet<Asset> items = [
CreateCard(1, appID0),
CreateCard(2, appID0),
CreateCard(3, appID0),
CreateCard(4, appID0)
};
];
GetItemsForFullBadge(
items, new Dictionary<uint, byte> {

View file

@ -200,60 +200,62 @@ public sealed class SteamChatMessage {
public async Task RyzhehvostInitialTestForSplitting() {
const string prefix = "/me ";
const string message = @"<XLimited5> Уже имеет: app/1493800 | Aircraft Carrier Survival: Prolouge
<XLimited5> Уже имеет: app/349520 | Armillo
<XLimited5> Уже имеет: app/346330 | BrainBread 2
<XLimited5> Уже имеет: app/1086690 | C-War 2
<XLimited5> Уже имеет: app/730 | Counter-Strike: Global Offensive
<XLimited5> Уже имеет: app/838380 | DEAD OR ALIVE 6
<XLimited5> Уже имеет: app/582890 | Estranged: The Departure
<XLimited5> Уже имеет: app/331470 | Everlasting Summer
<XLimited5> Уже имеет: app/1078000 | Gamecraft
<XLimited5> Уже имеет: app/266310 | GameGuru
<XLimited5> Уже имеет: app/275390 | Guacamelee! Super Turbo Championship Edition
<XLimited5> Уже имеет: app/627690 | Idle Champions of the Forgotten Realms
<XLimited5> Уже имеет: app/1048540 | Kao the Kangaroo: Round 2
<XLimited5> Уже имеет: app/370910 | Kathy Rain
<XLimited5> Уже имеет: app/343710 | KHOLAT
<XLimited5> Уже имеет: app/253900 | Knights and Merchants
<XLimited5> Уже имеет: app/224260 | No More Room in Hell
<XLimited5> Уже имеет: app/343360 | Particula
<XLimited5> Уже имеет: app/237870 | Planet Explorers
<XLimited5> Уже имеет: app/684680 | Polygoneer
<XLimited5> Уже имеет: app/1089130 | Quake II RTX
<XLimited5> Уже имеет: app/755790 | Ring of Elysium
<XLimited5> Уже имеет: app/1258080 | Shop Titans
<XLimited5> Уже имеет: app/759530 | Struckd - 3D Game Creator
<XLimited5> Уже имеет: app/269710 | Tumblestone
<XLimited5> Уже имеет: app/304930 | Unturned
<XLimited5> Уже имеет: app/1019250 | WWII TCG - World War 2: The Card Game
const string message = """
<XLimited5> Уже имеет: app/1493800 | Aircraft Carrier Survival: Prolouge
<XLimited5> Уже имеет: app/349520 | Armillo
<XLimited5> Уже имеет: app/346330 | BrainBread 2
<XLimited5> Уже имеет: app/1086690 | C-War 2
<XLimited5> Уже имеет: app/730 | Counter-Strike: Global Offensive
<XLimited5> Уже имеет: app/838380 | DEAD OR ALIVE 6
<XLimited5> Уже имеет: app/582890 | Estranged: The Departure
<XLimited5> Уже имеет: app/331470 | Everlasting Summer
<XLimited5> Уже имеет: app/1078000 | Gamecraft
<XLimited5> Уже имеет: app/266310 | GameGuru
<XLimited5> Уже имеет: app/275390 | Guacamelee! Super Turbo Championship Edition
<XLimited5> Уже имеет: app/627690 | Idle Champions of the Forgotten Realms
<XLimited5> Уже имеет: app/1048540 | Kao the Kangaroo: Round 2
<XLimited5> Уже имеет: app/370910 | Kathy Rain
<XLimited5> Уже имеет: app/343710 | KHOLAT
<XLimited5> Уже имеет: app/253900 | Knights and Merchants
<XLimited5> Уже имеет: app/224260 | No More Room in Hell
<XLimited5> Уже имеет: app/343360 | Particula
<XLimited5> Уже имеет: app/237870 | Planet Explorers
<XLimited5> Уже имеет: app/684680 | Polygoneer
<XLimited5> Уже имеет: app/1089130 | Quake II RTX
<XLimited5> Уже имеет: app/755790 | Ring of Elysium
<XLimited5> Уже имеет: app/1258080 | Shop Titans
<XLimited5> Уже имеет: app/759530 | Struckd - 3D Game Creator
<XLimited5> Уже имеет: app/269710 | Tumblestone
<XLimited5> Уже имеет: app/304930 | Unturned
<XLimited5> Уже имеет: app/1019250 | WWII TCG - World War 2: The Card Game
<ASF> 1/1 ботов уже имеют игру app/1493800 | Aircraft Carrier Survival: Prolouge.
<ASF> 1/1 ботов уже имеют игру app/349520 | Armillo.
<ASF> 1/1 ботов уже имеют игру app/346330 | BrainBread 2.
<ASF> 1/1 ботов уже имеют игру app/1086690 | C-War 2.
<ASF> 1/1 ботов уже имеют игру app/730 | Counter-Strike: Global Offensive.
<ASF> 1/1 ботов уже имеют игру app/838380 | DEAD OR ALIVE 6.
<ASF> 1/1 ботов уже имеют игру app/582890 | Estranged: The Departure.
<ASF> 1/1 ботов уже имеют игру app/331470 | Everlasting Summer.
<ASF> 1/1 ботов уже имеют игру app/1078000 | Gamecraft.
<ASF> 1/1 ботов уже имеют игру app/266310 | GameGuru.
<ASF> 1/1 ботов уже имеют игру app/275390 | Guacamelee! Super Turbo Championship Edition.
<ASF> 1/1 ботов уже имеют игру app/627690 | Idle Champions of the Forgotten Realms.
<ASF> 1/1 ботов уже имеют игру app/1048540 | Kao the Kangaroo: Round 2.
<ASF> 1/1 ботов уже имеют игру app/370910 | Kathy Rain.
<ASF> 1/1 ботов уже имеют игру app/343710 | KHOLAT.
<ASF> 1/1 ботов уже имеют игру app/253900 | Knights and Merchants.
<ASF> 1/1 ботов уже имеют игру app/224260 | No More Room in Hell.
<ASF> 1/1 ботов уже имеют игру app/343360 | Particula.
<ASF> 1/1 ботов уже имеют игру app/237870 | Planet Explorers.
<ASF> 1/1 ботов уже имеют игру app/684680 | Polygoneer.
<ASF> 1/1 ботов уже имеют игру app/1089130 | Quake II RTX.
<ASF> 1/1 ботов уже имеют игру app/755790 | Ring of Elysium.
<ASF> 1/1 ботов уже имеют игру app/1258080 | Shop Titans.
<ASF> 1/1 ботов уже имеют игру app/759530 | Struckd - 3D Game Creator.
<ASF> 1/1 ботов уже имеют игру app/269710 | Tumblestone.
<ASF> 1/1 ботов уже имеют игру app/304930 | Unturned.";
<ASF> 1/1 ботов уже имеют игру app/1493800 | Aircraft Carrier Survival: Prolouge.
<ASF> 1/1 ботов уже имеют игру app/349520 | Armillo.
<ASF> 1/1 ботов уже имеют игру app/346330 | BrainBread 2.
<ASF> 1/1 ботов уже имеют игру app/1086690 | C-War 2.
<ASF> 1/1 ботов уже имеют игру app/730 | Counter-Strike: Global Offensive.
<ASF> 1/1 ботов уже имеют игру app/838380 | DEAD OR ALIVE 6.
<ASF> 1/1 ботов уже имеют игру app/582890 | Estranged: The Departure.
<ASF> 1/1 ботов уже имеют игру app/331470 | Everlasting Summer.
<ASF> 1/1 ботов уже имеют игру app/1078000 | Gamecraft.
<ASF> 1/1 ботов уже имеют игру app/266310 | GameGuru.
<ASF> 1/1 ботов уже имеют игру app/275390 | Guacamelee! Super Turbo Championship Edition.
<ASF> 1/1 ботов уже имеют игру app/627690 | Idle Champions of the Forgotten Realms.
<ASF> 1/1 ботов уже имеют игру app/1048540 | Kao the Kangaroo: Round 2.
<ASF> 1/1 ботов уже имеют игру app/370910 | Kathy Rain.
<ASF> 1/1 ботов уже имеют игру app/343710 | KHOLAT.
<ASF> 1/1 ботов уже имеют игру app/253900 | Knights and Merchants.
<ASF> 1/1 ботов уже имеют игру app/224260 | No More Room in Hell.
<ASF> 1/1 ботов уже имеют игру app/343360 | Particula.
<ASF> 1/1 ботов уже имеют игру app/237870 | Planet Explorers.
<ASF> 1/1 ботов уже имеют игру app/684680 | Polygoneer.
<ASF> 1/1 ботов уже имеют игру app/1089130 | Quake II RTX.
<ASF> 1/1 ботов уже имеют игру app/755790 | Ring of Elysium.
<ASF> 1/1 ботов уже имеют игру app/1258080 | Shop Titans.
<ASF> 1/1 ботов уже имеют игру app/759530 | Struckd - 3D Game Creator.
<ASF> 1/1 ботов уже имеют игру app/269710 | Tumblestone.
<ASF> 1/1 ботов уже имеют игру app/304930 | Unturned.
""";
List<string> output = await GetMessageParts(message, prefix).ToListAsync().ConfigureAwait(false);

View file

@ -30,21 +30,21 @@ namespace ArchiSteamFarm.Tests;
public sealed class Trading {
[TestMethod]
public void ExploitingNewSetsIsFairButNotNeutral() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 40),
CreateItem(2, 10),
CreateItem(3, 10)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(2, 5),
CreateItem(3, 5)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(1, 9),
CreateItem(4)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -52,45 +52,45 @@ public sealed class Trading {
[TestMethod]
public void MismatchRarityIsNotFair() {
HashSet<Asset> itemsToGive = new() { CreateItem(1, rarity: Asset.ERarity.Rare) };
HashSet<Asset> itemsToReceive = new() { CreateItem(2) };
HashSet<Asset> itemsToGive = [CreateItem(1, rarity: Asset.ERarity.Rare)];
HashSet<Asset> itemsToReceive = [CreateItem(2)];
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
}
[TestMethod]
public void MismatchRealAppIDsIsNotFair() {
HashSet<Asset> itemsToGive = new() { CreateItem(1, realAppID: 570) };
HashSet<Asset> itemsToReceive = new() { CreateItem(2) };
HashSet<Asset> itemsToGive = [CreateItem(1, realAppID: 570)];
HashSet<Asset> itemsToReceive = [CreateItem(2)];
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
}
[TestMethod]
public void MismatchTypesIsNotFair() {
HashSet<Asset> itemsToGive = new() { CreateItem(1, type: Asset.EType.Emoticon) };
HashSet<Asset> itemsToReceive = new() { CreateItem(2) };
HashSet<Asset> itemsToGive = [CreateItem(1, type: Asset.EType.Emoticon)];
HashSet<Asset> itemsToReceive = [CreateItem(2)];
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
}
[TestMethod]
public void MultiGameMultiTypeBadReject() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 9),
CreateItem(3, 9, 730, Asset.EType.Emoticon),
CreateItem(4, realAppID: 730, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(4, realAppID: 730, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(2),
CreateItem(3, realAppID: 730, type: Asset.EType.Emoticon)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -98,20 +98,20 @@ public sealed class Trading {
[TestMethod]
public void MultiGameMultiTypeNeutralAccept() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 9),
CreateItem(3, realAppID: 730, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(3, realAppID: 730, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(2),
CreateItem(4, realAppID: 730, type: Asset.EType.Emoticon)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -119,21 +119,21 @@ public sealed class Trading {
[TestMethod]
public void MultiGameSingleTypeBadReject() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 9),
CreateItem(3, realAppID: 730),
CreateItem(4, realAppID: 730)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(3, realAppID: 730)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(2),
CreateItem(4, realAppID: 730)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -141,20 +141,20 @@ public sealed class Trading {
[TestMethod]
public void MultiGameSingleTypeNeutralAccept() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 2),
CreateItem(3, realAppID: 730)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(3, realAppID: 730)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(2),
CreateItem(4, realAppID: 730)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -162,21 +162,17 @@ public sealed class Trading {
[TestMethod]
public void SingleGameAbrynosWasWrongNeutralAccept() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1),
CreateItem(2, 2),
CreateItem(3),
CreateItem(4),
CreateItem(5)
};
];
HashSet<Asset> itemsToGive = new() {
CreateItem(2)
};
HashSet<Asset> itemsToGive = [CreateItem(2)];
HashSet<Asset> itemsToReceive = new() {
CreateItem(3)
};
HashSet<Asset> itemsToReceive = [CreateItem(3)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -184,18 +180,14 @@ public sealed class Trading {
[TestMethod]
public void SingleGameDonationAccept() {
HashSet<Asset> inventory = new() {
CreateItem(1)
};
HashSet<Asset> inventory = [CreateItem(1)];
HashSet<Asset> itemsToGive = new() {
CreateItem(1)
};
HashSet<Asset> itemsToGive = [CreateItem(1)];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(2),
CreateItem(3, type: Asset.EType.SteamGems)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -203,21 +195,21 @@ public sealed class Trading {
[TestMethod]
public void SingleGameMultiTypeBadReject() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 9),
CreateItem(3, 9, type: Asset.EType.Emoticon),
CreateItem(4, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(4, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(2),
CreateItem(3, type: Asset.EType.Emoticon)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -225,20 +217,20 @@ public sealed class Trading {
[TestMethod]
public void SingleGameMultiTypeNeutralAccept() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 9),
CreateItem(3, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(3, type: Asset.EType.Emoticon)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(2),
CreateItem(4, type: Asset.EType.Emoticon)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -246,19 +238,19 @@ public sealed class Trading {
[TestMethod]
public void SingleGameQuantityBadReject() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1),
CreateItem(2),
CreateItem(3)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(2),
CreateItem(3)
};
];
HashSet<Asset> itemsToReceive = new() { CreateItem(4, 3) };
HashSet<Asset> itemsToReceive = [CreateItem(4, 3)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -266,17 +258,17 @@ public sealed class Trading {
[TestMethod]
public void SingleGameQuantityBadReject2() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1),
CreateItem(2, 2)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(2, 2)
};
];
HashSet<Asset> itemsToReceive = new() { CreateItem(3, 3) };
HashSet<Asset> itemsToReceive = [CreateItem(3, 3)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -284,17 +276,17 @@ public sealed class Trading {
[TestMethod]
public void SingleGameQuantityNeutralAccept() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 2),
CreateItem(2)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(1),
CreateItem(2)
};
];
HashSet<Asset> itemsToReceive = new() { CreateItem(3, 2) };
HashSet<Asset> itemsToReceive = [CreateItem(3, 2)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -302,13 +294,13 @@ public sealed class Trading {
[TestMethod]
public void SingleGameSingleTypeBadReject() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1),
CreateItem(2)
};
];
HashSet<Asset> itemsToGive = new() { CreateItem(1) };
HashSet<Asset> itemsToReceive = new() { CreateItem(2) };
HashSet<Asset> itemsToGive = [CreateItem(1)];
HashSet<Asset> itemsToReceive = [CreateItem(2)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -316,18 +308,18 @@ public sealed class Trading {
[TestMethod]
public void SingleGameSingleTypeBadWithOverpayingReject() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 2),
CreateItem(2, 2),
CreateItem(3, 2)
};
];
HashSet<Asset> itemsToGive = new() { CreateItem(2) };
HashSet<Asset> itemsToGive = [CreateItem(2)];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(1),
CreateItem(3)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -335,14 +327,14 @@ public sealed class Trading {
[TestMethod]
public void SingleGameSingleTypeBigDifferenceAccept() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1),
CreateItem(2, 5),
CreateItem(3)
};
];
HashSet<Asset> itemsToGive = new() { CreateItem(2) };
HashSet<Asset> itemsToReceive = new() { CreateItem(3) };
HashSet<Asset> itemsToGive = [CreateItem(2)];
HashSet<Asset> itemsToReceive = [CreateItem(3)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -350,23 +342,23 @@ public sealed class Trading {
[TestMethod]
public void SingleGameSingleTypeBigDifferenceReject() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1),
CreateItem(2, 2),
CreateItem(3, 2),
CreateItem(4, 3),
CreateItem(5, 10)
};
];
HashSet<Asset> itemsToGive = new() {
HashSet<Asset> itemsToGive = [
CreateItem(2),
CreateItem(5)
};
];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(3),
CreateItem(4)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -374,9 +366,9 @@ public sealed class Trading {
[TestMethod]
public void SingleGameSingleTypeGoodAccept() {
HashSet<Asset> inventory = new() { CreateItem(1, 2) };
HashSet<Asset> itemsToGive = new() { CreateItem(1) };
HashSet<Asset> itemsToReceive = new() { CreateItem(2) };
HashSet<Asset> inventory = [CreateItem(1, 2)];
HashSet<Asset> itemsToGive = [CreateItem(1)];
HashSet<Asset> itemsToReceive = [CreateItem(2)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -384,9 +376,9 @@ public sealed class Trading {
[TestMethod]
public void SingleGameSingleTypeNeutralAccept() {
HashSet<Asset> inventory = new() { CreateItem(1) };
HashSet<Asset> itemsToGive = new() { CreateItem(1) };
HashSet<Asset> itemsToReceive = new() { CreateItem(2) };
HashSet<Asset> inventory = [CreateItem(1)];
HashSet<Asset> itemsToGive = [CreateItem(1)];
HashSet<Asset> itemsToReceive = [CreateItem(2)];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -394,17 +386,17 @@ public sealed class Trading {
[TestMethod]
public void SingleGameSingleTypeNeutralWithOverpayingAccept() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 2),
CreateItem(2, 2)
};
];
HashSet<Asset> itemsToGive = new() { CreateItem(2) };
HashSet<Asset> itemsToGive = [CreateItem(2)];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(1),
CreateItem(3)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@ -412,23 +404,23 @@ public sealed class Trading {
[TestMethod]
public void TakingExcessiveAmountOfSingleCardCanStillBeFairAndNeutral() {
HashSet<Asset> inventory = new() {
HashSet<Asset> inventory = [
CreateItem(1, 52),
CreateItem(2, 73),
CreateItem(3, 52),
CreateItem(4, 47),
CreateItem(5)
};
];
HashSet<Asset> itemsToGive = new() { CreateItem(2, 73) };
HashSet<Asset> itemsToGive = [CreateItem(2, 73)];
HashSet<Asset> itemsToReceive = new() {
HashSet<Asset> itemsToReceive = [
CreateItem(1, 9),
CreateItem(3, 9),
CreateItem(4, 8),
CreateItem(5, 24),
CreateItem(6, 23)
};
];
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));

View file

@ -189,6 +189,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceLockStatementBraces/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceUsingStatementBraces/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceWhileStatementBraces/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EntityFramework_002EModelValidation_002ECircularDependency/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ExtractCommonPropertyPattern/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator/@EntryIndexedValue">SUGGESTION</s:String>
@ -317,8 +318,9 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNullPropagation/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNullPropagationWhenPossible/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UsePositionalDeconstructionPattern/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseRawString/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseRawString/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseStringInterpolationWhenPossible/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseSymbolAlias/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseThrowIfNullMethod/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseVerbatimString/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UsingStatementResourceInitializationExpression/@EntryIndexedValue">SUGGESTION</s:String>

View file

@ -135,7 +135,7 @@ public sealed class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ISet<T> where
public void SymmetricExceptWith(IEnumerable<T> other) {
ISet<T> otherSet = other as ISet<T> ?? other.ToHashSet();
HashSet<T> removed = new();
HashSet<T> removed = [];
foreach (T item in otherSet.Where(Contains)) {
removed.Add(item);

View file

@ -41,7 +41,7 @@ internal sealed class ConcurrentList<T> : IList<T>, IReadOnlyList<T> {
}
}
private readonly List<T> BackingCollection = new();
private readonly List<T> BackingCollection = [];
private readonly AsyncReaderWriterLock Lock = new();
int ICollection<T>.Count => Count;

View file

@ -123,7 +123,7 @@ public static class Utilities {
switch (ASF.GlobalConfig?.OptimizationMode) {
case GlobalConfig.EOptimizationMode.MinMemoryUsage:
List<T> results = new();
List<T> results = [];
foreach (Task<T> task in tasks) {
results.Add(await task.ConfigureAwait(false));

View file

@ -36,7 +36,7 @@ public sealed class SwaggerValidValuesAttribute : CustomSwaggerAttribute {
public override void Apply(OpenApiSchema schema) {
ArgumentNullException.ThrowIfNull(schema);
OpenApiArray validValues = new();
OpenApiArray validValues = [];
if (ValidIntValues != null) {
validValues.AddRange(ValidIntValues.Select(static type => new OpenApiInteger(type)));

View file

@ -62,7 +62,7 @@ public sealed class TwoFactorAuthenticationConfirmationsRequest {
private set {
ArgumentNullException.ThrowIfNull(value);
HashSet<ulong> acceptedCreatorIDs = new();
HashSet<ulong> acceptedCreatorIDs = [];
foreach (string creatorIDText in value) {
if (!ulong.TryParse(creatorIDText, out ulong creatorID) || (creatorID == 0)) {

View file

@ -49,7 +49,7 @@ internal static class Logging {
internal static bool LogFileExists => File.Exists(SharedInfo.LogFile);
private static readonly ConcurrentHashSet<LoggingRule> ConsoleLoggingRules = new();
private static readonly ConcurrentHashSet<LoggingRule> ConsoleLoggingRules = [];
private static readonly SemaphoreSlim ConsoleSemaphore = new(1, 1);
private static string Backspace => "\b \b";

View file

@ -207,7 +207,7 @@ public static class PluginsCore {
return true;
}
HashSet<IPlugin> invalidPlugins = new();
HashSet<IPlugin> invalidPlugins = [];
foreach (IPlugin plugin in activePlugins) {
try {
@ -649,7 +649,7 @@ public static class PluginsCore {
return null;
}
HashSet<Assembly> assemblies = new();
HashSet<Assembly> assemblies = [];
try {
foreach (string assemblyPath in Directory.EnumerateFiles(path, "*.dll", SearchOption.AllDirectories)) {

View file

@ -165,7 +165,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
private readonly SemaphoreSlim RefreshWebSessionSemaphore = new(1, 1);
private readonly SemaphoreSlim SendCompleteTypesSemaphore = new(1, 1);
private readonly SteamClient SteamClient;
private readonly ConcurrentHashSet<ulong> SteamFamilySharingIDs = new();
private readonly ConcurrentHashSet<ulong> SteamFamilySharingIDs = [];
private readonly SteamUser SteamUser;
private readonly Trading Trading;
@ -524,7 +524,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
string[] botNames = args.Split(SharedInfo.ListElementSeparators, StringSplitOptions.RemoveEmptyEntries);
HashSet<Bot> result = new();
HashSet<Bot> result = [];
foreach (string botName in botNames) {
if (botName.Equals(SharedInfo.ASF, StringComparison.OrdinalIgnoreCase)) {
@ -659,7 +659,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
ArgumentOutOfRangeException.ThrowIfLessThan(maxItems, MinCardsPerBadge);
HashSet<Asset> result = new();
HashSet<Asset> result = [];
Dictionary<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity), Dictionary<ulong, HashSet<Asset>>> itemsPerClassIDPerSet = inventory.GroupBy(static item => (item.RealAppID, item.Type, item.Rarity)).ToDictionary(static grouping => grouping.Key, static grouping => grouping.GroupBy(static item => item.ClassID).ToDictionary(static group => group.Key, static group => group.ToHashSet()));
foreach (((uint RealAppID, Asset.EType Type, Asset.ERarity Rarity) set, (uint setsToExtract, byte itemsPerSet)) in amountsToExtract.OrderBy(static kv => kv.Value.ItemsPerSet)) {
@ -1281,7 +1281,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
throw new InvalidOperationException(nameof(ASF.GlobalDatabase));
}
HashSet<SteamApps.PICSRequest> packageRequests = new();
HashSet<SteamApps.PICSRequest> packageRequests = [];
foreach (uint packageID in packageIDs) {
if (!ASF.GlobalDatabase.PackageAccessTokensReadOnly.TryGetValue(packageID, out ulong packageAccessToken)) {
@ -1936,7 +1936,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
throw new ArgumentNullException(nameof(gamesToRedeemInBackground));
}
HashSet<object> invalidKeys = new();
HashSet<object> invalidKeys = [];
foreach (DictionaryEntry game in gamesToRedeemInBackground) {
bool invalid = false;
@ -2084,7 +2084,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
// Level 5 is maximum level for card badges according to https://steamcommunity.com/tradingcards/faq
IEnumerable<IAttr> linkElements = badgePage.SelectNodes<IAttr>("//a[@class='badge_craft_button']/@href | //div[@class='badges_sheet']/div[contains(@class, 'badge_row') and .//div[@class='badge_info_description']/div[contains(text(), 'Level 5')]]/a[@class='badge_row_overlay']/@href");
HashSet<uint> result = new();
HashSet<uint> result = [];
foreach (string badgeUri in linkElements.Select(static htmlNode => htmlNode.Value)) {
if (string.IsNullOrEmpty(badgeUri)) {
@ -3353,7 +3353,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
return;
}
HashSet<UserNotificationsCallback.EUserNotification> newPluginNotifications = new();
HashSet<UserNotificationsCallback.EUserNotification> newPluginNotifications = [];
foreach ((UserNotificationsCallback.EUserNotification notification, uint count) in callback.Notifications) {
bool newNotification;

View file

@ -86,7 +86,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable {
// More advanced calculation, the above AND hours required for bumps
uint cardsRemaining = 0;
List<float> totalHoursClocked = new();
List<float> totalHoursClocked = [];
foreach (Game gameToFarm in GamesToFarm) {
cardsRemaining += gameToFarm.CardsRemaining;
@ -119,11 +119,11 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable {
}
private readonly Bot Bot;
private readonly ConcurrentHashSet<Game> CurrentGamesFarming = new();
private readonly ConcurrentHashSet<Game> CurrentGamesFarming = [];
private readonly SemaphoreSlim EventSemaphore = new(1, 1);
private readonly SemaphoreSlim FarmingInitializationSemaphore = new(1, 1);
private readonly SemaphoreSlim FarmingResetSemaphore = new(0, 1);
private readonly ConcurrentList<Game> GamesToFarm = new();
private readonly ConcurrentList<Game> GamesToFarm = [];
private readonly Timer? IdleFarmingTimer;
private readonly ConcurrentDictionary<uint, DateTime> LocallyIgnoredAppIDs = new();
@ -723,7 +723,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable {
break;
default:
backgroundTasks ??= new HashSet<Task>();
backgroundTasks ??= [];
backgroundTasks.Add(task);
@ -1141,7 +1141,7 @@ public sealed class CardsFarmer : IAsyncDisposable, IDisposable {
GamesToFarm.Clear();
ConcurrentHashSet<uint> parsedAppIDs = new();
ConcurrentHashSet<uint> parsedAppIDs = [];
Task mainTask = CheckPage(htmlDocument, parsedAppIDs);

View file

@ -36,8 +36,8 @@ public sealed class TradeOffer {
[PublicAPI]
public IReadOnlyCollection<Asset> ItemsToReceiveReadOnly => ItemsToReceive;
internal readonly HashSet<Asset> ItemsToGive = new();
internal readonly HashSet<Asset> ItemsToReceive = new();
internal readonly HashSet<Asset> ItemsToGive = [];
internal readonly HashSet<Asset> ItemsToReceive = [];
[PublicAPI]
public ulong OtherSteamID64 { get; private set; }

View file

@ -33,6 +33,6 @@ internal sealed class TradeOfferSendRequest {
internal sealed class ItemList {
[JsonProperty("assets", Required = Required.Always)]
internal readonly HashSet<Asset> Assets = new();
internal readonly HashSet<Asset> Assets = [];
}
}

View file

@ -44,7 +44,7 @@ public sealed class Trading : IDisposable {
internal const byte MaxTradesPerAccount = 5; // This is limit introduced by Valve
private readonly Bot Bot;
private readonly ConcurrentHashSet<ulong> HandledTradeOfferIDs = new();
private readonly ConcurrentHashSet<ulong> HandledTradeOfferIDs = [];
private readonly SemaphoreSlim TradesSemaphore = new(1, 1);
private bool ParsingScheduled;
@ -128,7 +128,7 @@ public sealed class Trading : IDisposable {
// This loop is a bit more complex due to the fact that we might have a mix of the same item splitted into different amounts
foreach (Asset itemToGive in itemsToGive) {
uint amountToGive = itemToGive.Amount;
HashSet<Asset> itemsToRemove = new();
HashSet<Asset> itemsToRemove = [];
// Keep in mind that ClassID is unique only within appID scope - we can do it like this because we're not dealing with non-Steam items here (otherwise we'd need to check appID too)
foreach (Asset item in inventory.Where(item => item.ClassID == itemToGive.ClassID)) {
@ -258,7 +258,7 @@ public sealed class Trading : IDisposable {
throw new ArgumentNullException(nameof(classIDs));
}
HashSet<Asset> result = new();
HashSet<Asset> result = [];
IEnumerable<Asset> items = inventory.Where(static item => item.Tradable);

View file

@ -197,7 +197,7 @@ public sealed class ArchiWebHandler : IDisposable {
return null;
}
HashSet<uint> result = new();
HashSet<uint> result = [];
IEnumerable<IAttr> linkNodes = response.Content.SelectNodes<IAttr>("//li[@class='booster_eligibility_game']/a/@href");
@ -353,11 +353,7 @@ public sealed class ArchiWebHandler : IDisposable {
(ulong ClassID, ulong InstanceID) key = (description.ClassID, description.InstanceID);
if (descriptions.ContainsKey(key)) {
continue;
}
descriptions[key] = description;
descriptions.TryAdd(key, description);
}
foreach (Asset asset in response.Content.Assets) {
@ -593,7 +589,7 @@ public sealed class ArchiWebHandler : IDisposable {
trades = trades.Concat(response["trade_offers_sent"].Children);
}
HashSet<TradeOffer> result = new();
HashSet<TradeOffer> result = [];
foreach (KeyValue trade in trades) {
ETradeOfferState state = trade["trade_offer_state"].AsEnum<ETradeOfferState>();
@ -679,7 +675,7 @@ public sealed class ArchiWebHandler : IDisposable {
ArgumentOutOfRangeException.ThrowIfZero(itemsPerTrade);
TradeOfferSendRequest singleTrade = new();
HashSet<TradeOfferSendRequest> trades = new() { singleTrade };
HashSet<TradeOfferSendRequest> trades = [singleTrade];
if (itemsToGive != null) {
foreach (Asset itemToGive in itemsToGive) {
@ -1906,7 +1902,7 @@ public sealed class ArchiWebHandler : IDisposable {
IEnumerable<IAttr> htmlNodes = response.Content.SelectNodes<IAttr>("//div[@class='pending_gift']/div[starts-with(@id, 'pending_gift_')][count(div[@class='pending_giftcard_leftcol']) > 0]/@id");
HashSet<ulong> results = new();
HashSet<ulong> results = [];
foreach (string giftCardIDText in htmlNodes.Select(static htmlNode => htmlNode.Value)) {
if (string.IsNullOrEmpty(giftCardIDText)) {
@ -1952,7 +1948,7 @@ public sealed class ArchiWebHandler : IDisposable {
IEnumerable<IAttr> htmlNodes = response.Content.SelectNodes<IAttr>("(//table[@class='accountTable'])[2]//a/@data-miniprofile");
HashSet<ulong> result = new();
HashSet<ulong> result = [];
foreach (string miniProfile in htmlNodes.Select(static htmlNode => htmlNode.Value)) {
if (string.IsNullOrEmpty(miniProfile)) {

View file

@ -47,7 +47,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable {
private static readonly SemaphoreSlim GiftCardsSemaphore = new(1, 1);
private readonly Bot Bot;
private readonly ConcurrentHashSet<ulong> HandledGifts = new();
private readonly ConcurrentHashSet<ulong> HandledGifts = [];
private readonly SemaphoreSlim TradingSemaphore = new(1, 1);
private Timer? CardsFarmerResumeTimer;

View file

@ -532,7 +532,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.Response2FA(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -574,7 +574,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.Response2FAConfirm(GetProxyAccess(bot, access, steamID), confirm))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -678,7 +678,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAddLicense(GetProxyAccess(bot, access, steamID), query))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -729,7 +729,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAdvancedLoot(GetProxyAccess(bot, access, steamID), appID, contextID))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -821,7 +821,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAdvancedRedeem(GetProxyAccess(bot, access, steamID), options, keys, steamID))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -910,7 +910,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseAdvancedTransfer(GetProxyAccess(bot, access, steamID), appID, contextID, targetBot))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -944,7 +944,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseBackgroundGamesRedeemer(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1021,7 +1021,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseFarm(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1049,7 +1049,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingBlacklist(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1071,7 +1071,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<uint> appIDs = new();
HashSet<uint> appIDs = [];
foreach (string target in targets) {
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
@ -1113,7 +1113,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingBlacklistAdd(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1135,7 +1135,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<uint> appIDs = new();
HashSet<uint> appIDs = [];
foreach (string target in targets) {
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
@ -1172,7 +1172,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingBlacklistRemove(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1200,7 +1200,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingQueue(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1222,7 +1222,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<uint> appIDs = new();
HashSet<uint> appIDs = [];
foreach (string target in targets) {
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
@ -1271,7 +1271,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingQueueAdd(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1293,7 +1293,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<uint> appIDs = new();
HashSet<uint> appIDs = [];
foreach (string target in targets) {
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
@ -1335,7 +1335,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseFarmingQueueRemove(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1413,7 +1413,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseInput(GetProxyAccess(bot, access, steamID), propertyName, inputValue)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1451,7 +1451,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseLevel(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1493,7 +1493,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseLoot(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1523,7 +1523,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(appIDTexts)));
}
HashSet<uint> realAppIDs = new();
HashSet<uint> realAppIDs = [];
foreach (string appIDText in appIDTexts) {
if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) {
@ -1554,7 +1554,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseLootByRealAppIDs(GetProxyAccess(bot, access, steamID), realAppIDsText, exclude))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1582,7 +1582,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseMatchActivelyBlacklist(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1604,7 +1604,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<uint> appIDs = new();
HashSet<uint> appIDs = [];
foreach (string target in targets) {
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
@ -1633,7 +1633,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseMatchActivelyBlacklistAdd(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1655,7 +1655,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<uint> appIDs = new();
HashSet<uint> appIDs = [];
foreach (string target in targets) {
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
@ -1684,7 +1684,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseMatchActivelyBlacklistRemove(GetProxyAccess(bot, access, steamID), targetAppIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1728,7 +1728,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseNickname(GetProxyAccess(bot, access, steamID), nickname)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -1896,7 +1896,7 @@ public sealed class Commands {
IList<(string? Response, Dictionary<string, string>? OwnedGames)> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseOwns(GetProxyAccess(bot, access, steamID), query))).ConfigureAwait(false);
List<(string Response, Dictionary<string, string> OwnedGames)> validResults = new(results.Where(static result => !string.IsNullOrEmpty(result.Response) && (result.OwnedGames != null))!);
List<(string Response, Dictionary<string, string> OwnedGames)> validResults = [..results.Where(static result => !string.IsNullOrEmpty(result.Response) && (result.OwnedGames != null))];
if (validResults.Count == 0) {
return null;
@ -1962,7 +1962,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePause(GetProxyAccess(bot, access, steamID), permanent, resumeInSecondsText))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2052,7 +2052,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePlay(GetProxyAccess(bot, access, steamID), targetGameIDs))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2090,7 +2090,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePointsBalance(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2243,7 +2243,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponsePrivacy(GetProxyAccess(bot, access, steamID), privacySettingsText))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2285,8 +2285,8 @@ public sealed class Commands {
HashSet<string> pendingKeys = keys.ToHashSet(StringComparer.Ordinal);
HashSet<string> unusedKeys = pendingKeys.ToHashSet(StringComparer.Ordinal);
HashSet<Bot> rateLimitedBots = new();
HashSet<Bot> triedBots = new();
HashSet<Bot> rateLimitedBots = [];
HashSet<Bot> triedBots = [];
StringBuilder response = new();
@ -2523,7 +2523,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseRedeem(GetProxyAccess(bot, access, steamID), keysText, steamID, redeemFlags))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2561,7 +2561,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseReset(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2609,7 +2609,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseResume(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2643,7 +2643,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseStart(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2720,7 +2720,7 @@ public sealed class Commands {
IList<(string? Response, Bot Bot)> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseStatus(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<(string Response, Bot Bot)> validResults = new(results.Where(static result => !string.IsNullOrEmpty(result.Response))!);
List<(string Response, Bot Bot)> validResults = [..results.Where(static result => !string.IsNullOrEmpty(result.Response))];
if (validResults.Count == 0) {
return null;
@ -2762,7 +2762,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseStop(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2790,7 +2790,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseTradingBlacklist(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2812,7 +2812,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<ulong> targetIDs = new();
HashSet<ulong> targetIDs = [];
foreach (string target in targets) {
if (!ulong.TryParse(target, out ulong targetID) || (targetID == 0) || !new SteamID(targetID).IsIndividualAccount) {
@ -2841,7 +2841,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseTradingBlacklistAdd(GetProxyAccess(bot, access, steamID), targetSteamIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2863,7 +2863,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(targets)));
}
HashSet<ulong> targetIDs = new();
HashSet<ulong> targetIDs = [];
foreach (string target in targets) {
if (!ulong.TryParse(target, out ulong targetID) || (targetID == 0) || !new SteamID(targetID).IsIndividualAccount) {
@ -2892,7 +2892,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseTradingBlacklistRemove(GetProxyAccess(bot, access, steamID), targetSteamIDs)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -2951,7 +2951,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseTransfer(GetProxyAccess(bot, access, steamID), botNameTo))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -3016,7 +3016,7 @@ public sealed class Commands {
return FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(appIDTexts)));
}
HashSet<uint> realAppIDs = new();
HashSet<uint> realAppIDs = [];
foreach (string appIDText in appIDTexts) {
if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) {
@ -3050,7 +3050,7 @@ public sealed class Commands {
return FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(appIDTexts)));
}
HashSet<uint> realAppIDs = new();
HashSet<uint> realAppIDs = [];
foreach (string appIDText in appIDTexts) {
if (!uint.TryParse(appIDText, out uint appID) || (appID == 0)) {
@ -3068,7 +3068,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseTransferByRealAppIDs(GetProxyAccess(bot, access, steamID), realAppIDs, targetBot, exclude))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -3132,7 +3132,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseUnpackBoosters(GetProxyAccess(bot, access, steamID)))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
@ -3194,7 +3194,7 @@ public sealed class Commands {
IList<string?> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseWalletBalance(GetProxyAccess(bot, access, steamID))))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
List<string> responses = [..results.Where(static result => !string.IsNullOrEmpty(result))];
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}

View file

@ -31,7 +31,7 @@ namespace ArchiSteamFarm.Steam.SteamKit2;
internal sealed class InMemoryServerListProvider : IServerListProvider {
[JsonProperty(Required = Required.DisallowNull)]
private readonly ConcurrentHashSet<ServerRecordEndPoint> ServerRecords = new();
private readonly ConcurrentHashSet<ServerRecordEndPoint> ServerRecords = [];
public Task<IEnumerable<ServerRecord>> FetchServerListAsync() => Task.FromResult(ServerRecords.Where(static server => !string.IsNullOrEmpty(server.Host) && server is { Port: > 0, ProtocolTypes: > 0 }).Select(static server => ServerRecord.CreateServer(server.Host, server.Port, server.ProtocolTypes)));

View file

@ -38,22 +38,22 @@ namespace ArchiSteamFarm.Steam.Storage;
public sealed class BotDatabase : GenericDatabase {
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ConcurrentHashSet<uint> FarmingBlacklistAppIDs = new();
internal readonly ConcurrentHashSet<uint> FarmingBlacklistAppIDs = [];
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ConcurrentHashSet<uint> FarmingPriorityQueueAppIDs = new();
internal readonly ConcurrentHashSet<uint> FarmingPriorityQueueAppIDs = [];
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ObservableConcurrentDictionary<uint, DateTime> FarmingRiskyIgnoredAppIDs = new();
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ConcurrentHashSet<uint> FarmingRiskyPrioritizedAppIDs = new();
internal readonly ConcurrentHashSet<uint> FarmingRiskyPrioritizedAppIDs = [];
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ConcurrentHashSet<uint> MatchActivelyBlacklistAppIDs = new();
internal readonly ConcurrentHashSet<uint> MatchActivelyBlacklistAppIDs = [];
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ConcurrentHashSet<ulong> TradingBlacklistSteamIDs = new();
internal readonly ConcurrentHashSet<ulong> TradingBlacklistSteamIDs = [];
internal uint GamesToRedeemInBackgroundCount {
get {

View file

@ -21,6 +21,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Helpers;
using JetBrains.Annotations;
@ -48,7 +49,7 @@ public abstract class GenericDatabase : SerializableFile {
public JToken? LoadFromJsonStorage(string key) {
ArgumentException.ThrowIfNullOrEmpty(key);
return KeyValueJsonStorage.TryGetValue(key, out JToken? value) ? value : null;
return KeyValueJsonStorage.GetValueOrDefault(key);
}
[PublicAPI]

View file

@ -47,7 +47,7 @@ public sealed class GlobalDatabase : GenericDatabase {
public IReadOnlyDictionary<uint, PackageData> PackagesDataReadOnly => PackagesData;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ConcurrentHashSet<ulong> CachedBadBots = new();
internal readonly ConcurrentHashSet<ulong> CachedBadBots = [];
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ObservableConcurrentDictionary<uint, byte> CardCountsPerGame = new();
@ -192,7 +192,7 @@ public sealed class GlobalDatabase : GenericDatabase {
ArgumentOutOfRangeException.ThrowIfZero(appID);
ArgumentNullException.ThrowIfNull(packageIDs);
HashSet<uint> result = new();
HashSet<uint> result = [];
foreach (uint packageID in packageIDs.Where(static packageID => packageID != 0)) {
if (!PackagesData.TryGetValue(packageID, out PackageData? packageEntry) || (packageEntry.AppIDs?.Contains(appID) != true)) {

View file

@ -156,7 +156,7 @@ internal static class GitHub {
ArgumentException.ThrowIfNullOrEmpty(markdownText);
MarkdownDocument markdownDocument = Markdown.Parse(markdownText);
MarkdownDocument result = new();
MarkdownDocument result = [];
foreach (Block block in markdownDocument.SkipWhile(static block => block is not HeadingBlock { Inline.FirstChild: LiteralInline literalInline } || (literalInline.Content.ToString()?.Equals("Changelog", StringComparison.OrdinalIgnoreCase) != true)).Skip(1).TakeWhile(static block => block is not ThematicBreakBlock).ToList()) {
// All blocks that we're interested in must be removed from original markdownDocument firstly