From 4e5b9abbab446052bd0835bc8aaa749cf4aa1733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Mon, 23 Nov 2026 23:54:11 +0100 Subject: [PATCH 1/3] Make the PdfSharp ParseStyleSheet synchronous --- Source/HtmlRenderer.PdfSharp/PdfGenerator.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs index 099b2a440..6be7ed395 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs @@ -80,13 +80,9 @@ public static void RegisterCustomFontDirectory(string fontDirectory) /// the stylesheet source to parse /// true - combine the parsed CSS data with default CSS data, false - return only the parsed CSS data /// the parsed CSS data - public static Task ParseStyleSheet(string stylesheet, bool combineWithDefault = true) + public static CssData ParseStyleSheet(string stylesheet, bool combineWithDefault = true) { - // CssData.Parse -> CssParser.ParseStyleSheet is not itself async yet (its @import resolution - // bridges into the async resource-loading pipeline synchronously for now - it's also called - // directly from several UI controls' public API, out of scope for this conversion) - wrapped - // in Task.FromResult here so this method's own shape matches the rest of this async-only API. - return Task.FromResult(CssData.Parse(PdfSharpAdapter.Instance, stylesheet, combineWithDefault)); + return CssData.Parse(PdfSharpAdapter.Instance, stylesheet, combineWithDefault); } /// From 1748a41e61b0bf5b44cfaac1366a92bc826448cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Mon, 23 Nov 2026 23:54:12 +0100 Subject: [PATCH 2/3] Add the Async suffix to every public method returning a Task --- Source/Demo/WPF/DemoWindow.xaml.cs | 2 +- Source/Demo/WinForms/DemoForm.cs | 2 +- Source/Demo/WinForms/PerfForm.cs | 2 +- Source/Demo/WinUI/MainWindow.xaml.cs | 2 +- .../Adapters/PdfSharpAdapter.cs | 18 ++++++------ Source/HtmlRenderer.PdfSharp/HtmlContainer.cs | 4 +-- Source/HtmlRenderer.PdfSharp/PdfGenerator.cs | 16 +++++------ Source/HtmlRenderer.PdfSharp/README.md | 2 +- .../HtmlRenderer.WPF/Adapters/WpfAdapter.cs | 2 +- Source/HtmlRenderer.WPF/HtmlContainer.cs | 4 +-- Source/HtmlRenderer.WPF/HtmlControl.cs | 6 ++-- Source/HtmlRenderer.WPF/HtmlRender.cs | 6 ++-- .../Adapters/WinFormsAdapter.cs | 2 +- Source/HtmlRenderer.WinForms/HtmlContainer.cs | 4 +-- Source/HtmlRenderer.WinForms/HtmlLabel.cs | 6 ++-- Source/HtmlRenderer.WinForms/HtmlPanel.cs | 6 ++-- Source/HtmlRenderer.WinForms/HtmlRender.cs | 8 +++--- Source/HtmlRenderer.WinForms/HtmlToolTip.cs | 4 +-- Source/HtmlRenderer.WinUI/HtmlContainer.cs | 4 +-- Source/HtmlRenderer.WinUI/HtmlControl.cs | 6 ++-- Source/HtmlRenderer.WinUI/HtmlRender.cs | 6 ++-- Source/HtmlRenderer/Adapters/RAdapter.cs | 28 +++++++++---------- .../Core/CssEngine/Model/CodepointRange.cs | 2 +- Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs | 2 +- .../Core/Handlers/FontsHandler.cs | 2 +- .../Core/Handlers/ImageLoadHandler.cs | 6 ++-- .../Core/Handlers/StylesheetLoadHandler.cs | 6 ++-- Source/HtmlRenderer/Core/HtmlContainerInt.cs | 8 +++--- .../Core/Network/DataUriNetworkLoader.cs | 4 +-- .../Network/EmbeddedResourceNetworkLoader.cs | 12 ++++---- .../Core/Network/FileUriNetworkLoader.cs | 6 ++-- .../Core/Network/HttpClientNetworkLoader.cs | 6 ++-- .../Core/Network/RNetworkLoader.cs | 4 +-- .../Core/Network/RNetworkResponse.cs | 2 +- Source/HtmlRenderer/Core/Parse/DomParser.cs | 2 +- .../BoxModel/BlockPlacementSeamTests.cs | 2 +- .../ContainerLeftBehindKeepWithNextTest.cs | 2 +- .../ContainerLeftBehindTest.cs | 2 +- .../RasterImageSizeIntegrationTests.cs | 2 +- .../FixedPositionRepeatsPerPageTest.cs | 6 ++-- .../BreakPropagationIntegrationTests.cs | 2 +- .../EarlyBreakLayoutIntegrationTests.cs | 2 +- .../EngineRelayoutIdempotencyTests.cs | 2 +- .../FragmentainerCursorIntegrationTests.cs | 2 +- .../JustifiedLineAtABreakTests.cs | 2 +- .../KeepWithNextIntegrationTests.cs | 2 +- ...MonolithicContentLayoutIntegrationTests.cs | 2 +- .../OrphansWidowsIntegrationTests.cs | 2 +- .../PageBreakIntegrationTests.cs | 2 +- .../PageMarginPaginationIntegrationTests.cs | 2 +- .../ResumableBlockLayoutIntegrationTests.cs | 2 +- .../Fragmentation/StraddlingLineClaimTests.cs | 2 +- .../Fragmentation/UnreachedWordClaimTests.cs | 2 +- .../OffsetTopLineTopSyncTest.cs | 2 +- .../OrphansOnFirstRunTest.cs | 2 +- .../BackgroundPaintIntegrationTests.cs | 2 +- .../Painting/CssBackgrounds3Tests.cs | 2 +- .../Painting/CssBackgrounds4Tests.cs | 2 +- .../Painting/CssImages3Tests.cs | 2 +- .../Painting/CssImages4Tests.cs | 2 +- .../HighlightPaintIntegrationTests.cs | 2 +- .../PageOriginPaintIntegrationTests.cs | 2 +- .../RowspanCellShiftTest.cs | 2 +- .../StageD2FragmentBucketingSmokeTest.cs | 4 +-- .../StageD3PrecisionTest.cs | 2 +- .../StageD4RepeatedHeaderTest.cs | 2 +- .../StageR1DriverLoopTest.cs | 4 +-- .../StageR3RelocationTest.cs | 2 +- .../StageR4KeepWithNextTest.cs | 2 +- .../StageR5WidowsMultiPageTest.cs | 4 +-- .../StageR7TableCellForcedBreakTest.cs | 2 +- .../StageR7TableMultiPageCellTest.cs | 2 +- ...tageR9KeepWithNextAcrossForcedBreakTest.cs | 2 +- .../StageR9OversizedKeepWithNextRunTest.cs | 2 +- .../TableRowDefaultAtomicityTest.cs | 4 +-- .../TestSupport/LayoutHarness.cs | 4 +-- .../TestSupport/PaintHarness.cs | 4 +-- .../Text/SmallCapsIntegrationTests.cs | 2 +- .../StyleElementTextConcatenationTests.cs | 2 +- .../Text/VerticalAlignIntegrationTests.cs | 2 +- ...FixedPositionPaginationIntegrationTests.cs | 2 +- .../FixedPositionRepeatsPerPdfPageTest.cs | 4 +-- .../FontFaceFamilyTests.cs | 4 +-- .../HandleLinksPaginationTests.cs | 8 +++--- .../MultiPageTextVisibilityTest.cs | 2 +- .../PageRuleTests.cs | 2 +- .../PageSizeConverterTests.cs | 2 +- .../PageSizeRuleTests.cs | 2 +- .../PdfGeneratorTests.cs | 8 +++--- .../PrintMediaTests.cs | 2 +- .../StageD2VerificationTest.cs | 14 +++++----- .../StageD3VerificationTest.cs | 6 ++-- .../StageD4VerificationTest.cs | 2 +- .../StageF1VerificationTest.cs | 4 +-- .../TableHeaderPdfRenderingTests.cs | 8 +++--- ...eaderRepetitionThroughTheGeneratorTests.cs | 2 +- .../Adapters/PenCacheTests.cs | 4 +-- .../HtmlRenderer.Test/Css/CascadeTests.cs | 2 +- .../HtmlRenderer.Test/Css/ConformanceTests.cs | 2 +- .../HtmlRenderer.Test/Css/FontFaceTests.cs | 6 ++-- .../Css/SyntaxAndDataTypesTests.cs | 4 +-- .../CssModules/CssInlineTests.cs | 2 +- .../CssModules/CssValues5Tests.cs | 2 +- .../CssModules/CssValuesTests.cs | 2 +- .../CssModules/CssomTests.cs | 6 ++-- .../Html/DocumentMetadataTests.cs | 6 ++-- .../Html/EmbeddedTestSupport.cs | 4 +-- .../Html/InfrastructureTests.cs | 6 ++-- .../Test/HtmlRenderer.Test/Html/LinksTests.cs | 2 +- .../TestSupport/LayoutHarness.cs | 4 +-- 110 files changed, 216 insertions(+), 216 deletions(-) diff --git a/Source/Demo/WPF/DemoWindow.xaml.cs b/Source/Demo/WPF/DemoWindow.xaml.cs index be75f0372..4f861cafc 100644 --- a/Source/Demo/WPF/DemoWindow.xaml.cs +++ b/Source/Demo/WPF/DemoWindow.xaml.cs @@ -122,7 +122,7 @@ private async void OnGeneratePdf_Click(object sender, RoutedEventArgs e) config.PageSize = PageSize.A4; config.SetMargins(20); - var doc = await PdfGenerator.GeneratePdf(_mainControl.GetHtml(), config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); + var doc = await PdfGenerator.GeneratePdfAsync(_mainControl.GetHtml(), config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); var tmpFile = Path.GetTempFileName(); var pdfFile = Path.ChangeExtension(tmpFile, ".pdf"); diff --git a/Source/Demo/WinForms/DemoForm.cs b/Source/Demo/WinForms/DemoForm.cs index b68da61f6..d4b52f652 100644 --- a/Source/Demo/WinForms/DemoForm.cs +++ b/Source/Demo/WinForms/DemoForm.cs @@ -144,7 +144,7 @@ private async void OnGeneratePdf_Click(object sender, EventArgs e) config.PageSize = PageSize.A4; config.SetMargins(20); - var doc = await PdfGenerator.GeneratePdf(_mainControl.GetHtml(), config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); + var doc = await PdfGenerator.GeneratePdfAsync(_mainControl.GetHtml(), config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); var tmpFile = Path.GetTempFileName(); var pdfFile = Path.ChangeExtension(tmpFile, ".pdf"); // Preserves the full path diff --git a/Source/Demo/WinForms/PerfForm.cs b/Source/Demo/WinForms/PerfForm.cs index 472235c73..801115571 100644 --- a/Source/Demo/WinForms/PerfForm.cs +++ b/Source/Demo/WinForms/PerfForm.cs @@ -81,7 +81,7 @@ public static void Run(bool layout, bool paint) { foreach (var html in _perfTestSamples) { - htmlContainer.SetHtml(html); + htmlContainer.SetHtmlAsync(html); if (layout) htmlContainer.PerformLayout(g); diff --git a/Source/Demo/WinUI/MainWindow.xaml.cs b/Source/Demo/WinUI/MainWindow.xaml.cs index 853a6572d..c3155727d 100644 --- a/Source/Demo/WinUI/MainWindow.xaml.cs +++ b/Source/Demo/WinUI/MainWindow.xaml.cs @@ -90,7 +90,7 @@ private async void OnGeneratePdf_Click(object sender, RoutedEventArgs e) // Off the UI thread, as the image conversion blocks on Win2D var pdfFile = await Task.Run(async () => { - var doc = await PdfGenerator.GeneratePdf(html, config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); + var doc = await PdfGenerator.GeneratePdfAsync(html, config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); var file = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N") + ".pdf"); doc.Save(file); return file; diff --git a/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs b/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs index 001392f6c..2d6ebb629 100644 --- a/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs +++ b/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs @@ -64,9 +64,9 @@ private PdfSharpAdapter() } /// - /// Also recognizes a family registered via - those live entirely in + /// Also recognizes a family registered via - those live entirely in /// , invisible to the shared FontsHandler the base implementation - /// checks (see 's own doc comment for why). Without this override, + /// checks (see 's own doc comment for why). Without this override, /// would never see an @font-face-only /// family as "existing" and would silently substitute /// for it before layout ever gets a chance to resolve the real face. @@ -186,23 +186,23 @@ protected override RFont CreateFontInt(RFontFamily family, double size, RFontSty } /// - /// Never called: this backend overrides directly (see its own doc + /// Never called: this backend overrides directly (see its own doc /// comment) rather than routing through the base's LoadFontFaceFontInt-based path. /// protected override RFontFamily LoadFontFaceFontInt(byte[] fontBytes, string filePath) { - throw new NotSupportedException("PdfSharpAdapter overrides AddFontFace directly and never calls LoadFontFaceFontInt."); + throw new NotSupportedException("PdfSharpAdapter overrides AddFontFaceAsync directly and never calls LoadFontFaceFontInt."); } /// - /// Bypasses the base /shared FontsHandler registry + /// Bypasses the base /shared FontsHandler registry /// entirely: PDFsharp's needs raw font bytes for PDF embedding, which /// /// already stores and matches against directly - no platform font-family handle is involved. /// - public override async Task AddFontFace(string familyName, RUri uri, int weight, bool isItalic, int stretch, IReadOnlyList ranges) + public override async Task AddFontFaceAsync(string familyName, RUri uri, int weight, bool isItalic, int stretch, IReadOnlyList ranges) { - var networkResponse = await GetResourceStream(uri).ConfigureAwait(false); + var networkResponse = await GetResourceStreamAsync(uri).ConfigureAwait(false); if (networkResponse?.ResourceStream == null) { return false; @@ -222,14 +222,14 @@ public override async Task AddFontFace(string familyName, RUri uri, int we } } - /// Bypasses the shared registry, for the same reason as - see its doc comment. + /// Bypasses the shared registry, for the same reason as - see its doc comment. public override bool AddFontFaceFromLocalFamily(string familyName, string localFamilyName, int weight, bool isItalic, int stretch, IReadOnlyList ranges) { return _fontResolver.AddLocalFontFamily(familyName, localFamilyName, weight, isItalic, stretch, ranges); } /// - /// Bypasses the shared registry, for the same reason as - see its doc + /// Bypasses the shared registry, for the same reason as - see its doc /// comment. PDFsharp's own /// construction only ever resolves by (family name, bold, italic) internally - there is no public /// PDFsharp API surface to hand it an already-chosen numeric weight/stretch/face directly - so a diff --git a/Source/HtmlRenderer.PdfSharp/HtmlContainer.cs b/Source/HtmlRenderer.PdfSharp/HtmlContainer.cs index d6bcc1f65..5b063592b 100644 --- a/Source/HtmlRenderer.PdfSharp/HtmlContainer.cs +++ b/Source/HtmlRenderer.PdfSharp/HtmlContainer.cs @@ -257,9 +257,9 @@ public string SelectedHtml /// /// the html to init with, init empty if not given /// optional: the stylesheet to init with, init default if not given - public Task SetHtml(string htmlSource, CssData baseCssData = null) + public Task SetHtmlAsync(string htmlSource, CssData baseCssData = null) { - return _htmlContainerInt.SetHtml(htmlSource, baseCssData); + return _htmlContainerInt.SetHtmlAsync(htmlSource, baseCssData); } /// diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs index 6be7ed395..0233f8e32 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs @@ -95,12 +95,12 @@ public static CssData ParseStyleSheet(string stylesheet, bool combineWithDefault /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the generated image of the HTML - public static async Task GeneratePdf(string html, PageSize pageSize, int margin = 20, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) + public static async Task GeneratePdfAsync(string html, PageSize pageSize, int margin = 20, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { var config = new PdfGenerateConfig(); config.PageSize = pageSize; config.SetMargins(margin); - return await GeneratePdf(html, config, cssData, stylesheetLoad, imageLoad).ConfigureAwait(false); + return await GeneratePdfAsync(html, config, cssData, stylesheetLoad, imageLoad).ConfigureAwait(false); } /// @@ -112,13 +112,13 @@ public static async Task GeneratePdf(string html, PageSize pageSize /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the generated image of the HTML - public static async Task GeneratePdf(string html, PdfGenerateConfig config, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) + public static async Task GeneratePdfAsync(string html, PdfGenerateConfig config, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { // create PDF document to render the HTML into var document = new PdfDocument(); // add rendered PDF pages to document - await AddPdfPages(document, html, config, cssData, stylesheetLoad, imageLoad).ConfigureAwait(false); + await AddPdfPagesAsync(document, html, config, cssData, stylesheetLoad, imageLoad).ConfigureAwait(false); return document; } @@ -134,12 +134,12 @@ public static async Task GeneratePdf(string html, PdfGenerateConfig /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the generated image of the HTML - public static Task AddPdfPages(PdfDocument document, string html, PageSize pageSize, int margin = 20, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) + public static Task AddPdfPagesAsync(PdfDocument document, string html, PageSize pageSize, int margin = 20, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { var config = new PdfGenerateConfig(); config.PageSize = pageSize; config.SetMargins(margin); - return AddPdfPages(document, html, config, cssData, stylesheetLoad, imageLoad); + return AddPdfPagesAsync(document, html, config, cssData, stylesheetLoad, imageLoad); } /// @@ -152,7 +152,7 @@ public static Task AddPdfPages(PdfDocument document, string html, PageSize pageS /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the generated image of the HTML - public static async Task AddPdfPages(PdfDocument document, string html, PdfGenerateConfig config, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) + public static async Task AddPdfPagesAsync(PdfDocument document, string html, PdfGenerateConfig config, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { XSize orgPageSize; // get the size of each page to layout the HTML in @@ -180,7 +180,7 @@ public static async Task AddPdfPages(PdfDocument document, string html, PdfGener container.Location = new XPoint(config.MarginLeft, config.MarginTop); container.MaxSize = new XSize(pageSize.Width, 0); - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); container.PageSize = pageSize; container.MarginBottom = config.MarginBottom; container.MarginLeft = config.MarginLeft; diff --git a/Source/HtmlRenderer.PdfSharp/README.md b/Source/HtmlRenderer.PdfSharp/README.md index f1af8def0..79ebaf7da 100644 --- a/Source/HtmlRenderer.PdfSharp/README.md +++ b/Source/HtmlRenderer.PdfSharp/README.md @@ -28,7 +28,7 @@ class Program { private static void Main(string[] args) { - PdfDocument pdf = PdfGenerator.GeneratePdf("

Hello World

This is html rendered text

", PageSize.A4); + PdfDocument pdf = PdfGenerator.GeneratePdfAsync("

Hello World

This is html rendered text

", PageSize.A4); pdf.Save("document.pdf"); } } diff --git a/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs b/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs index d0fda838e..5bc6bbd1c 100644 --- a/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs +++ b/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs @@ -92,7 +92,7 @@ private WpfAdapter() // DataUriNetworkLoader-only - safer for unattended/server-side PDF generation, matching // PeachPDF's own default), WPF is an interactive UI backend where fetching a real http(s): // image or stylesheet out of the box is the expected behavior. data:/file: URIs still resolve - // the same way regardless (RAdapter.GetResourceStream intercepts both before ever consulting + // the same way regardless (RAdapter.GetResourceStreamAsync intercepts both before ever consulting // NetworkLoader), so only http(s): actually reaches this loader in practice. NetworkLoader = new HttpClientNetworkLoader(_sharedHttpClient, (Uri)null); diff --git a/Source/HtmlRenderer.WPF/HtmlContainer.cs b/Source/HtmlRenderer.WPF/HtmlContainer.cs index 1177465d4..6e34495c3 100644 --- a/Source/HtmlRenderer.WPF/HtmlContainer.cs +++ b/Source/HtmlRenderer.WPF/HtmlContainer.cs @@ -272,9 +272,9 @@ public void ClearSelection() ///
/// the html to init with, init empty if not given /// optional: the stylesheet to init with, init default if not given - public Task SetHtml(string htmlSource, CssData baseCssData = null) + public Task SetHtmlAsync(string htmlSource, CssData baseCssData = null) { - return _htmlContainerInt.SetHtml(htmlSource, baseCssData); + return _htmlContainerInt.SetHtmlAsync(htmlSource, baseCssData); } /// diff --git a/Source/HtmlRenderer.WPF/HtmlControl.cs b/Source/HtmlRenderer.WPF/HtmlControl.cs index ca52940bd..986b9e4d6 100644 --- a/Source/HtmlRenderer.WPF/HtmlControl.cs +++ b/Source/HtmlRenderer.WPF/HtmlControl.cs @@ -74,7 +74,7 @@ public class HtmlControl : Control /// /// Tracks the in-flight call, if any, so a newer call can supersede an - /// older one still awaiting - the stale call's post-await side + /// older one still awaiting - the stale call's post-await side /// effects (invalidate/error reporting) are skipped once it resumes, checked by reference equality /// against this field. /// @@ -479,7 +479,7 @@ protected virtual void InvokeMouseMove() /// /// /// A new call before a previous one finishes supersedes it: the previous call's - /// keeps running (it has no mid-flight cancellation point of + /// keeps running (it has no mid-flight cancellation point of /// its own) but its post-completion side effects - invalidate, error reporting - are discarded /// once it resumes, so only the newest call's results ever reach the control. /// @@ -493,7 +493,7 @@ public async Task SetTextAsync(string html, CancellationToken cancellationToken try { - await _htmlContainer.SetHtml(html, _baseCssData); + await _htmlContainer.SetHtmlAsync(html, _baseCssData); } catch (Exception ex) { diff --git a/Source/HtmlRenderer.WPF/HtmlRender.cs b/Source/HtmlRenderer.WPF/HtmlRender.cs index 76eac2606..c403d3924 100644 --- a/Source/HtmlRenderer.WPF/HtmlRender.cs +++ b/Source/HtmlRenderer.WPF/HtmlRender.cs @@ -152,7 +152,7 @@ public static async Task MeasureAsync(string html, double maxWidth = 0, Cs if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); container.PerformLayout(); actualSize = container.ActualSize; @@ -297,7 +297,7 @@ public static async Task RenderToImageAsync(string html, Size size, container.StylesheetLoad += stylesheetLoad; if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); var finalSize = MeasureHtmlByRestrictions(container, minSize, maxSize); container.MaxSize = finalSize; @@ -409,7 +409,7 @@ private static async Task RenderHtml(DrawingContext g, string html, Point if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); container.PerformLayout(); container.PerformPaint(g, new Rect(0, 0, double.MaxValue, double.MaxValue)); diff --git a/Source/HtmlRenderer.WinForms/Adapters/WinFormsAdapter.cs b/Source/HtmlRenderer.WinForms/Adapters/WinFormsAdapter.cs index a38363338..3c7814af7 100644 --- a/Source/HtmlRenderer.WinForms/Adapters/WinFormsAdapter.cs +++ b/Source/HtmlRenderer.WinForms/Adapters/WinFormsAdapter.cs @@ -75,7 +75,7 @@ private WinFormsAdapter() // DataUriNetworkLoader-only - safer for unattended/server-side PDF generation, matching // PeachPDF's own default), WinForms is an interactive UI backend where fetching a real // http(s): image or stylesheet out of the box is the expected behavior. data:/file: URIs - // still resolve the same way regardless (RAdapter.GetResourceStream intercepts both before + // still resolve the same way regardless (RAdapter.GetResourceStreamAsync intercepts both before // ever consulting NetworkLoader), so only http(s): actually reaches this loader in practice. NetworkLoader = new HttpClientNetworkLoader(_sharedHttpClient, (Uri)null); diff --git a/Source/HtmlRenderer.WinForms/HtmlContainer.cs b/Source/HtmlRenderer.WinForms/HtmlContainer.cs index af7fc9040..617287a6e 100644 --- a/Source/HtmlRenderer.WinForms/HtmlContainer.cs +++ b/Source/HtmlRenderer.WinForms/HtmlContainer.cs @@ -313,9 +313,9 @@ public void ClearSelection() ///
/// the html to init with, init empty if not given /// optional: the stylesheet to init with, init default if not given - public Task SetHtml(string htmlSource, CssData baseCssData = null) + public Task SetHtmlAsync(string htmlSource, CssData baseCssData = null) { - return _htmlContainerInt.SetHtml(htmlSource, baseCssData); + return _htmlContainerInt.SetHtmlAsync(htmlSource, baseCssData); } /// diff --git a/Source/HtmlRenderer.WinForms/HtmlLabel.cs b/Source/HtmlRenderer.WinForms/HtmlLabel.cs index 2fafa39e6..8bd5a8b92 100644 --- a/Source/HtmlRenderer.WinForms/HtmlLabel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlLabel.cs @@ -116,7 +116,7 @@ public class HtmlLabel : Control /// /// Tracks the in-flight call, if any, so a newer call can supersede an - /// older one still awaiting - the stale call's post-await side + /// older one still awaiting - the stale call's post-await side /// effects (layout/invalidate/error reporting) are skipped once it resumes, checked by reference /// equality against this field. /// @@ -419,7 +419,7 @@ public override string Text /// /// /// A new call before a previous one finishes supersedes it: the previous call's - /// keeps running (it has no mid-flight cancellation point of + /// keeps running (it has no mid-flight cancellation point of /// its own) but its post-completion side effects - layout, invalidate, error reporting - are /// discarded once it resumes, so only the newest call's results ever reach the control. /// @@ -433,7 +433,7 @@ public async Task SetTextAsync(string html, CancellationToken cancellationToken try { - await _htmlContainer.SetHtml(html, _baseCssData); + await _htmlContainer.SetHtmlAsync(html, _baseCssData); } catch (Exception ex) { diff --git a/Source/HtmlRenderer.WinForms/HtmlPanel.cs b/Source/HtmlRenderer.WinForms/HtmlPanel.cs index 91c331fbf..319781b90 100644 --- a/Source/HtmlRenderer.WinForms/HtmlPanel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlPanel.cs @@ -108,7 +108,7 @@ public class HtmlPanel : ScrollableControl /// /// Tracks the in-flight call, if any, so a newer call can supersede an - /// older one still awaiting - the stale call's post-await side + /// older one still awaiting - the stale call's post-await side /// effects (layout/invalidate/error reporting) are skipped once it resumes, checked by reference /// equality against this field. /// @@ -364,7 +364,7 @@ public override string Text ///
/// /// A new call before a previous one finishes supersedes it: the previous call's - /// keeps running (it has no mid-flight cancellation point of + /// keeps running (it has no mid-flight cancellation point of /// its own) but its post-completion side effects - layout, invalidate, error reporting - are /// discarded once it resumes, so only the newest call's results ever reach the control. /// @@ -378,7 +378,7 @@ public async Task SetTextAsync(string html, CancellationToken cancellationToken try { - await _htmlContainer.SetHtml(html, _baseCssData); + await _htmlContainer.SetHtmlAsync(html, _baseCssData); } catch (Exception ex) { diff --git a/Source/HtmlRenderer.WinForms/HtmlRender.cs b/Source/HtmlRenderer.WinForms/HtmlRender.cs index cd15e2f47..c7c074df9 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRender.cs +++ b/Source/HtmlRenderer.WinForms/HtmlRender.cs @@ -475,7 +475,7 @@ public static async Task RenderToImageAsync(Image image, string html, PointF loc container.StylesheetLoad += stylesheetLoad; if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); var finalSize = MeasureHtmlByRestrictions(container, minSize, maxSize); container.MaxSize = finalSize; @@ -594,7 +594,7 @@ public static async Task RenderToImageGdiPlusAsync(string html, Size minS container.StylesheetLoad += stylesheetLoad; if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); var finalSize = MeasureHtmlByRestrictions(container, minSize, maxSize); container.MaxSize = finalSize; @@ -645,7 +645,7 @@ private static async Task Measure(Graphics g, string html, float maxWidth if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); container.PerformLayout(g); actualSize = container.ActualSize; @@ -747,7 +747,7 @@ private static async Task RenderHtml(Graphics g, string html, PointF loca if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); container.PerformLayout(g); container.PerformPaint(g); diff --git a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs index 7de567f96..bf28a37e8 100644 --- a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs +++ b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs @@ -248,11 +248,11 @@ protected virtual void OnToolTipPopup(PopupEventArgs e) //Create fragment container var cssClass = string.IsNullOrEmpty(_tooltipCssClass) ? null : string.Format(" class=\"{0}\"", _tooltipCssClass); var toolipHtml = string.Format("{1}", cssClass, GetToolTip(e.AssociatedControl)); - // Bridges into the async HtmlContainer.SetHtml from this synchronous event handler. + // Bridges into the async HtmlContainer.SetHtmlAsync from this synchronous event handler. // Deliberately, permanently blocking: WinForms' ToolTip.Popup is a synchronous framework // callback with no async variant - e.ToolTipSize must be set before this method returns or // the tooltip won't position correctly, so there is no way to make this fire-and-forget. - _htmlContainer.SetHtml(toolipHtml, _baseCssData).GetAwaiter().GetResult(); + _htmlContainer.SetHtmlAsync(toolipHtml, _baseCssData).GetAwaiter().GetResult(); _htmlContainer.MaxSize = MaximumSize; //Measure size of the container diff --git a/Source/HtmlRenderer.WinUI/HtmlContainer.cs b/Source/HtmlRenderer.WinUI/HtmlContainer.cs index 9d686020f..c3d8690e0 100644 --- a/Source/HtmlRenderer.WinUI/HtmlContainer.cs +++ b/Source/HtmlRenderer.WinUI/HtmlContainer.cs @@ -244,9 +244,9 @@ public void ClearSelection() /// /// Init with optional document and stylesheet. /// - public Task SetHtml(string htmlSource, CssData baseCssData = null) + public Task SetHtmlAsync(string htmlSource, CssData baseCssData = null) { - return _htmlContainerInt.SetHtml(htmlSource, baseCssData); + return _htmlContainerInt.SetHtmlAsync(htmlSource, baseCssData); } /// diff --git a/Source/HtmlRenderer.WinUI/HtmlControl.cs b/Source/HtmlRenderer.WinUI/HtmlControl.cs index 4a7499fff..b3187122d 100644 --- a/Source/HtmlRenderer.WinUI/HtmlControl.cs +++ b/Source/HtmlRenderer.WinUI/HtmlControl.cs @@ -117,7 +117,7 @@ internal enum CursorShape /// /// Tracks the in-flight call, if any, so a newer call can supersede an - /// older one still awaiting . + /// older one still awaiting . /// private CancellationTokenSource _pendingLoad; @@ -339,7 +339,7 @@ public void ClearSelection() /// /// /// A new call before a previous one finishes supersedes it: the previous call's - /// keeps running (it has no mid-flight cancellation point of + /// keeps running (it has no mid-flight cancellation point of /// its own) but its post-completion side effects - invalidate, error reporting - are discarded /// once it resumes, so only the newest call's results ever reach the control. /// @@ -353,7 +353,7 @@ public async Task SetTextAsync(string html, CancellationToken cancellationToken try { - await _htmlContainer.SetHtml(html, _baseCssData); + await _htmlContainer.SetHtmlAsync(html, _baseCssData); } catch (Exception ex) { diff --git a/Source/HtmlRenderer.WinUI/HtmlRender.cs b/Source/HtmlRenderer.WinUI/HtmlRender.cs index 671aca0a2..0c82d3e5f 100644 --- a/Source/HtmlRenderer.WinUI/HtmlRender.cs +++ b/Source/HtmlRenderer.WinUI/HtmlRender.cs @@ -105,7 +105,7 @@ public static async Task MeasureAsync(string html, double maxWidth = 0, Cs if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); container.PerformLayout(); actualSize = container.ActualSize; @@ -224,7 +224,7 @@ public static async Task RenderToImageAsync(string html, Siz container.StylesheetLoad += stylesheetLoad; if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); var finalSize = MeasureHtmlByRestrictions(container, minSize, maxSize); container.MaxSize = finalSize; @@ -300,7 +300,7 @@ private static async Task RenderHtml(CanvasDrawingSession g, string html, if (imageLoad != null) container.ImageLoad += imageLoad; - await container.SetHtml(html, cssData).ConfigureAwait(false); + await container.SetHtmlAsync(html, cssData).ConfigureAwait(false); container.PerformLayout(); container.PerformPaint(g, new Rect(0, 0, double.MaxValue, double.MaxValue)); diff --git a/Source/HtmlRenderer/Adapters/RAdapter.cs b/Source/HtmlRenderer/Adapters/RAdapter.cs index 85bbc2209..e0c2c7304 100644 --- a/Source/HtmlRenderer/Adapters/RAdapter.cs +++ b/Source/HtmlRenderer/Adapters/RAdapter.cs @@ -59,8 +59,8 @@ public abstract class RAdapter private readonly FontsHandler _fontsHandler; /// - /// Dedup cache for , keyed by the resolved resource's absolute URI - since - /// the orchestrator re-runs @font-face registration on every SetHtml and this adapter + /// Dedup cache for , keyed by the resolved resource's absolute URI - since + /// the orchestrator re-runs @font-face registration on every SetHtmlAsync and this adapter /// is a process-wide singleton, re-registering the same face's bytes with the platform text engine /// on every call would leak native font handles (WinForms' PrivateFontCollection.AddMemoryFont/ /// WPF's AddFontMemResourceEx both register a *new* resource each call, even for identical @@ -191,7 +191,7 @@ protected void OnColorSchemeChanged() /// /// the resource URI, already resolved to absolute against or a <base href> element /// the resolved resource, or null if it could not be resolved - public Task GetResourceStream(RUri uri) + public Task GetResourceStreamAsync(RUri uri) { // Without local file access BaseUri can be null and a relative reference stays relative. // RUri.Scheme throws on it and the loaders don't check, so it's answered as unresolved here. @@ -203,7 +203,7 @@ public Task GetResourceStream(RUri uri) if (uri.Scheme == "data") { var dataLoader = NetworkLoader as DataUriNetworkLoader ?? new DataUriNetworkLoader(); - return dataLoader.GetResourceStream(uri); + return dataLoader.GetResourceStreamAsync(uri); } if (uri.Scheme == "file") @@ -216,16 +216,16 @@ public Task GetResourceStream(RUri uri) } var fileLoader = NetworkLoader as FileUriNetworkLoader ?? InternalFileLoader; - return fileLoader.GetResourceStream(uri); + return fileLoader.GetResourceStreamAsync(uri); } if (uri.Scheme == EmbeddedResourceNetworkLoader.Scheme) { var embeddedLoader = NetworkLoader as EmbeddedResourceNetworkLoader ?? InternalEmbeddedResourceLoader; - return embeddedLoader.GetResourceStream(uri); + return embeddedLoader.GetResourceStreamAsync(uri); } - return NetworkLoader.GetResourceStream(uri); + return NetworkLoader.GetResourceStreamAsync(uri); } /// @@ -342,7 +342,7 @@ public RImage ImageFromStream(Stream memoryStream) /// /// Check if the given font exists in the system by font family name, including the families - /// registered by . uses + /// registered by . uses /// it to pick the first available family of a font-family list. /// /// the font name to check @@ -378,7 +378,7 @@ public void AddFontFamilyMapping(string fromFamily, string toFamily) /// /// Loads one url() item of an @font-face src (CSS Fonts 4 §4.3.2) through - /// and registers it as a face of . + /// and registers it as a face of . /// /// the family name of the @font-face rule /// the absolute URI of the item @@ -391,7 +391,7 @@ public void AddFontFamilyMapping(string fromFamily, string toFamily) /// Virtual for the PdfSharp backend, which needs the font bytes for embedding and keeps the faces /// in its own font resolver. /// - public virtual async Task AddFontFace(string familyName, RUri uri, int weight, bool isItalic, int stretch, IReadOnlyList ranges) + public virtual async Task AddFontFaceAsync(string familyName, RUri uri, int weight, bool isItalic, int stretch, IReadOnlyList ranges) { RFontFamily fontFamily; bool cached; @@ -402,7 +402,7 @@ public virtual async Task AddFontFace(string familyName, RUri uri, int wei if (!cached) { - var networkResponse = await GetResourceStream(uri).ConfigureAwait(false); + var networkResponse = await GetResourceStreamAsync(uri).ConfigureAwait(false); if (networkResponse == null || networkResponse.ResourceStream == null) { return false; @@ -452,7 +452,7 @@ public virtual async Task AddFontFace(string familyName, RUri uri, int wei /// the registered families, not against full font names. /// /// false if there's no such family, the caller then tries the next item - /// Virtual for the PdfSharp backend, see . + /// Virtual for the PdfSharp backend, see . public virtual bool AddFontFaceFromLocalFamily(string familyName, string localFamilyName, int weight, bool isItalic, int stretch, IReadOnlyList ranges) { var localFamily = _fontsHandler.TryGetExistingFamily(localFamilyName); @@ -492,7 +492,7 @@ public RFont GetFont(string family, double size, RFontStyle style) /// font instance, or null when is given and no registered face covers it /// /// Virtual so the PdfSharp backend can override it to bypass 's shared - /// registry entirely, for the same reason as - see its doc comment. + /// registry entirely, for the same reason as - see its doc comment. /// public virtual RFont GetFont(string family, double size, RFontStyle style, int weight, int stretch, int? codepoint) { @@ -687,7 +687,7 @@ internal RFont CreateFont(RFontFamily family, double size, RFontStyle style) /// /// Registers the bytes of an @font-face font file with the platform text engine and returns - /// the family of the loaded face. Not called when is overridden. + /// the family of the loaded face. Not called when is overridden. /// /// the font file (TTF/OTF) /// where the bytes came from, for diagnostics diff --git a/Source/HtmlRenderer/Core/CssEngine/Model/CodepointRange.cs b/Source/HtmlRenderer/Core/CssEngine/Model/CodepointRange.cs index 5cd5d7de3..004855f6d 100644 --- a/Source/HtmlRenderer/Core/CssEngine/Model/CodepointRange.cs +++ b/Source/HtmlRenderer/Core/CssEngine/Model/CodepointRange.cs @@ -8,7 +8,7 @@ namespace TheArtOfDev.HtmlRenderer.Core.CssEngine /// int-codepoint convention) rather than PeachPDF's Rune-based RuneRange - see /// for why: System.Text.Rune only exists on /// net8.0, not this project's netstandard2.0 leg. Public: it appears in - /// 's public signature, for a custom adapter implementation + /// 's public signature, for a custom adapter implementation /// outside this assembly. ///
public readonly struct CodepointRange diff --git a/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs b/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs index e45eb2f8a..9d967e756 100644 --- a/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs +++ b/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs @@ -164,7 +164,7 @@ private async Task FetchVideoApiDataAsync(RUri apiUri, string source, Action /// Registers one @font-face face under . A face with the same - /// descriptors replaces the earlier one, the rules are registered again on every SetHtml. + /// descriptors replaces the earlier one, the rules are registered again on every SetHtmlAsync. ///
/// the family name of the @font-face rule /// the loaded face diff --git a/Source/HtmlRenderer/Core/Handlers/ImageLoadHandler.cs b/Source/HtmlRenderer/Core/Handlers/ImageLoadHandler.cs index c51ab6b03..5e152c49d 100644 --- a/Source/HtmlRenderer/Core/Handlers/ImageLoadHandler.cs +++ b/Source/HtmlRenderer/Core/Handlers/ImageLoadHandler.cs @@ -120,7 +120,7 @@ public RRect Rectangle /// /// /// HTML §4.8.4.3.5. A path or URI is resolved against the document base URL and fetched through - /// . With + /// . With /// the fetch blocks until the image is loaded, otherwise it runs in the background and the /// completion callback requests a re-layout. /// @@ -206,7 +206,7 @@ private void OnHtmlImageLoadEventCallback(string path, object image, RRect image /// /// Resolve (a file path, URI or data: URI) against the document base - /// and fetch it through . + /// and fetch it through . /// private async Task LoadImageFromPathAsync(string path, bool async) { @@ -220,7 +220,7 @@ private async Task LoadImageFromPathAsync(string path, bool async) return; } - var networkResponse = await _htmlContainer.Adapter.GetResourceStream(uri).ConfigureAwait(false); + var networkResponse = await _htmlContainer.Adapter.GetResourceStreamAsync(uri).ConfigureAwait(false); if (!_disposed && networkResponse != null && networkResponse.ResourceStream != null) { diff --git a/Source/HtmlRenderer/Core/Handlers/StylesheetLoadHandler.cs b/Source/HtmlRenderer/Core/Handlers/StylesheetLoadHandler.cs index df9df2c5f..d883e3bc6 100644 --- a/Source/HtmlRenderer/Core/Handlers/StylesheetLoadHandler.cs +++ b/Source/HtmlRenderer/Core/Handlers/StylesheetLoadHandler.cs @@ -33,7 +33,7 @@ internal static class StylesheetLoadHandler /// The source can be local file or web URI.
/// First raise event to allow the client to overwrite the stylesheet loading.
/// If the event doesn't handle it, the reference is resolved against the document base and fetched - /// through , uniformly for local files, data: + /// through , uniformly for local files, data: /// URIs, and remote HTTP(S) sources. /// /// the container of the html to handle load stylesheet for @@ -78,7 +78,7 @@ internal static class StylesheetLoadHandler /// /// Load stylesheet string from given source (file path or uri), resolved against the document base - /// and fetched through . + /// and fetched through . /// /// the container of the html to handle load stylesheet for /// the file path or uri to load the stylesheet from @@ -92,7 +92,7 @@ private static async Task LoadStylesheet(HtmlContainerInt htmlContainer, return string.Empty; } - var networkResponse = await htmlContainer.Adapter.GetResourceStream(uri).ConfigureAwait(false); + var networkResponse = await htmlContainer.Adapter.GetResourceStreamAsync(uri).ConfigureAwait(false); if (networkResponse == null || networkResponse.ResourceStream == null) { diff --git a/Source/HtmlRenderer/Core/HtmlContainerInt.cs b/Source/HtmlRenderer/Core/HtmlContainerInt.cs index 717c82cf9..a2120ed47 100644 --- a/Source/HtmlRenderer/Core/HtmlContainerInt.cs +++ b/Source/HtmlRenderer/Core/HtmlContainerInt.cs @@ -125,7 +125,7 @@ public sealed class HtmlContainerInt : IDisposable private CssData _cssData; /// - /// The html and base stylesheet last given to , kept so the cascade can be + /// The html and base stylesheet last given to , kept so the cascade can be /// re-run when a viewport change alters which @media rules apply. /// private string _htmlSource; @@ -595,7 +595,7 @@ internal RColor SelectionBackColor /// /// the html to init with, init empty if not given /// optional: the stylesheet to init with, init default if not given - public async Task SetHtml(string htmlSource, CssData baseCssData = null) + public async Task SetHtmlAsync(string htmlSource, CssData baseCssData = null) { Clear(); _htmlSource = htmlSource; @@ -627,8 +627,8 @@ private void RefreshMediaDependentCascade() var media = MediaQueryContext.FromAdapter(_adapter, _maxSize.Width, _maxSize.Height); if (!_cssData.MediaOutcomeChanged(_cascadeMedia, media)) return; - // PerformLayout is synchronous, so this blocks on the async SetHtml - SetHtml(_htmlSource, _baseCssData).GetAwaiter().GetResult(); + // PerformLayout is synchronous, so this blocks on the async SetHtmlAsync + SetHtmlAsync(_htmlSource, _baseCssData).GetAwaiter().GetResult(); } /// diff --git a/Source/HtmlRenderer/Core/Network/DataUriNetworkLoader.cs b/Source/HtmlRenderer/Core/Network/DataUriNetworkLoader.cs index bef2d1d3b..178bf652b 100644 --- a/Source/HtmlRenderer/Core/Network/DataUriNetworkLoader.cs +++ b/Source/HtmlRenderer/Core/Network/DataUriNetworkLoader.cs @@ -22,13 +22,13 @@ public class DataUriNetworkLoader : RNetworkLoader /// Not supported by this loader — the HTML string must always be passed directly rather than /// loaded via a network loader. /// - public override Task GetPrimaryContents() + public override Task GetPrimaryContentsAsync() { return null!; } /// - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { if (uri.Scheme != "data") return Task.FromResult(null); diff --git a/Source/HtmlRenderer/Core/Network/EmbeddedResourceNetworkLoader.cs b/Source/HtmlRenderer/Core/Network/EmbeddedResourceNetworkLoader.cs index 980345888..871f4319b 100644 --- a/Source/HtmlRenderer/Core/Network/EmbeddedResourceNetworkLoader.cs +++ b/Source/HtmlRenderer/Core/Network/EmbeddedResourceNetworkLoader.cs @@ -13,7 +13,7 @@ namespace TheArtOfDev.HtmlRenderer.Core.Network /// The assembly to search is named directly in the URI's authority rather than configured on the /// loader instance, so - like data:/file: - this always resolves the same way regardless /// of which is configured on : - /// intercepts this scheme unconditionally, the same + /// intercepts this scheme unconditionally, the same /// way it already does for data:/file:. /// /// @@ -29,8 +29,8 @@ public sealed class EmbeddedResourceNetworkLoader : RNetworkLoader /// /// Creates a loader with no primary document - it only resolves embedded: URIs it's asked - /// for via (which is how 's internal, - /// always-on instance of this loader is used). is not supported on + /// for via (which is how 's internal, + /// always-on instance of this loader is used). is not supported on /// an instance created this way — pass the HTML directly instead, or use the other constructor. /// public EmbeddedResourceNetworkLoader() @@ -61,7 +61,7 @@ public static RUri BuildUri(Assembly assembly, string manifestResourceName) public override RUri? BaseUri => _primaryContentsUri; /// - public override async Task GetPrimaryContents() + public override async Task GetPrimaryContentsAsync() { if (_primaryContentsUri is null) { @@ -69,7 +69,7 @@ public override async Task GetPrimaryContents() "This EmbeddedResourceNetworkLoader was created without a primary resource; construct it with an assembly and manifest resource name to load the root document, or pass the HTML directly."); } - var networkResponse = await GetResourceStream(_primaryContentsUri).ConfigureAwait(false); + var networkResponse = await GetResourceStreamAsync(_primaryContentsUri).ConfigureAwait(false); if (networkResponse?.ResourceStream is null) { @@ -83,7 +83,7 @@ public override async Task GetPrimaryContents() } /// - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { var assemblyName = uri.Uri.Host; var resourceName = uri.Uri.AbsolutePath.TrimStart('/'); diff --git a/Source/HtmlRenderer/Core/Network/FileUriNetworkLoader.cs b/Source/HtmlRenderer/Core/Network/FileUriNetworkLoader.cs index 561761200..282ea0f0e 100644 --- a/Source/HtmlRenderer/Core/Network/FileUriNetworkLoader.cs +++ b/Source/HtmlRenderer/Core/Network/FileUriNetworkLoader.cs @@ -26,7 +26,7 @@ public class FileUriNetworkLoader : RNetworkLoader /// /// Creates a loader whose base URI is the current working directory, for rendering an in-memory /// HTML string whose relative references should resolve against the process's working directory. - /// is not supported on an instance created this way — pass the HTML + /// is not supported on an instance created this way — pass the HTML /// directly instead. /// public FileUriNetworkLoader() @@ -54,7 +54,7 @@ public FileUriNetworkLoader(string primaryFilePath) public override RUri BaseUri { get; } /// - public override async Task GetPrimaryContents() + public override async Task GetPrimaryContentsAsync() { if (_primaryFilePath is null) { @@ -70,7 +70,7 @@ public override async Task GetPrimaryContents() } /// - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { if (!uri.IsAbsoluteUri || uri.Scheme != "file") { diff --git a/Source/HtmlRenderer/Core/Network/HttpClientNetworkLoader.cs b/Source/HtmlRenderer/Core/Network/HttpClientNetworkLoader.cs index bf8d5ec7b..884b9fc40 100644 --- a/Source/HtmlRenderer/Core/Network/HttpClientNetworkLoader.cs +++ b/Source/HtmlRenderer/Core/Network/HttpClientNetworkLoader.cs @@ -32,14 +32,14 @@ public HttpClientNetworkLoader(HttpClient httpClient, string primaryContentsUri) public override RUri? BaseUri => primaryContentsUri != null ? new RUri(primaryContentsUri) : null; /// - public override async Task GetPrimaryContents() + public override async Task GetPrimaryContentsAsync() { if (BaseUri is null) { throw new InvalidOperationException("Primary contents URL is not set."); } - var networkResponse = await GetResourceStream(BaseUri).ConfigureAwait(false); + var networkResponse = await GetResourceStreamAsync(BaseUri).ConfigureAwait(false); if (networkResponse?.ResourceStream is null) { @@ -53,7 +53,7 @@ public override async Task GetPrimaryContents() } /// - public override async Task GetResourceStream(RUri uri) + public override async Task GetResourceStreamAsync(RUri uri) { var response = await httpClient.GetAsync(uri.Uri).ConfigureAwait(false); diff --git a/Source/HtmlRenderer/Core/Network/RNetworkLoader.cs b/Source/HtmlRenderer/Core/Network/RNetworkLoader.cs index 566736df4..b85571d50 100644 --- a/Source/HtmlRenderer/Core/Network/RNetworkLoader.cs +++ b/Source/HtmlRenderer/Core/Network/RNetworkLoader.cs @@ -19,14 +19,14 @@ public abstract class RNetworkLoader /// Returns the root HTML document as a string. Called once at the start of rendering when no HTML /// string is given directly to the render/generate call. /// - public abstract Task GetPrimaryContents(); + public abstract Task GetPrimaryContentsAsync(); /// /// Returns the content of an external resource (a stylesheet, image, or font) referenced by the /// document, or null if the resource cannot be resolved. /// /// The resource URI, resolved against or a <base href> element if relative. - public abstract Task GetResourceStream(RUri uri); + public abstract Task GetResourceStreamAsync(RUri uri); /// /// The document's base URL, used to resolve relative href, src, and CSS url() diff --git a/Source/HtmlRenderer/Core/Network/RNetworkResponse.cs b/Source/HtmlRenderer/Core/Network/RNetworkResponse.cs index 9430b075d..08c2e874e 100644 --- a/Source/HtmlRenderer/Core/Network/RNetworkResponse.cs +++ b/Source/HtmlRenderer/Core/Network/RNetworkResponse.cs @@ -5,7 +5,7 @@ namespace TheArtOfDev.HtmlRenderer.Core.Network { /// - /// The result of resolving a resource URI via . + /// The result of resolving a resource URI via . /// /// The resource's content stream, or null if the resource has no body. /// diff --git a/Source/HtmlRenderer/Core/Parse/DomParser.cs b/Source/HtmlRenderer/Core/Parse/DomParser.cs index 3acc5b106..41bb81950 100644 --- a/Source/HtmlRenderer/Core/Parse/DomParser.cs +++ b/Source/HtmlRenderer/Core/Parse/DomParser.cs @@ -181,7 +181,7 @@ private static async Task RegisterFontFaces(CssData cssData, HtmlContainerInt ht else if (!string.IsNullOrEmpty(candidate.Url)) { var uri = CommonUtils.ResolveAgainstDocumentBase(htmlContainer, candidate.Url, stylesheetBaseUri); - loaded = uri != null && await adapter.AddFontFace(familyName, uri, weight, isItalic, stretch, ranges).ConfigureAwait(false); + loaded = uri != null && await adapter.AddFontFaceAsync(familyName, uri, weight, isItalic, stretch, ranges).ConfigureAwait(false); } else { diff --git a/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/BlockPlacementSeamTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/BlockPlacementSeamTests.cs index 4e3587efe..14b561157 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/BlockPlacementSeamTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/BlockPlacementSeamTests.cs @@ -17,7 +17,7 @@ namespace HtmlRenderer.IntegrationTest.BoxModel; /// to mean is that it finds nothing before it, exactly as a box with no parent always did. /// /// -// The regex cache in RegexParserUtils isn't thread-safe, parallel SetHtml calls can corrupt it. +// The regex cache in RegexParserUtils isn't thread-safe, parallel SetHtmlAsync calls can corrupt it. [TestClass] [DoNotParallelize] public sealed class BlockPlacementSeamTests diff --git a/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindKeepWithNextTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindKeepWithNextTest.cs index 6cb723c57..3d55c22ed 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindKeepWithNextTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindKeepWithNextTest.cs @@ -41,7 +41,7 @@ public async Task SectionWrappingHeadingAndParagraph_MovesWithThePulledHeading_N { using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line

", fillerCount)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $""" {filler} diff --git a/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindTest.cs index 6dc9240ad..077715799 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/ContainerLeftBehindTest.cs @@ -38,7 +38,7 @@ public async Task WrapperDivWithOneAvoidBreakChild_MovesWithIt_NeverSpansBothPag { using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line

", fillerCount)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $""" {filler} diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Content/RasterImageSizeIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Content/RasterImageSizeIntegrationTests.cs index e65d0e709..eef5a0e2b 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Content/RasterImageSizeIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Content/RasterImageSizeIntegrationTests.cs @@ -22,7 +22,7 @@ public void RasterImage_IsOneCssPixelPerImagePixel() MaxSize = new RSize(1000, 1000), AvoidAsyncImagesLoading = true }; - container.SetHtml(LayoutHarness.Wrap($"")).GetAwaiter().GetResult(); + container.SetHtmlAsync(LayoutHarness.Wrap($"")).GetAwaiter().GetResult(); using var bitmap = new Bitmap(1, 1, PixelFormat.Format32bppArgb); using var g = Graphics.FromImage(bitmap); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/FixedPositionRepeatsPerPageTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/FixedPositionRepeatsPerPageTest.cs index df7e7b21e..ae95eb966 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/FixedPositionRepeatsPerPageTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/FixedPositionRepeatsPerPageTest.cs @@ -38,7 +38,7 @@ public async Task TopLeftFixedElement_RepeatsIdenticallyOnEveryPage() { using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line of body text

", 60)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $"""
PageHeaderMarker
@@ -71,7 +71,7 @@ await wrapper.SetHtml( public async Task FixedElementNestedInABlock_GivesTheBlockNoFragmentOnOtherPages() { using var wrapper = new HtmlContainer(); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( """
@@ -111,7 +111,7 @@ public async Task FixedElement_StillRendersOnce_WithoutARealPageGrid() // Continuous media, no PageSize, so no page grid to repeat on using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line of body text

", 60)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $"""
PageHeaderMarker
diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/BreakPropagationIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/BreakPropagationIntegrationTests.cs index dd1654529..72ee5d2f0 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/BreakPropagationIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/BreakPropagationIntegrationTests.cs @@ -27,7 +27,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string bodyHtml) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(400, PageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EarlyBreakLayoutIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EarlyBreakLayoutIntegrationTests.cs index d02a8102b..0405c0a56 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EarlyBreakLayoutIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EarlyBreakLayoutIntegrationTests.cs @@ -33,7 +33,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string bodyHtml) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(300, PageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EngineRelayoutIdempotencyTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EngineRelayoutIdempotencyTests.cs index 3f2013626..4661b13bd 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EngineRelayoutIdempotencyTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/EngineRelayoutIdempotencyTests.cs @@ -30,7 +30,7 @@ private static async Task> LayoutRepeatedlyAsync( string bodyHtml, int passes, System.Func snapshot, double pageHeight = 1000) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(300, pageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/FragmentainerCursorIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/FragmentainerCursorIntegrationTests.cs index d87b872fc..f7b87414b 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/FragmentainerCursorIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/FragmentainerCursorIntegrationTests.cs @@ -29,7 +29,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string bodyHtml) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(300, PageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/JustifiedLineAtABreakTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/JustifiedLineAtABreakTests.cs index e263ba857..0a60a288b 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/JustifiedLineAtABreakTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/JustifiedLineAtABreakTests.cs @@ -28,7 +28,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string bodyHtml, double pageWidth = 200) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(pageWidth, 300); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/KeepWithNextIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/KeepWithNextIntegrationTests.cs index 05b6c33ef..0dc14e4b7 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/KeepWithNextIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/KeepWithNextIntegrationTests.cs @@ -31,7 +31,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string sectionHtml, double fillerHeight = 900) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $"" + $"
filler
" + sectionHtml diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/MonolithicContentLayoutIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/MonolithicContentLayoutIntegrationTests.cs index faa28c350..b297843e1 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/MonolithicContentLayoutIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/MonolithicContentLayoutIntegrationTests.cs @@ -31,7 +31,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string bodyHtml) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(400, PageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/OrphansWidowsIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/OrphansWidowsIntegrationTests.cs index 6b38e06f4..093f5a095 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/OrphansWidowsIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/OrphansWidowsIntegrationTests.cs @@ -28,7 +28,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) string bodyHtml, double pageHeight = 100, double pageWidth = 400, int marginTop = 0) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(pageWidth, pageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageBreakIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageBreakIntegrationTests.cs index 8b67365d5..34d7e8aaa 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageBreakIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageBreakIntegrationTests.cs @@ -28,7 +28,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string bodyHtml) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(400, PageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageMarginPaginationIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageMarginPaginationIntegrationTests.cs index 6a1b9092b..dcf3b4562 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageMarginPaginationIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/PageMarginPaginationIntegrationTests.cs @@ -32,7 +32,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) string bodyHtml, double marginTop, double marginBottom) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.MarginTop = (int)marginTop; diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/ResumableBlockLayoutIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/ResumableBlockLayoutIntegrationTests.cs index cb31a3cac..d57a60da6 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/ResumableBlockLayoutIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/ResumableBlockLayoutIntegrationTests.cs @@ -31,7 +31,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task<(CssBox Root, HtmlContainerInt Container)> BuildAsync(string bodyHtml) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(300, PageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/StraddlingLineClaimTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/StraddlingLineClaimTests.cs index 9f60817a2..668f56908 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/StraddlingLineClaimTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/StraddlingLineClaimTests.cs @@ -29,7 +29,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) string bodyHtml, double pageHeight = 842, double pageWidth = 600, int marginTop = 10) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(pageWidth, pageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/UnreachedWordClaimTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/UnreachedWordClaimTests.cs index e39a1c582..6dcc7204e 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/UnreachedWordClaimTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/UnreachedWordClaimTests.cs @@ -30,7 +30,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) string bodyHtml, double pageHeight = 850, double pageWidth = 600, int marginTop = 10) { var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new RSize(pageWidth, pageHeight); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/OffsetTopLineTopSyncTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/OffsetTopLineTopSyncTest.cs index cd1c3edb6..630f62092 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/OffsetTopLineTopSyncTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/OffsetTopLineTopSyncTest.cs @@ -21,7 +21,7 @@ public sealed class OffsetTopLineTopSyncTest public async Task EffectiveTop_MatchesLocation_AfterOffsetTopOnAMultiLineBox() { using var wrapper = new HtmlContainer(); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( """

Heading WordTwo WordThree WordFour WordFive WordSix WordSeven WordEight WordNine WordTen

diff --git a/Source/Test/HtmlRenderer.IntegrationTest/OrphansOnFirstRunTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/OrphansOnFirstRunTest.cs index 76e4dda31..da95eff1b 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/OrphansOnFirstRunTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/OrphansOnFirstRunTest.cs @@ -38,7 +38,7 @@ public async Task ParagraphStartingNearPageBottom_NeverStrandsFewerThanOrphansLi { using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line

", fillerCount)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $""" {filler} diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Painting/BackgroundPaintIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Painting/BackgroundPaintIntegrationTests.cs index 71c9a8576..2409da157 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Painting/BackgroundPaintIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Painting/BackgroundPaintIntegrationTests.cs @@ -380,7 +380,7 @@ private static RecordingGraphics PaintBackground(string style, EventHandler")).GetAwaiter().GetResult(); + container.SetHtmlAsync(PaintHarness.Wrap($"
")).GetAwaiter().GetResult(); using (var layoutGraphics = new RecordingGraphics()) container.PerformLayout(layoutGraphics); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds3Tests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds3Tests.cs index fe0d1e3d4..965d53a37 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds3Tests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds3Tests.cs @@ -389,7 +389,7 @@ private static (HtmlContainerInt Container, TheArtOfDev.HtmlRenderer.Core.Dom.Cs PageSize = new RSize(1000, 4000), AvoidAsyncImagesLoading = true }; - container.SetHtml(PaintHarness.Wrap($"
")).GetAwaiter().GetResult(); + container.SetHtmlAsync(PaintHarness.Wrap($"
")).GetAwaiter().GetResult(); using (var layoutGraphics = new RecordingGraphics()) container.PerformLayout(layoutGraphics); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds4Tests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds4Tests.cs index 23d136de7..54a330f38 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds4Tests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssBackgrounds4Tests.cs @@ -46,7 +46,7 @@ private static RecordingGraphics Paint(string style) PageSize = new RSize(1000, 4000), AvoidAsyncImagesLoading = true }; - container.SetHtml(PaintHarness.Wrap($"
")).GetAwaiter().GetResult(); + container.SetHtmlAsync(PaintHarness.Wrap($"
")).GetAwaiter().GetResult(); using (var layoutGraphics = new RecordingGraphics()) container.PerformLayout(layoutGraphics); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages3Tests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages3Tests.cs index d2925fc73..1358a6214 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages3Tests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages3Tests.cs @@ -320,7 +320,7 @@ private static (RecordingGraphics Graphics, GradientAdapter.Gradient? Gradient) AvoidAsyncImagesLoading = true, AvoidImagesLateLoading = true }; - container.SetHtml(PaintHarness.Wrap(body)).GetAwaiter().GetResult(); + container.SetHtmlAsync(PaintHarness.Wrap(body)).GetAwaiter().GetResult(); using (var layoutGraphics = new RecordingGraphics(adapter)) container.PerformLayout(layoutGraphics); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages4Tests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages4Tests.cs index 8423aef7a..72090da04 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages4Tests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Painting/CssImages4Tests.cs @@ -166,7 +166,7 @@ private static (RecordingGraphics Graphics, CssImages3Tests.GradientAdapter.Grad AvoidAsyncImagesLoading = true, AvoidImagesLateLoading = true }; - container.SetHtml(PaintHarness.Wrap(body)).GetAwaiter().GetResult(); + container.SetHtmlAsync(PaintHarness.Wrap(body)).GetAwaiter().GetResult(); using (var layoutGraphics = new RecordingGraphics(adapter)) container.PerformLayout(layoutGraphics); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Painting/HighlightPaintIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Painting/HighlightPaintIntegrationTests.cs index ee2b4b254..fe81b56fc 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Painting/HighlightPaintIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Painting/HighlightPaintIntegrationTests.cs @@ -140,7 +140,7 @@ private static (CssBox Root, HtmlContainerInt Container) Layout(string css, stri AvoidImagesLateLoading = images }; - container.SetHtml($"{body}"); + container.SetHtmlAsync($"{body}"); using var layoutGraphics = new RecordingGraphics(); container.PerformLayout(layoutGraphics); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Painting/PageOriginPaintIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Painting/PageOriginPaintIntegrationTests.cs index 6548f727f..b3a541629 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Painting/PageOriginPaintIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Painting/PageOriginPaintIntegrationTests.cs @@ -44,7 +44,7 @@ public void ContinuousSurface_WithAnOffset_StillPaintsTheBottomOfTheDocument() Location = new RPoint(0, 300), PageSize = new RSize(99999, 99999) }; - container.SetHtml(PaintHarness.Wrap( + container.SetHtmlAsync(PaintHarness.Wrap( "
top

BottomMarker

")); using var layout = new RecordingGraphics(); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/RowspanCellShiftTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/RowspanCellShiftTest.cs index 415e073c0..7476c3d31 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/RowspanCellShiftTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/RowspanCellShiftTest.cs @@ -49,7 +49,7 @@ public async Task RowspanCellSpanningAShiftedRow_BottomTracksTheShift_NotLeftSta // mechanism that can act on the straddling row - otherwise a small table gets moved wholesale // and never exercises this bug at all. var extraRows = string.Concat(Enumerable.Range(0, 40).Select(i => $"Extra{i}AExtra{i}B")); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $""" {filler} diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageD2FragmentBucketingSmokeTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageD2FragmentBucketingSmokeTest.cs index b1a94bde9..ef00f1007 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageD2FragmentBucketingSmokeTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageD2FragmentBucketingSmokeTest.cs @@ -24,7 +24,7 @@ public async Task MultiPageDocument_ProducesOneFragmentainerPerPage_WithSplitBox { using var wrapper = new HtmlContainer(); var paragraphs = string.Concat(Enumerable.Repeat("

filler line of text for pagination

", 80)); - await wrapper.SetHtml($"{paragraphs}"); + await wrapper.SetHtmlAsync($"{paragraphs}"); var container = GetInternal(wrapper); container.PageSize = new TheArtOfDev.HtmlRenderer.Adapters.Entities.RSize(500, 700); @@ -62,7 +62,7 @@ public async Task MultiPageDocument_ProducesOneFragmentainerPerPage_WithSplitBox public async Task HugeMargin_SkipsBlankFragmentainers() { using var wrapper = new HtmlContainer(); - await wrapper.SetHtml("
content
"); + await wrapper.SetHtmlAsync("
content
"); var container = GetInternal(wrapper); container.PageSize = new TheArtOfDev.HtmlRenderer.Adapters.Entities.RSize(500, 700); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageD3PrecisionTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageD3PrecisionTest.cs index 0303c139e..6c842cba7 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageD3PrecisionTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageD3PrecisionTest.cs @@ -16,7 +16,7 @@ public sealed class StageD3PrecisionTest private static HtmlContainerInt Layout(string html, int pageWidth, int pageHeight, out HtmlContainer wrapper, out Bitmap bitmap) { wrapper = new HtmlContainer(); - wrapper.SetHtml(html).GetAwaiter().GetResult(); + wrapper.SetHtmlAsync(html).GetAwaiter().GetResult(); var prop = typeof(HtmlContainer).GetProperty("HtmlContainerInt", BindingFlags.NonPublic | BindingFlags.Instance)!; var container = (HtmlContainerInt)prop.GetValue(wrapper)!; diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageD4RepeatedHeaderTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageD4RepeatedHeaderTest.cs index d438fe2c2..409de7627 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageD4RepeatedHeaderTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageD4RepeatedHeaderTest.cs @@ -27,7 +27,7 @@ public void ThreadRepeatsOnEveryPageTheTableSpans() sb.Append(""); using var wrapper = new HtmlContainer(); - wrapper.SetHtml(sb.ToString()).GetAwaiter().GetResult(); + wrapper.SetHtmlAsync(sb.ToString()).GetAwaiter().GetResult(); var prop = typeof(HtmlContainer).GetProperty("HtmlContainerInt", BindingFlags.NonPublic | BindingFlags.Instance)!; var container = (HtmlContainerInt)prop.GetValue(wrapper)!; diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR1DriverLoopTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR1DriverLoopTest.cs index 0cdde8f13..22ceff56c 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR1DriverLoopTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR1DriverLoopTest.cs @@ -27,7 +27,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) public async Task TwoForcedBreaksInSequence_EachStartsANewPageWithCorrectContent() { using var wrapper = new HtmlContainer(); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( """
First page content.
@@ -83,7 +83,7 @@ public async Task ManyForcedBreaksInSequence_TerminatesPromptlyWithOnePagePerBre using var wrapper = new HtmlContainer(); var divs = string.Concat(Enumerable.Range(0, 50).Select(i => $"
Section {i}
")); - await wrapper.SetHtml($"{divs}"); + await wrapper.SetHtmlAsync($"{divs}"); var container = GetInternal(wrapper); container.PageSize = new TheArtOfDev.HtmlRenderer.Adapters.Entities.RSize(500, 700); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR3RelocationTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR3RelocationTest.cs index f06bab3e2..4fc404cfc 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR3RelocationTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR3RelocationTest.cs @@ -22,7 +22,7 @@ public async Task MonolithicContentTallerThanOnePage_IsLeftInPlace_NotMoved() { using var wrapper = new HtmlContainer(); // A scroll container is monolithic, this one is taller than the 700px page. - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( """
filler
diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR4KeepWithNextTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR4KeepWithNextTest.cs index 6ac5b5adb..5a8853e17 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR4KeepWithNextTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR4KeepWithNextTest.cs @@ -22,7 +22,7 @@ private static HtmlContainerInt GetInternal(HtmlContainer wrapper) private static async Task LayoutAsync(string bodyHtml) { using var wrapper = new HtmlContainer(); - await wrapper.SetHtml($"{bodyHtml}"); + await wrapper.SetHtmlAsync($"{bodyHtml}"); var container = GetInternal(wrapper); container.PageSize = new TheArtOfDev.HtmlRenderer.Adapters.Entities.RSize(595, 800); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR5WidowsMultiPageTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR5WidowsMultiPageTest.cs index f15399311..6ad4c04c9 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR5WidowsMultiPageTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR5WidowsMultiPageTest.cs @@ -44,7 +44,7 @@ public async Task LongParagraph_PullsBackAcrossMultipleEarlierPages_WhenTheFirst // Page height 100 against a 24px line leaves 4px of slack per page, every page break lines up. var sentence = "Alpha bravo charlie delta echo foxtrot golf hotel india juliet kilo lima mike november oscar papa quebec romeo sierra tango uniform victor whiskey "; var paragraph = string.Concat(Enumerable.Repeat(sentence, 40)); - await wrapper.SetHtml($"

{paragraph}

"); + await wrapper.SetHtmlAsync($"

{paragraph}

"); var container = GetInternal(wrapper); container.PageSize = new TheArtOfDev.HtmlRenderer.Adapters.Entities.RSize(220, 100); @@ -72,7 +72,7 @@ public async Task LongParagraph_DeclinesGracefully_WhenSatisfyingWidowsWouldOver using var wrapper = new HtmlContainer(); // Every page is full, so widows:3 on the last page can only be met by overflowing the one before. var words = string.Concat(Enumerable.Repeat("word ", 300)); - await wrapper.SetHtml($"

{words}

"); + await wrapper.SetHtmlAsync($"

{words}

"); var container = GetInternal(wrapper); container.PageSize = new TheArtOfDev.HtmlRenderer.Adapters.Entities.RSize(60, 100); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableCellForcedBreakTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableCellForcedBreakTest.cs index 9ac047a82..0e7a9d6e8 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableCellForcedBreakTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableCellForcedBreakTest.cs @@ -50,7 +50,7 @@ private static void CollectWordsWithAbsoluteY(BoxFragment f, double bandTop, Lis public async Task ForcedBreakInsideTableCell_DoesNotOverlapOrLoseContent() { using var wrapper = new HtmlContainer(); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( """
diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableMultiPageCellTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableMultiPageCellTest.cs index b31d2afc6..788d31cdc 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableMultiPageCellTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR7TableMultiPageCellTest.cs @@ -51,7 +51,7 @@ public async Task RowAfterAMultiPageSpanningCell_IsNotLost() using var wrapper = new HtmlContainer(); var sentence = "one two three four five six seven eight nine ten "; var longCell = string.Concat(Enumerable.Repeat(sentence, 100)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $""" diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR9KeepWithNextAcrossForcedBreakTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR9KeepWithNextAcrossForcedBreakTest.cs index 190bbbc31..359b40d96 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR9KeepWithNextAcrossForcedBreakTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR9KeepWithNextAcrossForcedBreakTest.cs @@ -43,7 +43,7 @@ public async Task KeepWithNextPairRightAfterAForcedBreak_StaysTogether_OnTheResu { using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line of text

", 39)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $"""
ForcedBreakMarker
diff --git a/Source/Test/HtmlRenderer.IntegrationTest/StageR9OversizedKeepWithNextRunTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/StageR9OversizedKeepWithNextRunTest.cs index 0ccd94209..f29655c80 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/StageR9OversizedKeepWithNextRunTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/StageR9OversizedKeepWithNextRunTest.cs @@ -48,7 +48,7 @@ public async Task LongAvoidChainTallerThanOnePage_NeverCorruptsGeometry_AndLoses using var wrapper = new HtmlContainer(); var runMembers = string.Concat(Enumerable.Range(0, 60).Select(i => $"

RunMember{i} filler filler filler filler filler

")); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $"""
TopMarker
diff --git a/Source/Test/HtmlRenderer.IntegrationTest/TableRowDefaultAtomicityTest.cs b/Source/Test/HtmlRenderer.IntegrationTest/TableRowDefaultAtomicityTest.cs index c3a5b020c..a35fa7a76 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/TableRowDefaultAtomicityTest.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/TableRowDefaultAtomicityTest.cs @@ -40,7 +40,7 @@ public async Task OrdinaryRowWithNoBreakInsideAvoid_IsStillPreservedUnfragmented { using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line

", fillerCount)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $""" {filler} @@ -86,7 +86,7 @@ public async Task RowSpanningIntoASubsequentRow_RemainsFreelyFragmentable() { using var wrapper = new HtmlContainer(); var filler = string.Concat(Enumerable.Repeat("

filler line

", fillerCount)); - await wrapper.SetHtml( + await wrapper.SetHtmlAsync( $""" {filler} diff --git a/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs b/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs index d7fb43373..f21b02ca5 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs @@ -26,7 +26,7 @@ internal static class LayoutHarness /// Lays out at x pixels. /// /// - /// Optional: run against the parsed box tree's root after SetHtml and before layout, for a test that + /// Optional: run against the parsed box tree's root after SetHtmlAsync and before layout, for a test that /// has to put something in the tree the parser cannot produce. /// /// @@ -50,7 +50,7 @@ internal static (CssBox Root, HtmlContainerInt Container) Layout( }; container.SetMargins((int)margin); - container.SetHtml(html); + container.SetHtmlAsync(html); if (prepare is not null) { diff --git a/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/PaintHarness.cs b/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/PaintHarness.cs index e448efbbb..c0a6229d0 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/PaintHarness.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/PaintHarness.cs @@ -28,7 +28,7 @@ internal static (CssBox Root, HtmlContainerInt Container) Layout( PageSize = new RSize(maxWidth, maxHeight) }; - container.SetHtml(html); + container.SetHtmlAsync(html); using var layoutGraphics = new RecordingGraphics(); container.PerformLayout(layoutGraphics); @@ -59,7 +59,7 @@ internal static (CssBox Root, HtmlContainerInt Container) LayoutPaginated( }; container.SetMargins((int)margin); - container.SetHtml(html); + container.SetHtmlAsync(html); using var layoutGraphics = new RecordingGraphics(); container.PerformLayout(layoutGraphics); diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Text/SmallCapsIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Text/SmallCapsIntegrationTests.cs index 61e969491..5e8a6b7f6 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Text/SmallCapsIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Text/SmallCapsIntegrationTests.cs @@ -4,7 +4,7 @@ namespace HtmlRenderer.IntegrationTest.Text; -// The regex cache in RegexParserUtils isn't thread-safe, parallel SetHtml calls can corrupt it. +// The regex cache in RegexParserUtils isn't thread-safe, parallel SetHtmlAsync calls can corrupt it. [DoNotParallelize] [TestClass] public sealed class SmallCapsIntegrationTests diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Text/StyleElementTextConcatenationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Text/StyleElementTextConcatenationTests.cs index e27c2ff17..a1cd2f4b7 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Text/StyleElementTextConcatenationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Text/StyleElementTextConcatenationTests.cs @@ -2,7 +2,7 @@ namespace HtmlRenderer.IntegrationTest.Text; -// RegexParserUtils caches its regexes in a static Dictionary, parallel SetHtml calls can corrupt it +// RegexParserUtils caches its regexes in a static Dictionary, parallel SetHtmlAsync calls can corrupt it [DoNotParallelize] [TestClass] public sealed class StyleElementTextConcatenationTests diff --git a/Source/Test/HtmlRenderer.IntegrationTest/Text/VerticalAlignIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/Text/VerticalAlignIntegrationTests.cs index 160253fa2..2cc076e1a 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/Text/VerticalAlignIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/Text/VerticalAlignIntegrationTests.cs @@ -3,7 +3,7 @@ namespace HtmlRenderer.IntegrationTest.Text; -// The regex cache in RegexParserUtils isn't thread-safe, parallel SetHtml calls can corrupt it. +// The regex cache in RegexParserUtils isn't thread-safe, parallel SetHtmlAsync calls can corrupt it. [DoNotParallelize] [TestClass] public sealed class VerticalAlignIntegrationTests diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionPaginationIntegrationTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionPaginationIntegrationTests.cs index 7bd5180b9..67746e3f0 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionPaginationIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionPaginationIntegrationTests.cs @@ -30,7 +30,7 @@ public async Task FixedPositionBox_BackgroundRepeatsAtTheSamePosition_OnEveryRea """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThanOrEqualTo(3, document.Pages.Count, "test content should span at least 3 pages for this to be a meaningful check."); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionRepeatsPerPdfPageTest.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionRepeatsPerPdfPageTest.cs index b0a61632b..5bff0deba 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionRepeatsPerPdfPageTest.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/FixedPositionRepeatsPerPdfPageTest.cs @@ -36,10 +36,10 @@ public async Task FixedHeaderMarker_AddsOneExtraTextOperatorToEveryGeneratedPage var sentence = "This is a moderately long sentence used to build a paragraph that will wrap across many lines and, eventually, across more than one page. "; var body = $"

{string.Concat(Enumerable.Repeat(sentence, 200))}

"; - using var withFixed = await PdfGenerator.GeneratePdf( + using var withFixed = await PdfGenerator.GeneratePdfAsync( $"""
FixedHeaderMarkerText
{body}""", config); - using var withoutFixed = await PdfGenerator.GeneratePdf($"{body}", config); + using var withoutFixed = await PdfGenerator.GeneratePdfAsync($"{body}", config); Assert.IsGreaterThanOrEqualTo(3, withoutFixed.Pages.Count, "test content should span at least 3 pages for this to be meaningful"); Assert.AreEqual(withoutFixed.Pages.Count, withFixed.Pages.Count, "adding a fixed header should not itself change how many pages the body content needs"); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/FontFaceFamilyTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/FontFaceFamilyTests.cs index 0f4dbcbcb..c73049eec 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/FontFaceFamilyTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/FontFaceFamilyTests.cs @@ -45,8 +45,8 @@ public async Task FontFace_DoesntApplyToALaterDocumentWithoutIt() fontFace = $""; } - using var withFontFace = await PdfGenerator.GeneratePdf($"{fontFace}{text}", PageSize.A4); - using var without = await PdfGenerator.GeneratePdf($"{text}", PageSize.A4); + using var withFontFace = await PdfGenerator.GeneratePdfAsync($"{fontFace}{text}", PageSize.A4); + using var without = await PdfGenerator.GeneratePdfAsync($"{text}", PageSize.A4); Assert.IsTrue(FontNames(withFontFace).Any(IsTuffyBoldItalic)); Assert.IsFalse(FontNames(without).Any(IsTuffyBoldItalic)); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/HandleLinksPaginationTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/HandleLinksPaginationTests.cs index fc15fc985..de471ee66 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/HandleLinksPaginationTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/HandleLinksPaginationTests.cs @@ -24,7 +24,7 @@ public async Task Link_PastGenuineMultiPageFillerContent_LandsOnExactlyOneCorrec """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThan(1, document.Pages.Count, "filler content should span multiple pages for this to be meaningful"); Assert.AreEqual(0, document.Pages[0].Annotations.Count, "the link sits well past the first page's worth of filler"); @@ -41,7 +41,7 @@ public async Task Link_AfterAContentEmptySpacer_LandsOnTheCorrectMaterializedPag { // The spacer has no text/background/border, so every page-slot it alone spans is content-empty // and is never materialized as a fragmentainer at all (FragmentEmitter.HasContentInBand / - // PdfGenerator.AddPdfPages' blank-page-skipping loop) - the linked paragraph sits several grid + // PdfGenerator.AddPdfPagesAsync' blank-page-skipping loop) - the linked paragraph sits several grid // slots into the document but on an early materialized PDF page. HandleLinks must map the link's // fragmentainer band to the PDF page actually generated for it via slotToPage, not to its raw // (non-contiguous) SlotIndex. @@ -56,7 +56,7 @@ public async Task Link_AfterAContentEmptySpacer_LandsOnTheCorrectMaterializedPag var config = new PdfGenerateConfig { PageSize = PageSize.A4 }; config.SetMargins(20); - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThanOrEqualTo(2, document.Pages.Count); Assert.AreEqual(0, document.Pages[0].Annotations.Count, "the link is not on the first page"); @@ -87,7 +87,7 @@ public async Task EmptyOrTopFragment_LinksToTheFirstPage(string href) var filler = string.Concat(Enumerable.Repeat("

filler line of body text

", 150)); var html = $"{filler}

back to the top

"; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); using var stream = new MemoryStream(); document.Save(stream); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/MultiPageTextVisibilityTest.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/MultiPageTextVisibilityTest.cs index d596afdbf..aa7d8c068 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/MultiPageTextVisibilityTest.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/MultiPageTextVisibilityTest.cs @@ -21,7 +21,7 @@ public async Task EveryPage_HasRealTextDrawingOperators() var sentence = "This is a moderately long sentence used to build a paragraph that will wrap across many lines and, eventually, across more than one page. "; var html = $"

{string.Concat(Enumerable.Repeat(sentence, 200))}

"; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThanOrEqualTo(3, document.Pages.Count, "Test content should span at least 3 pages for this to be a meaningful check."); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/PageRuleTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/PageRuleTests.cs index 4241ac674..3d0583bc3 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/PageRuleTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/PageRuleTests.cs @@ -17,7 +17,7 @@ private static async Task PageCount(string html, int marginTop = 0, int mar { var config = new PdfGenerateConfig { PageSize = PageSize.A4, MarginTop = marginTop, MarginBottom = marginBottom }; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); return document.Pages.Count; } diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeConverterTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeConverterTests.cs index 59fea4cca..bc2273036 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeConverterTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeConverterTests.cs @@ -4,7 +4,7 @@ namespace HtmlRenderer.PdfSharp.Test; /// /// Tests for from the PDFsharp NuGet package, which -/// +/// /// calls directly to resolve the page size in points for each configured . /// [TestClass] diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeRuleTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeRuleTests.cs index e14ffe2b4..0212bcd93 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeRuleTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/PageSizeRuleTests.cs @@ -10,7 +10,7 @@ namespace HtmlRenderer.PdfSharp.Test; public sealed class PageSizeRuleTests { private static async Task Generate(string css, string body = "

x

") => - await PdfGenerator.GeneratePdf( + await PdfGenerator.GeneratePdfAsync( $"{body}", new PdfGenerateConfig { PageSize = PageSize.A4 }); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/PdfGeneratorTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/PdfGeneratorTests.cs index cdec7cc91..8d3747057 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/PdfGeneratorTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/PdfGeneratorTests.cs @@ -35,7 +35,7 @@ public async Task GeneratePdf_FromHtml_CreatesPdfDocument() """; // Act - using var document = await PdfGenerator.GeneratePdf(html, config, null, DemoUtils.OnStylesheetLoad, OnImageLoadPdfSharp); + using var document = await PdfGenerator.GeneratePdfAsync(html, config, null, DemoUtils.OnStylesheetLoad, OnImageLoadPdfSharp); // Assert Assert.AreEqual(1, document.Pages.Count); @@ -88,7 +88,7 @@ public async Task GeneratePdf_FromHtml_WithMultipleFonts_CreatesPdfDocument() """; // Act - using var document = await PdfGenerator.GeneratePdf(html, config, null, DemoUtils.OnStylesheetLoad, null); + using var document = await PdfGenerator.GeneratePdfAsync(html, config, null, DemoUtils.OnStylesheetLoad, null); // Assert Assert.AreEqual(1, document.Pages.Count); @@ -118,7 +118,7 @@ public async Task GeneratePdf_FromHtml_WithMultipleFonts_CreatesPdfDocument() public async Task GeneratePdf_SimpleHtml_ProducesAtLeastOnePage() { // Act - using var document = await PdfGenerator.GeneratePdf("

Hello

", PageSize.A4); + using var document = await PdfGenerator.GeneratePdfAsync("

Hello

", PageSize.A4); // Assert Assert.IsTrue(document.Pages.Count >= 1); @@ -128,7 +128,7 @@ public async Task GeneratePdf_SimpleHtml_ProducesAtLeastOnePage() public async Task GeneratePdf_SimpleHtml_CanBeSaved() { // Arrange - using var document = await PdfGenerator.GeneratePdf("

Hello

", PageSize.A4); + using var document = await PdfGenerator.GeneratePdfAsync("

Hello

", PageSize.A4); // Act using var stream = new MemoryStream(); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/PrintMediaTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/PrintMediaTests.cs index e9da8ecce..402cad8fa 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/PrintMediaTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/PrintMediaTests.cs @@ -17,7 +17,7 @@ public async Task Pdf_IsRenderedForPrintMedia() const string html = "" + "
"; - using var document = await PdfGenerator.GeneratePdf(html, new PdfGenerateConfig { PageSize = PageSize.A4 }); + using var document = await PdfGenerator.GeneratePdfAsync(html, new PdfGenerateConfig { PageSize = PageSize.A4 }); Assert.AreEqual(2, document.Pages.Count); } diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/StageD2VerificationTest.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/StageD2VerificationTest.cs index 23d4b0c9d..e4c04ab49 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/StageD2VerificationTest.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/StageD2VerificationTest.cs @@ -22,7 +22,7 @@ public async Task ForcedBreakBefore_Page_StartsNewPage() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.AreEqual(2, document.Pages.Count); } @@ -35,7 +35,7 @@ public async Task NoForcedBreak_SmallContent_StaysOnOnePage() const string html = "

Title

Body text.

"; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.AreEqual(1, document.Pages.Count); } @@ -54,7 +54,7 @@ public async Task LegacyPageBreakBefore_Always_StartsNewPage() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.AreEqual(2, document.Pages.Count); } @@ -77,7 +77,7 @@ public async Task BreakInsideAvoid_KeepsBlockTogether_OnOnePage() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThanOrEqualTo(2, document.Pages.Count); } @@ -93,7 +93,7 @@ public async Task ManyParagraphs_FlowAcrossMultiplePages() 120)); var html = $"{paragraphs}"; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThan(1, document.Pages.Count); } @@ -107,7 +107,7 @@ public async Task HugeMargin_DoesNotProduceRunawayBlankPages() const string html = "
content
"; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsLessThanOrEqualTo(2, document.Pages.Count); } @@ -128,7 +128,7 @@ public async Task KeepWithNext_HeadingStaysWithFollowingParagraph() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThanOrEqualTo(2, document.Pages.Count); } diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/StageD3VerificationTest.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/StageD3VerificationTest.cs index 5e78cf76e..3f8cd67c9 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/StageD3VerificationTest.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/StageD3VerificationTest.cs @@ -18,7 +18,7 @@ public async Task LongParagraph_SpansPagesWithoutError() var sentence = "This is a moderately long sentence used to build a paragraph that will wrap across many lines and, eventually, across more than one page. "; var html = $"

{string.Concat(Enumerable.Repeat(sentence, 100))}

"; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThan(1, document.Pages.Count); } @@ -40,7 +40,7 @@ public async Task Widows_PullsMinimumLinesToNextPage() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThanOrEqualTo(2, document.Pages.Count); } @@ -61,7 +61,7 @@ public async Task Orphans_KeepsMinimumLinesOnFirstPage() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThanOrEqualTo(2, document.Pages.Count); } diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/StageD4VerificationTest.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/StageD4VerificationTest.cs index a5e6ac363..ea2f05592 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/StageD4VerificationTest.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/StageD4VerificationTest.cs @@ -25,7 +25,7 @@ public async Task LargeTableWithHeader_SpansMultiplePagesWithoutError() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThan(1, document.Pages.Count); } diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/StageF1VerificationTest.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/StageF1VerificationTest.cs index 84b0af092..d334d622c 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/StageF1VerificationTest.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/StageF1VerificationTest.cs @@ -25,7 +25,7 @@ public async Task WebLinkAndAnchorLink_AcrossPages_DoNotThrow() """; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsGreaterThan(1, document.Pages.Count); @@ -51,7 +51,7 @@ public async Task HugeMargin_ProducesNoBlankPages() const string html = "
content
"; - using var document = await PdfGenerator.GeneratePdf(html, config); + using var document = await PdfGenerator.GeneratePdfAsync(html, config); Assert.IsLessThanOrEqualTo(2, document.Pages.Count); } diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderPdfRenderingTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderPdfRenderingTests.cs index 714dbb586..6a1323e30 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderPdfRenderingTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderPdfRenderingTests.cs @@ -52,7 +52,7 @@ public async Task TableHeader_MultiPageTable_RepeatsHeaderOnEveryRealGeneratedPa """; - using var document = await PdfGenerator.GeneratePdf(html, PageSize.A4, margin: 20); + using var document = await PdfGenerator.GeneratePdfAsync(html, PageSize.A4, margin: 20); Assert.IsGreaterThanOrEqualTo(2, document.Pages.Count, $"PDF should have at least 2 pages but has {document.Pages.Count}"); AssertHeaderRepeatsOnEveryPage(document); @@ -76,7 +76,7 @@ public async Task TableHeader_ThreePageTable_RepeatsHeaderOnEveryRealGeneratedPa """; - using var document = await PdfGenerator.GeneratePdf(html, PageSize.A4, margin: 20); + using var document = await PdfGenerator.GeneratePdfAsync(html, PageSize.A4, margin: 20); Assert.IsGreaterThanOrEqualTo(3, document.Pages.Count, $"PDF should have at least 3 pages but has {document.Pages.Count}"); AssertHeaderRepeatsOnEveryPage(document); @@ -107,7 +107,7 @@ public async Task TableHeader_ComplexHeaderWithColspan_RepeatsAcrossPages() """; - using var document = await PdfGenerator.GeneratePdf(html, PageSize.A4, margin: 20); + using var document = await PdfGenerator.GeneratePdfAsync(html, PageSize.A4, margin: 20); Assert.IsGreaterThanOrEqualTo(2, document.Pages.Count, "PDF should have at least 2 pages for complex header test"); AssertHeaderRepeatsOnEveryPage(document); @@ -126,7 +126,7 @@ public async Task TableHeader_SinglePageTable_PaintsHeaderBackgroundExactlyOnce(
"""; - using var document = await PdfGenerator.GeneratePdf(html, PageSize.A4, margin: 20); + using var document = await PdfGenerator.GeneratePdfAsync(html, PageSize.A4, margin: 20); Assert.AreEqual(1, document.Pages.Count, "this fixture is deliberately small enough to fit on one page"); diff --git a/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderRepetitionThroughTheGeneratorTests.cs b/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderRepetitionThroughTheGeneratorTests.cs index 1e90e3068..edd91e207 100644 --- a/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderRepetitionThroughTheGeneratorTests.cs +++ b/Source/Test/HtmlRenderer.PdfSharp.Test/TableHeaderRepetitionThroughTheGeneratorTests.cs @@ -35,7 +35,7 @@ private static async Task LayoutFixtureAsync() """; - return await PdfGenerator.GeneratePdf(html, PageSize.A4, margin: 20); + return await PdfGenerator.GeneratePdfAsync(html, PageSize.A4, margin: 20); } private static int HeaderMatchCount(PdfDocument document, int pageIndex) diff --git a/Source/Test/HtmlRenderer.Test/Adapters/PenCacheTests.cs b/Source/Test/HtmlRenderer.Test/Adapters/PenCacheTests.cs index ba2bb6179..c40782fcc 100644 --- a/Source/Test/HtmlRenderer.Test/Adapters/PenCacheTests.cs +++ b/Source/Test/HtmlRenderer.Test/Adapters/PenCacheTests.cs @@ -8,11 +8,11 @@ namespace HtmlRenderer.Test.Adapters; public sealed class PenCacheTests { [TestMethod] - public void PaintingADashedBorder_LeavesThePlainPenOfItsColorUnchanged() + public async Task PaintingADashedBorder_LeavesThePlainPenOfItsColorUnchanged() { var adapter = new MockAdapter(); var container = new HtmlContainerInt(adapter) { MaxSize = new RSize(800, 600), PageSize = new RSize(800, 600) }; - container.SetHtml("
"); + await container.SetHtmlAsync("
"); var graphics = new RecordingGraphics(adapter); container.PerformLayout(graphics); container.PerformPaint(graphics); diff --git a/Source/Test/HtmlRenderer.Test/Css/CascadeTests.cs b/Source/Test/HtmlRenderer.Test/Css/CascadeTests.cs index b19799407..123f52f61 100644 --- a/Source/Test/HtmlRenderer.Test/Css/CascadeTests.cs +++ b/Source/Test/HtmlRenderer.Test/Css/CascadeTests.cs @@ -394,7 +394,7 @@ private static CssBox BoxWithStylesheets(string body, Dictionary e.SetStyleSheet = css; }; - container.SetHtml(LayoutHarness.Wrap(body)); + container.SetHtmlAsync(LayoutHarness.Wrap(body)); using (var graphics = new RecordingGraphics()) container.PerformLayout(graphics); diff --git a/Source/Test/HtmlRenderer.Test/Css/ConformanceTests.cs b/Source/Test/HtmlRenderer.Test/Css/ConformanceTests.cs index 9cbc5b669..134ca2646 100644 --- a/Source/Test/HtmlRenderer.Test/Css/ConformanceTests.cs +++ b/Source/Test/HtmlRenderer.Test/Css/ConformanceTests.cs @@ -51,7 +51,7 @@ public void UserStyleSheet_ImportantBeatsAuthorImportant() { var adapter = new MockAdapter(); var container = new HtmlContainerInt(adapter) { MaxSize = new RSize(1000, 4000) }; - container.SetHtml( + container.SetHtmlAsync( "

a

", CssData.Parse(adapter, "p { color: green !important }")).GetAwaiter().GetResult(); using var graphics = new RecordingGraphics(); diff --git a/Source/Test/HtmlRenderer.Test/Css/FontFaceTests.cs b/Source/Test/HtmlRenderer.Test/Css/FontFaceTests.cs index 4ba4e4977..9e83fe05c 100644 --- a/Source/Test/HtmlRenderer.Test/Css/FontFaceTests.cs +++ b/Source/Test/HtmlRenderer.Test/Css/FontFaceTests.cs @@ -131,7 +131,7 @@ private static List FontFaceRequests(string src) var loader = new StyleSheetLoader("@font-face { font-family: F; src: " + src + " }"); var container = new HtmlContainerInt(new MockAdapter { NetworkLoader = loader }) { AvoidAsyncImagesLoading = true }; - container.SetHtml("a").GetAwaiter().GetResult(); + container.SetHtmlAsync("a").GetAwaiter().GetResult(); return loader.Requests; } @@ -142,9 +142,9 @@ private sealed class StyleSheetLoader(string styleSheet) : RNetworkLoader public override RUri? BaseUri => new("https://example.com/doc/index.html"); - public override Task GetPrimaryContents() => Task.FromResult(string.Empty); + public override Task GetPrimaryContentsAsync() => Task.FromResult(string.Empty); - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { Requests.Add(uri.AbsoluteUri); if (uri.AbsoluteUri != "https://example.com/doc/css/fonts.css") diff --git a/Source/Test/HtmlRenderer.Test/Css/SyntaxAndDataTypesTests.cs b/Source/Test/HtmlRenderer.Test/Css/SyntaxAndDataTypesTests.cs index d0eb6c583..83b1ff9be 100644 --- a/Source/Test/HtmlRenderer.Test/Css/SyntaxAndDataTypesTests.cs +++ b/Source/Test/HtmlRenderer.Test/Css/SyntaxAndDataTypesTests.cs @@ -827,7 +827,7 @@ private static string[] RequestedStyleSheets(string css) e.SetStyleSheet = "p { color: green }"; }; - container.SetHtml(Document(css, "

a

")).GetAwaiter().GetResult(); + container.SetHtmlAsync(Document(css, "

a

")).GetAwaiter().GetResult(); return requested.ToArray(); } @@ -843,7 +843,7 @@ private static (CssBox Box, string Href) StyledWithFile(string path, byte[] byte var href = new Uri(file).AbsoluteUri; var container = new HtmlContainerInt(new MockAdapter()) { MaxSize = new RSize(1000, 4000) }; - container.SetHtml($"
a
").GetAwaiter().GetResult(); + container.SetHtmlAsync($"
a
").GetAwaiter().GetResult(); using var graphics = new RecordingGraphics(); container.PerformLayout(graphics); diff --git a/Source/Test/HtmlRenderer.Test/CssModules/CssInlineTests.cs b/Source/Test/HtmlRenderer.Test/CssModules/CssInlineTests.cs index bb3a24241..939881ea4 100644 --- a/Source/Test/HtmlRenderer.Test/CssModules/CssInlineTests.cs +++ b/Source/Test/HtmlRenderer.Test/CssModules/CssInlineTests.cs @@ -178,7 +178,7 @@ private static CssBox Layout(string body) => private static RecordingGraphics Paint(string body) { var container = new HtmlContainerInt(new MockAdapter()) { MaxSize = new RSize(800, 600), PageSize = new RSize(800, 600) }; - container.SetHtml($"{body}"); + container.SetHtmlAsync($"{body}"); var graphics = new RecordingGraphics(); container.PerformLayout(graphics); container.PerformPaint(graphics); diff --git a/Source/Test/HtmlRenderer.Test/CssModules/CssValues5Tests.cs b/Source/Test/HtmlRenderer.Test/CssModules/CssValues5Tests.cs index 6d25368a5..888dd036b 100644 --- a/Source/Test/HtmlRenderer.Test/CssModules/CssValues5Tests.cs +++ b/Source/Test/HtmlRenderer.Test/CssModules/CssValues5Tests.cs @@ -213,7 +213,7 @@ private static List RequestedImages(string css, string body = "
(); var container = new HtmlContainerInt(new MockAdapter()) { MaxSize = new RSize(800, 600) }; container.ImageLoad += (_, e) => requested.Add(e.Src); - container.SetHtml($"{body}"); + container.SetHtmlAsync($"{body}"); using var graphics = new RecordingGraphics(); container.PerformLayout(graphics); container.PerformPaint(graphics); diff --git a/Source/Test/HtmlRenderer.Test/CssModules/CssValuesTests.cs b/Source/Test/HtmlRenderer.Test/CssModules/CssValuesTests.cs index fcb907e68..eacc442a9 100644 --- a/Source/Test/HtmlRenderer.Test/CssModules/CssValuesTests.cs +++ b/Source/Test/HtmlRenderer.Test/CssModules/CssValuesTests.cs @@ -66,7 +66,7 @@ public void EmptyUrl_ResolvesToNoResource(string value) var requested = new List(); var container = new HtmlContainerInt(new MockAdapter()) { MaxSize = new RSize(800, 600) }; container.ImageLoad += (_, e) => requested.Add(e.Src); - container.SetHtml($"
"); + container.SetHtmlAsync($"
"); using var graphics = new RecordingGraphics(); container.PerformLayout(graphics); container.PerformPaint(graphics); diff --git a/Source/Test/HtmlRenderer.Test/CssModules/CssomTests.cs b/Source/Test/HtmlRenderer.Test/CssModules/CssomTests.cs index d743086cc..da60f1a32 100644 --- a/Source/Test/HtmlRenderer.Test/CssModules/CssomTests.cs +++ b/Source/Test/HtmlRenderer.Test/CssModules/CssomTests.cs @@ -63,7 +63,7 @@ private static RColor ColorOf(string html, string contentType = "text/css") MaxSize = new RSize(1000, 4000), AvoidAsyncImagesLoading = true }; - container.SetHtml(html).GetAwaiter().GetResult(); + container.SetHtmlAsync(html).GetAwaiter().GetResult(); using (var graphics = new RecordingGraphics()) container.PerformLayout(graphics); @@ -74,9 +74,9 @@ private sealed class StubLoader(Dictionary resources, string con { public override RUri? BaseUri => new(DocumentUrl); - public override Task GetPrimaryContents() => Task.FromResult(string.Empty); + public override Task GetPrimaryContentsAsync() => Task.FromResult(string.Empty); - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { if (!resources.TryGetValue(uri.AbsoluteUri, out var content)) return Task.FromResult(null); diff --git a/Source/Test/HtmlRenderer.Test/Html/DocumentMetadataTests.cs b/Source/Test/HtmlRenderer.Test/Html/DocumentMetadataTests.cs index 20ac746c5..922cf487f 100644 --- a/Source/Test/HtmlRenderer.Test/Html/DocumentMetadataTests.cs +++ b/Source/Test/HtmlRenderer.Test/Html/DocumentMetadataTests.cs @@ -245,7 +245,7 @@ private static Document Load(string html, Dictionary? resources { var loader = new StubLoader(resources ?? [], contentType); var container = new HtmlContainerInt(new MockAdapter { NetworkLoader = loader }) { MaxSize = new RSize(1000, 4000), AvoidAsyncImagesLoading = true }; - container.SetHtml(html).GetAwaiter().GetResult(); + container.SetHtmlAsync(html).GetAwaiter().GetResult(); using (var graphics = new RecordingGraphics()) container.PerformLayout(graphics); @@ -270,9 +270,9 @@ private sealed class StubLoader(Dictionary resources, string con public override RUri? BaseUri => new(DocumentUrl); - public override Task GetPrimaryContents() => Task.FromResult(string.Empty); + public override Task GetPrimaryContentsAsync() => Task.FromResult(string.Empty); - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { Requested.Add(uri.AbsoluteUri); if (!resources.TryGetValue(uri.AbsoluteUri, out var content)) diff --git a/Source/Test/HtmlRenderer.Test/Html/EmbeddedTestSupport.cs b/Source/Test/HtmlRenderer.Test/Html/EmbeddedTestSupport.cs index 974d2aeb5..fa2e72fd4 100644 --- a/Source/Test/HtmlRenderer.Test/Html/EmbeddedTestSupport.cs +++ b/Source/Test/HtmlRenderer.Test/Html/EmbeddedTestSupport.cs @@ -40,9 +40,9 @@ public sealed class RecordingLoader(string baseUri) : RNetworkLoader public override RUri? BaseUri { get; } = new RUri(baseUri); - public override Task GetPrimaryContents() => Task.FromResult(""); + public override Task GetPrimaryContentsAsync() => Task.FromResult(""); - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { Requests.Add(uri.AbsoluteUri); return Task.FromResult(null); diff --git a/Source/Test/HtmlRenderer.Test/Html/InfrastructureTests.cs b/Source/Test/HtmlRenderer.Test/Html/InfrastructureTests.cs index 48eaa7240..99d1605e2 100644 --- a/Source/Test/HtmlRenderer.Test/Html/InfrastructureTests.cs +++ b/Source/Test/HtmlRenderer.Test/Html/InfrastructureTests.cs @@ -99,7 +99,7 @@ private static Document Load(string body, Dictionary? resources { var loader = new StubLoader(resources ?? [], contentType); var container = new HtmlContainerInt(new MockAdapter { NetworkLoader = loader }) { MaxSize = new RSize(1000, 4000), AvoidAsyncImagesLoading = true, AvoidImagesLateLoading = true }; - container.SetHtml($"{body}").GetAwaiter().GetResult(); + container.SetHtmlAsync($"{body}").GetAwaiter().GetResult(); using (var graphics = new RecordingGraphics()) container.PerformLayout(graphics); @@ -124,9 +124,9 @@ private sealed class StubLoader(Dictionary resources, string con public override RUri? BaseUri => new(DocumentUrl); - public override Task GetPrimaryContents() => Task.FromResult(string.Empty); + public override Task GetPrimaryContentsAsync() => Task.FromResult(string.Empty); - public override Task GetResourceStream(RUri uri) + public override Task GetResourceStreamAsync(RUri uri) { Requested.Add(uri.AbsoluteUri); if (!resources.TryGetValue(uri.AbsoluteUri, out var content)) diff --git a/Source/Test/HtmlRenderer.Test/Html/LinksTests.cs b/Source/Test/HtmlRenderer.Test/Html/LinksTests.cs index 1146b1935..e827620f8 100644 --- a/Source/Test/HtmlRenderer.Test/Html/LinksTests.cs +++ b/Source/Test/HtmlRenderer.Test/Html/LinksTests.cs @@ -137,7 +137,7 @@ private static string ColorWithStylesheet(string link) { var container = new HtmlContainerInt(new MockAdapter()) { MaxSize = new RSize(1000, 1000) }; container.StylesheetLoad += (_, e) => e.SetStyleSheet = "p { color: red }"; - container.SetHtml($"{link}

a

"); + container.SetHtmlAsync($"{link}

a

"); using var graphics = new RecordingGraphics(); container.PerformLayout(graphics); diff --git a/Source/Test/HtmlRenderer.Test/TestSupport/LayoutHarness.cs b/Source/Test/HtmlRenderer.Test/TestSupport/LayoutHarness.cs index b97bbb4a3..32440c52a 100644 --- a/Source/Test/HtmlRenderer.Test/TestSupport/LayoutHarness.cs +++ b/Source/Test/HtmlRenderer.Test/TestSupport/LayoutHarness.cs @@ -15,7 +15,7 @@ internal static class LayoutHarness /// Lays out at × pixels. /// /// - /// Optional: run against the parsed box tree's root after SetHtml and before layout, for a test that + /// Optional: run against the parsed box tree's root after SetHtmlAsync and before layout, for a test that /// has to put something in the tree the parser cannot produce. /// /// @@ -56,7 +56,7 @@ internal static (CssBox Root, HtmlContainerInt Container) Layout( container.PageSize = new RSize(maxWidth, pageHeight.Value); } - container.SetHtml(html); + container.SetHtmlAsync(html); if (prepare is not null) { From 69d21530e66aed8064f796cbcd15b9f6bed0c57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Mon, 23 Nov 2026 23:54:13 +0100 Subject: [PATCH 3/3] Point paint handlers to the container in the HtmlRender docs --- Source/HtmlRenderer.WPF/HtmlRender.cs | 10 ++++++++ Source/HtmlRenderer.WinForms/HtmlRender.cs | 30 ++++++++++++++++++++++ Source/HtmlRenderer.WinUI/HtmlRender.cs | 10 ++++++++ 3 files changed, 50 insertions(+) diff --git a/Source/HtmlRenderer.WPF/HtmlRender.cs b/Source/HtmlRenderer.WPF/HtmlRender.cs index c403d3924..d3c6247c2 100644 --- a/Source/HtmlRenderer.WPF/HtmlRender.cs +++ b/Source/HtmlRenderer.WPF/HtmlRender.cs @@ -176,6 +176,11 @@ public static async Task MeasureAsync(string html, double maxWidth = 0, Cs /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the drawing context is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderAsync(DrawingContext g, string html, double left = 0, double top = 0, double maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -199,6 +204,11 @@ public static Task RenderAsync(DrawingContext g, string html, double left /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the drawing context is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderAsync(DrawingContext g, string html, Point location, Size maxSize, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { diff --git a/Source/HtmlRenderer.WinForms/HtmlRender.cs b/Source/HtmlRenderer.WinForms/HtmlRender.cs index c7c074df9..45647c8f4 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRender.cs +++ b/Source/HtmlRenderer.WinForms/HtmlRender.cs @@ -148,6 +148,11 @@ public static CssData ParseStyleSheet(string stylesheet, bool combineWithDefault /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the size required for the html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the graphics is disposed. Load once with instead, + /// then call and when painting. + /// public static Task MeasureAsync(Graphics g, string html, float maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -168,6 +173,11 @@ public static Task MeasureAsync(Graphics g, string html, float maxWidth = /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the size required for the html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the graphics is disposed. Load once with instead, + /// then call and when painting. + /// public static Task MeasureGdiPlusAsync(Graphics g, string html, float maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -191,6 +201,11 @@ public static Task MeasureGdiPlusAsync(Graphics g, string html, float max /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the graphics is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderAsync(Graphics g, string html, float left = 0, float top = 0, float maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -215,6 +230,11 @@ public static Task RenderAsync(Graphics g, string html, float left = 0, f /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the graphics is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderAsync(Graphics g, string html, PointF location, SizeF maxSize, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -238,6 +258,11 @@ public static Task RenderAsync(Graphics g, string html, PointF location, /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the graphics is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderGdiPlusAsync(Graphics g, string html, float left = 0, float top = 0, float maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -262,6 +287,11 @@ public static Task RenderGdiPlusAsync(Graphics g, string html, float left /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the graphics is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderGdiPlusAsync(Graphics g, string html, PointF location, SizeF maxSize, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { diff --git a/Source/HtmlRenderer.WinUI/HtmlRender.cs b/Source/HtmlRenderer.WinUI/HtmlRender.cs index 0c82d3e5f..60f9afc6d 100644 --- a/Source/HtmlRenderer.WinUI/HtmlRender.cs +++ b/Source/HtmlRenderer.WinUI/HtmlRender.cs @@ -126,6 +126,11 @@ public static async Task MeasureAsync(string html, double maxWidth = 0, Cs /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the drawing session is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderAsync(CanvasDrawingSession g, string html, double left = 0, double top = 0, double maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -144,6 +149,11 @@ public static Task RenderAsync(CanvasDrawingSession g, string html, double /// optional: can be used to overwrite stylesheet resolution logic /// optional: can be used to overwrite image resolution logic /// the actual size of the rendered html + /// + /// Don't call this from a paint handler: loading stylesheets and images can finish after the handler + /// returned and the drawing session is disposed. Load once with instead, + /// then call and when painting. + /// public static Task RenderAsync(CanvasDrawingSession g, string html, Point location, Size maxSize, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) {