Repository navigation
Release 1.3.1 - #259
Merged
Merged
Release 1.3.1#259
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.
A style sheet nesting blocks deeply ended the process with a stack overflow, which no caller can catch: the parser recurses once per level of @media, @supports, @layer, @container, @scope and nested style rules. On a 256 KB thread stack, about 125 nested @media rules were enough (.NET 8, before the JIT optimizes); on a 1 MB stack about 580. - Add CssParserOptions.MaxNestingDepth (default 64). A rule nested in more blocks is dropped like an invalid rule, raising the new CssParseError.NestingTooDeep, and parsing continues after it - Add tests at depths that crashed before and at the limit, parsing on a 256 KB thread stack; with a default of 128 the test host crashes - Add a benchmark parsing nested @media and nested style rules This is a mitigation, not a fix: parsing still recurses once per level, and only the limit stops it. Raising the limit brings the crash back.
Adopt AngleSharp 1.9 and make the library trim and Native AOT compatible
Limit how deep the parser nests rules
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
This pull request introduces several important improvements and updates for the
AngleSharp.Csslibrary, focusing on enhanced parser safety, modern dependency support, trimming and Native AOT compatibility, and improved test coverage. It also updates documentation and CI workflows to reflect these changes.These changes collectively improve the reliability, maintainability, and modern .NET compatibility of the library.