Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ BenchmarkDotNet project (`net8.0`, `net10.0`), not part of the solution or the F
- `ParseValidationBenchmark.cs`: `ParseDocument` including the validation walks, per document shape and DOCTYPE kind (none, internal subset, local external subset).
- `TextContentBenchmark.cs`: `TextContent` of XML elements, from a single-text leaf to deep chains.
- `Documents.cs`: the shared document shapes and their DTDs.
- `Compare-Builds.ps1`: measures the working tree against a baseline commit.

### Documentation

Expand Down Expand Up @@ -331,17 +330,11 @@ dotnet run -c Release --project src/AngleSharp.Xml.Benchmarks -f net8.0 -- --che
dotnet run -c Release --project src/AngleSharp.Xml.Benchmarks -f net8.0 -- --filter '*TextContent*'
```

```powershell
./src/AngleSharp.Xml.Benchmarks/Compare-Builds.ps1 -BaselineRef <commit>[, <commit>...] -AngleSharpVersion <version> -Rounds 3 -Affinity <mask>
```

- Pass the same `-AngleSharpVersion` to every build when the compared commits default to different AngleSharp versions; otherwise core's own changes end up in the comparison.
- The script writes `summary.md` to its output directory: per case, each build's median of the rounds, its ratio to the working tree, the spread of the rounds, and the allocations.

- `--check` runs every setup and benchmark body once without measuring. Run it on both builds before a long run; `Compare-Builds.ps1` does.
- Compare builds with `Compare-Builds.ps1`: two separately built copies, alternated round by round. BenchmarkDotNet rebuilds the benchmark project it finds from the current directory, so the script runs each build from its own source tree and fails a round whose logs name the other build's AngleSharp.Xml module.
- To compare two commits, build each from its own source tree and alternate them round by round, so drift over the run favours neither. BenchmarkDotNet rebuilds the benchmark project it finds from the current directory; every run prints the `// AngleSharp.Xml module` it measured, which shows that a round ran the intended build.
- Build every compared commit with the same `AngleSharpVersion` (an MSBuild property, also read from the environment) when they default to different AngleSharp versions; otherwise core's own changes end up in the comparison.
- `--check` runs every setup and benchmark body once without measuring. Run it on every build before a long run.
- `MemoryDiagnoser` is on for every class; report the allocation column with the timings.
- Benchmarks need an otherwise idle machine; on hybrid CPUs pin them to the fast cores (`--affinity`, or `-Affinity` on the script).
- Benchmarks need an otherwise idle machine; on hybrid CPUs pin them to the fast cores (`--affinity`).
- Keep the shapes within what the oldest compared build survives. Before the explicit-stack walks, the old code overflowed the call stack parsing at about 2600 levels with a DTD (2850 without) and in `TextContent` at about 5000 (net8.0, 1 MB stack), which is why the deep shapes stop at 2000 and 4000.
- Every shape must stay valid against its DTD: an invalid document stops the walks at the first error and measures an early exit. `GlobalSetup` throws if one is not.
- A parse allocates megabytes, so when the garbage collector runs during it can move a row by 5-10% either way, and the direction changes with the document size. That is why the catalog comes in three sizes (`catalog-500`, `catalog`, `catalog-2000`). A difference at one size alone is not proof. A change that really costs work shows at every size; one that flips sign between sizes is GC timing. To confirm, rerun with BenchmarkDotNet's `--envVars DOTNET_GCgen0size:20000000` (512 MB Gen0, so no Gen0 or Gen1 collection runs during a parse) and compare the work alone.
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 1.3.1

Released on Sunday, November 22 2026.

- Fixed `document.title` of XHTML documents always being empty
- Fixed `createDocument` not being available to scripts (AngleSharp.Js) until a document was parsed
- Added running the scripts of the XHTML elements of a navigated XML document

# 1.3.0

Released on Sunday, November 1 2026.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AngleSharp.Xml contains code written by (in order of first pull request / commit
* [Florian Rappl](https://github.com/FlorianRappl)
* [Konstantin Safonov](https://github.com/kasthack)
* [jbrayfaithlife](https://github.com/jbrayfaithlife)
* [Michael Thyregod](https://github.com/michaelthyregod)

Without these awesome people AngleSharp.Xml could not exist. Thanks to everyone for your contributions! :beers:

Expand Down
239 changes: 0 additions & 239 deletions src/AngleSharp.Xml.Benchmarks/Compare-Builds.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion src/AngleSharp.Xml.Docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anglesharp/xml",
"version": "1.3.0",
"version": "1.3.1",
"preview": true,
"description": "The doclet for the AngleSharp.Xml documentation.",
"keywords": [
Expand Down
68 changes: 68 additions & 0 deletions src/AngleSharp.Xml.Tests/Dom/Acid3Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace AngleSharp.Xml.Tests.Dom
{
using AngleSharp.Dom;
using AngleSharp.Io;
using AngleSharp.Xml.Parser;
using NUnit.Framework;
using System;
using System.Linq;
using System.Threading.Tasks;

/// <summary>
/// Behavior the Acid3 test (acid3.acidtests.org) relies on.
/// </summary>
[TestFixture]
public class Acid3Tests
{
private const String XhtmlNamespace = "http://www.w3.org/1999/xhtml";

[Test]
public void TitleOfAnXhtmlDocumentUpdatesWithItsElement()
{
var document = BrowsingContext.New(Configuration.Default.WithXml()).OpenNewAsync().Result;
var doctype = document.Implementation.CreateDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
var xhtml = document.Implementation.CreateDocument(XhtmlNamespace, "html", doctype);
xhtml.DocumentElement.AppendChild(xhtml.CreateElement(XhtmlNamespace, "head"));
xhtml.DocumentElement.AppendChild(xhtml.CreateElement(XhtmlNamespace, "body"));
var title = xhtml.CreateElement(XhtmlNamespace, "title");
xhtml.DocumentElement.FirstChild.AppendChild(title);

Assert.AreEqual(String.Empty, xhtml.Title);

title.TextContent = " Sparrow ";

Assert.AreEqual("Sparrow", xhtml.Title);
}

[Test]
public async Task DocumentThatIsNotWellFormedFailsToOpen()
{
// showing the error instead is up to the application (IDocumentErrorHandler)
var context = BrowsingContext.New(Configuration.Default.WithXml());

try
{
await context.OpenAsync(res => res
.Address("http://localhost/xhtml.2")
.Content("<html xmlns='http://www.w3.org/1999/xhtml'><body><p><strong/> Parsing Test </strong></p></body></html>")
.Header(HeaderNames.ContentType, MimeTypeNames.Xml));
Assert.Fail("The parse error should propagate.");
}
catch (XmlParseException)
{
}
}

[Test]
public void ConfigurationNamesTheLibrarySoItsDomExtensionsAreFound()
{
var config = Configuration.Default.WithXml().WithXml();
var libraries = config.Services
.Where(m => m is not Delegate)
.Select(m => m.GetType().Assembly)
.Count(m => m == typeof(XmlParser).Assembly);

Assert.AreEqual(1, libraries);
}
}
}
Loading
Loading