Skip to content

Read the diff:match result without the IHtmlCollection indexer - #62

Open
michaelthyregod wants to merge 2 commits into
AngleSharp:develfrom
michaelthyregod:fix/diff-match-indexer
Open

michaelthyregod wants to merge 2 commits into
AngleSharp:develfrom
michaelthyregod:fix/diff-match-indexer

Conversation

@michaelthyregod

Copy link
Copy Markdown

Types of Changes

Prerequisites

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

diff:match throws on .NET 8 and later when AngleSharp 1.3.1 or newer is used:

System.MissingMethodException: Method not found: '!0 AngleSharp.Dom.IHtmlCollection`1.get_Item(Int32)'.

Since 1.3.1 (AngleSharp#1226) the .NET 8 build of IHtmlCollection<T> takes its indexer from IReadOnlyList<T>, so the call compiled into this netstandard2.0 library no longer exists at runtime.

  • CssSelectorElementMatcher reads its single match with First() instead of the indexer, which works on every AngleSharp version. The minimum stays at 1.1.2.
  • The test project runs on AngleSharp 1.10.0, so the existing CssSelectorElementMatcherTest tests cover it: without the fix 3 of them fail there. 557/557 pass on 1.10.0 and on 1.1.2.

Suggested CHANGELOG line, for whichever heading you open:

  • Improved diff:match to work with AngleSharp 1.3.1 and later on .NET 8+ (#PR) @michaelthyregod

🤖 Generated with Claude Code

From AngleSharp 1.3.1 the .NET 8 build of IHtmlCollection<T> takes its
indexer from IReadOnlyList<T>, so the netstandard2.0 build of this library
threw MissingMethodException for diff:match on .NET 8 and later.
The library keeps its minimum; the tests run on a version whose .NET 8
build differs from the netstandard2.0 one, which catches the diff:match
break.
@CLAassistant

CLAassistant commented Nov 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@michaelthyregod

Copy link
Copy Markdown
Author

The cause is also being fixed in AngleSharp itself: AngleSharp/AngleSharp#1410 declares the indexers on every target again. This PR is still needed for AngleSharp 1.3.1 through 1.10.x, which are already released.

@michaelthyregod

Copy link
Copy Markdown
Author

Update: AngleSharp/AngleSharp#1410 was declined (no breaking changes in core), so this PR is the fix for diff:match. I checked the rest of the library for integer indexers on IHtmlCollection, IStringList and ITokenList; this was the only one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants