Repository navigation
Adopt AngleSharp 1.9 and make the library trim and Native AOT compatible - #257
Merged
FlorianRappl merged 1 commit intoNov 1, 2026
Merged
Conversation
- Require AngleSharp 1.9.0 (csproj default and CI), which the trim-safe ToDictionary<T> below needs - Mark the net8.0 and net10.0 targets IsAotCompatible, so the trim and AOT analyzers run on every build, with the same KnownILLinkPack override as AngleSharp and AngleSharp.Xml - Add a generic Css<T, TProperties> overload whose type parameter is annotated so the trimmer keeps its public properties. The Object overload stays, marked Obsolete and RequiresUnreferencedCode, so code compiled against it keeps working; on a recompile a call with an anonymous object binds to the generic overload, and a dictionary is copied rather than reflected over - Add internal copies of DynamicallyAccessedMembersAttribute and RequiresUnreferencedCodeAttribute for the targets whose BCL predates them - Add tests for Css with an anonymous object, a dictionary and a value declared as Object - Update AGENTS.md The package keeps its target frameworks and its dependencies apart from the AngleSharp minimum. Apps on net462, net472, net6.0, net7.0, net8.0 and net10.0 and a netstandard2.0 library build against the packed package without warnings and run correctly, and a console app published with PublishAot compiles with no trim or AOT warnings.
This was referenced Nov 2, 2026
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of Changes
Prerequisites
Please make sure you can check the following two boxes:
Contribution Type
What types of changes does your code introduce? Put an
xin all the boxes that apply:Description
The AngleSharp.Css counterpart of AngleSharp #1398 and AngleSharp.Xml #38: AngleSharp 1.9 as the minimum, and the library marked trim and Native AOT compatible. There is no separate issue.
Cssoverload below needs AngleSharp's genericToDictionary<T>, which came with 1.9.0. With 1.9.0, the old call toToDictionary(Object)is obsolete, so the bump alone would not build (warnings are errors).IsAotCompatibleon thenet8.0andnet10.0targets, with the sameKnownILLinkPackoverride as AngleSharp and AngleSharp.Xml. The analyzers flagged one place:Css(Object), which reads the properties of the value's runtime type.Css<T, TProperties>overload, with the type parameter annotated so the trimmer keeps its public properties. It followsAttr<T, TAttributes>in AngleSharp:Objectoverload stays, markedObsoleteandRequiresUnreferencedCode, so code compiled against it keeps working;DynamicallyAccessedMembersAttributeandRequiresUnreferencedCodeAttributefor the targets whose BCL predates them, as in AngleSharp.Csswith an anonymous object, a dictionary and a value declared asObject.Checked
netstandard2.0,net462,net472,net8.0,net10.0) and its dependencies; only the AngleSharp minimum changes.PublishAotagainst the library compiles with no trim or AOT warnings and runs correctly.Suggested CHANGELOG lines
I left
CHANGELOG.mdout so you can word them; suggestion:Cssoverload; theObjectoverload is obsolete (#PR) @michaelthyregod🤖 Generated with Claude Code