Skip to content

Commit 5661951

Browse files
chore(deps): update dependency anglesharp to 1.3.1 (#3507)
* chore(deps): update dependency anglesharp to 1.3.1 * Resolve new warnings --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Łukasz Domeradzki <[email protected]>
1 parent b872340 commit 5661951

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

ArchiSteamFarm/Steam/Bot.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,12 @@ public static HashSet<Asset> GetItemsForFullSets(IReadOnlyCollection<Asset> inve
756756

757757
byte maxPages = 1;
758758

759-
IElement? htmlNode = badgePage.QuerySelectorAll("a[class='pagelink']").LastOrDefault();
759+
IHtmlCollection<IElement> pageLinkNodes = badgePage.QuerySelectorAll("a[class='pagelink']");
760760

761-
if (htmlNode != null) {
762-
string lastPage = htmlNode.TextContent;
761+
if (pageLinkNodes.Count > 0) {
762+
IElement lastPageLinkNode = pageLinkNodes[^1];
763+
764+
string lastPage = lastPageLinkNode.TextContent;
763765

764766
if (string.IsNullOrEmpty(lastPage)) {
765767
ArchiLogger.LogNullError(lastPage);

ArchiSteamFarm/Steam/Cards/CardsFarmer.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,14 @@ private async Task CheckPage(IParentNode badgePage, ISet<uint> parsedAppIDs, IRe
500500
continue;
501501
}
502502

503+
if (statsNode == null) {
504+
Bot.ArchiLogger.LogNullError(statsNode);
505+
506+
continue;
507+
}
508+
503509
// Cards
504-
IElement? progressNode = statsNode?.QuerySelector("span[class='progress_info_bold']");
510+
IElement? progressNode = statsNode.QuerySelector("span[class='progress_info_bold']");
505511

506512
if (progressNode == null) {
507513
Bot.ArchiLogger.LogNullError(progressNode);
@@ -540,7 +546,7 @@ private async Task CheckPage(IParentNode badgePage, ISet<uint> parsedAppIDs, IRe
540546
}
541547

542548
// To save us on extra work, check cards earned so far first
543-
IElement? cardsEarnedNode = statsNode?.QuerySelector("div[class='card_drop_info_header']");
549+
IElement? cardsEarnedNode = statsNode.QuerySelector("div[class='card_drop_info_header']");
544550

545551
if (cardsEarnedNode == null) {
546552
Bot.ArchiLogger.LogNullError(cardsEarnedNode);
@@ -585,7 +591,7 @@ private async Task CheckPage(IParentNode badgePage, ISet<uint> parsedAppIDs, IRe
585591
}
586592

587593
// Hours
588-
IElement? timeNode = statsNode?.QuerySelector("div[class='badge_title_stats_playtime']");
594+
IElement? timeNode = statsNode.QuerySelector("div[class='badge_title_stats_playtime']");
589595

590596
if (timeNode == null) {
591597
Bot.ArchiLogger.LogNullError(timeNode);
@@ -619,15 +625,17 @@ private async Task CheckPage(IParentNode badgePage, ISet<uint> parsedAppIDs, IRe
619625
}
620626

621627
// Names
622-
IElement? nameNode = statsNode?.QuerySelectorAll("div[class='card_drop_info_body']").LastOrDefault();
628+
IHtmlCollection<IElement> cardDropInfoNodes = statsNode.QuerySelectorAll("div[class='card_drop_info_body']");
623629

624-
if (nameNode == null) {
625-
Bot.ArchiLogger.LogNullError(nameNode);
630+
if (cardDropInfoNodes.Count == 0) {
631+
Bot.ArchiLogger.LogNullError(cardDropInfoNodes);
626632

627633
continue;
628634
}
629635

630-
string name = nameNode.TextContent;
636+
IElement lastCardDropInfoNode = cardDropInfoNodes[^1];
637+
638+
string name = lastCardDropInfoNode.TextContent;
631639

632640
if (string.IsNullOrEmpty(name)) {
633641
Bot.ArchiLogger.LogNullError(name);
@@ -1028,16 +1036,18 @@ private async Task<bool> FarmSolo(Game game) {
10281036
return null;
10291037
}
10301038

1031-
IElement? nameNode = htmlDocument.QuerySelectorAll("span[class='profile_small_header_location']").LastOrDefault();
1039+
IHtmlCollection<IElement> profileHeaderNodes = htmlDocument.QuerySelectorAll("span[class='profile_small_header_location']");
10321040

1033-
if (nameNode == null) {
1041+
if (profileHeaderNodes.Count == 0) {
10341042
// Normally we should log null error here, but here's why we don't: https://www.youtube.com/watch?v=nSKp2StlS6s&t=40s
1035-
Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorIsInvalid(nameof(nameNode)));
1043+
Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorIsInvalid(nameof(profileHeaderNodes)));
10361044

10371045
return null;
10381046
}
10391047

1040-
string name = nameNode.TextContent.Trim();
1048+
IElement lastProfileHeaderNode = profileHeaderNodes[^1];
1049+
1050+
string name = lastProfileHeaderNode.TextContent.Trim();
10411051

10421052
if (string.IsNullOrEmpty(name)) {
10431053
Bot.ArchiLogger.LogNullError(name);
@@ -1163,10 +1173,12 @@ private async Task<bool> FarmSolo(Game game) {
11631173

11641174
byte maxPages = 1;
11651175

1166-
IElement? htmlNode = htmlDocument.QuerySelectorAll("a[class='pagelink']").LastOrDefault();
1176+
IHtmlCollection<IElement> pageLinkNodes = htmlDocument.QuerySelectorAll("a[class='pagelink']");
1177+
1178+
if (pageLinkNodes.Count > 0) {
1179+
IElement lastPageLinkNode = pageLinkNodes[^1];
11671180

1168-
if (htmlNode != null) {
1169-
string lastPage = htmlNode.TextContent;
1181+
string lastPage = lastPageLinkNode.TextContent;
11701182

11711183
if (string.IsNullOrEmpty(lastPage)) {
11721184
Bot.ArchiLogger.LogNullError(lastPage);

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<ItemGroup>
3-
<PackageVersion Include="AngleSharp" Version="1.3.0" />
3+
<PackageVersion Include="AngleSharp" Version="1.3.1" />
44
<PackageVersion Include="CryptSharpStandard" Version="1.0.0" />
55
<PackageVersion Include="Humanizer" Version="3.0.0-rc.30" />
66
<PackageVersion Include="JetBrains.Annotations.Sources" Version="2025.2.2" />

0 commit comments

Comments
 (0)