Skip to content

Add the Async suffix to every public method returning a Task - #304

Open
eXpl0it3r wants to merge 3 commits into
masterfrom
feature/async-naming
Open

eXpl0it3r wants to merge 3 commits into
masterfrom
feature/async-naming

Conversation

@eXpl0it3r

Copy link
Copy Markdown
Collaborator

Description

2.0 is a bit mixed at the moment: HtmlRender.RenderAsync, MeasureAsync etc. and SetTextAsync have the suffix, while HtmlContainer.SetHtml, PdfGenerator.GeneratePdf and the adapter's network API return a Task without it. As such every public method returning a Task now gets the Async suffix, which is still what the TAP guidance and the BCL do for libraries:

  • SetHtml becomes SetHtmlAsync on HtmlContainerInt and the WinForms, WPF, WinUI and PdfSharp containers
  • PdfGenerator.GeneratePdf and AddPdfPages become GeneratePdfAsync and AddPdfPagesAsync
  • RNetworkLoader.GetPrimaryContents and GetResourceStream become GetPrimaryContentsAsync and GetResourceStreamAsync
  • RAdapter.GetResourceStream and AddFontFace become GetResourceStreamAsync and AddFontFaceAsync

1.5 and 1.6 had no public method returning a Task, so none of the old names ever returned one in a release. Since the return type changes with 2.0 anyway, [Obsolete] forwarders wouldn't keep anyone's code compiling, as such there are none.

Additionally:

  • PdfGenerator.ParseStyleSheet (PdfSharp) only wrapped its result in Task.FromResult, it's synchronous now, like ParseStyleSheet of the other adapters
  • The HtmlRender overloads that draw onto a Graphics, DrawingContext or CanvasDrawingSession say in their remarks, that they shouldn't be called from a paint handler, and point to HtmlContainer.SetHtmlAsync plus PerformLayout and PerformPaint instead. Once something loads over the network, the await completes after the paint handler returned.

The line "the names stay the same" in #259 needs an update once this is merged.

How to test this PR?

CI should succeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant