This guide helps coding agents become productive quickly in the AngleSharp.Css repository.
- AngleSharp.Css is the CSS extension package for AngleSharp.
- It provides CSS parsing, CSSOM objects, declaration/value conversion, stylesheet integration, and render tree support.
- Main code lives in
src/AngleSharp.Css. - Tests live in
src/AngleSharp.Css.Tests.
From repository root:
# Full build + unit tests through Fallout (Linux/macOS)
./build.sh
# Full build + unit tests through Fallout (Windows PowerShell)
./build.ps1
# Run tests directly
dotnet test src/AngleSharp.Css.Tests/AngleSharp.Css.Tests.csproj
# Build solution directly
dotnet build src/AngleSharp.Css.sln
# Run CSS performance benchmark (Release)
dotnet run --project src/AngleSharp.Performance.Css/AngleSharp.Performance.Css.csproj -c Release --framework net10.0
# Short benchmark smoke run
dotnet run --project src/AngleSharp.Performance.Css/AngleSharp.Performance.Css.csproj -c Release --framework net10.0 -- --job shortNotes:
- CI invokes
./build.sh -AngleSharpVersion 1.5.0on Linux and./build.ps1on Windows. - Treat warnings as errors is enabled in
src/Directory.Build.props.
- Library project:
src/AngleSharp.Css/AngleSharp.Css.csproj- Targets:
netstandard2.0;net8.0;net10.0 - Additional Windows-only targets:
net462;net472
- Targets:
- Test project:
src/AngleSharp.Css.Tests/AngleSharp.Css.Tests.csproj- Targets:
net8.0
- Targets:
- Fallout entrypoint:
build/Build.cs- Default target chain runs unit tests.
-
src/AngleSharp.Css/Parser- Front-end parser (
CssParser), tokenizer, builder, and micro parsers. - If parsing/tokenization behavior changes, start here.
- Front-end parser (
-
src/AngleSharp.Css/Declarations- One static class per declaration (name, converter, initial value, flags).
- Example pattern:
DisplayDeclaration.cs.
-
src/AngleSharp.Css/Factories/DefaultDeclarationFactory.cs- Central registration table that wires declaration metadata.
- New declaration support usually needs an entry here.
-
src/AngleSharp.Css/ValueConverters.csandsrc/AngleSharp.Css/Converters- Converter composition and reusable converter building blocks.
- New value grammar often starts with a converter addition or composition.
-
src/AngleSharp.Css/Values- CSS value object model (primitives, composites, function values, tuples/lists).
-
src/AngleSharp.Css/Domandsrc/AngleSharp.Css/Dom/Internal- Public CSSOM interfaces/enums and internal implementations of rules, declarations, and sheets.
-
src/AngleSharp.Css/Constants- Canonical names and keyword constants (
PropertyNames,RuleNames,CssKeywords, etc.).
- Canonical names and keyword constants (
-
src/AngleSharp.Css/RenderTree- Render tree construction and render node/value computation.
-
src/AngleSharp.Css/FeatureValidators- Validators used for media feature / supports-style checks.
-
src/AngleSharp.Css.Tests- Test suites grouped by concern: declarations, rules, parsing, values, styling, extensions.
- Add or update declaration metadata class in
src/AngleSharp.Css/Declarations. - Ensure canonical property name exists in
src/AngleSharp.Css/Constants/PropertyNames.cs. - Wire declaration in
src/AngleSharp.Css/Factories/DefaultDeclarationFactory.cs. - Add tests in
src/AngleSharp.Css.Tests/Declarationsand/or related top-level declaration test files. - Validate computed/style integration with tests in
src/AngleSharp.Css.Tests/Stylingwhen behavior impacts cascade/computation.
- Extend converter composition in
src/AngleSharp.Css/ValueConverters.csand/or converter implementations insrc/AngleSharp.Css/Converters. - Add/update specific value objects in
src/AngleSharp.Css/Valuesif needed. - If grammar requires function or token-level parser support, update
src/AngleSharp.Css/Parser/Micro. - Add tests under
src/AngleSharp.Css.Tests/Valuesand declaration tests that consume the grammar.
- Public contract changes in
src/AngleSharp.Css/Dominterfaces. - Implementation changes in
src/AngleSharp.Css/Dom/Internal/Rules. - Parser/builder adjustments in
src/AngleSharp.Css/Parser. - Rule-focused tests in
src/AngleSharp.Css.Tests/Rules.
- Update computation/building in
src/AngleSharp.Css/RenderTree. - Confirm integration in
src/AngleSharp.Css/Extensions/WindowExtensions.csand styling flows. - Add or update tests in
src/AngleSharp.Css.Tests/Styling.
- Prefer targeted test runs while iterating:
dotnet test src/AngleSharp.Css.Tests/AngleSharp.Css.Tests.csproj --filter FullyQualifiedName~CssProperty- Before finishing, run full tests for confidence:
dotnet test src/AngleSharp.Css.Tests/AngleSharp.Css.Tests.csproj- If changing multi-target-sensitive code (conditional behavior, APIs), also run full build via Fallout script to mimic CI flow.
- Follow
.editorconfig(spaces, indent size 4 for.cs, LF endings). - Preserve existing namespace/file organization; this repo is convention-heavy.
- Avoid broad refactors when making focused feature fixes.
- Keep public API changes intentional; many files under
Domare effectively surface area. - Existing code mixes nullable contexts (
#nullable enableand#nullable disable); do not normalize unrelated files. - In
src/AngleSharp.Css/ValueConverters.cs, avoid static field initializers that reference converters declared later in the same file. Forward references can capturenullduring type initialization and only fail at runtime.
- Root overview:
README.md - Extended docs index:
docs/README.md - Suggested docs learning order is documented in
docs/README.md.
- Did I update all required wiring points (constants, declaration metadata, factory registration, parser/converter where needed)?
- Did I add focused tests in the closest matching test area?
- Does
dotnet test src/AngleSharp.Css.Tests/AngleSharp.Css.Tests.csprojpass? - If CI-relevant build behavior changed, did I run
./build.sh(or./build.ps1on Windows)? - Did I avoid unrelated formatting churn and preserve established structure?