Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added examples for Async.WebExtensions #12644

Merged
merged 3 commits into from
Jan 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions src/fsharp/FSharp.Core/async.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,18 @@ namespace Microsoft.FSharp.Control
/// <summary>Returns an asynchronous computation that, when run, will wait for a response to the given WebRequest.</summary>
/// <returns>An asynchronous computation that waits for response to the <c>WebRequest</c>.</returns>
///
/// <example-tbd></example-tbd>
/// <example id="get-response">
/// <code lang="fsharp">
/// open System.Net
/// open System.IO
/// let responseStreamToString = fun (responseStream : WebResponse) ->
/// let reader = new StreamReader(responseStream.GetResponseStream())
/// reader.ReadToEnd()
/// let webRequest = WebRequest.Create("https://www.w3.org")
/// let result = webRequest.AsyncGetResponse() |> Async.RunSynchronously |> responseStreamToString
/// </code>
/// </example>
/// Gets the web response asynchronously and converts response stream to string
[<CompiledName("AsyncGetResponse")>] // give the extension member a nice, unmangled compiled name, unique within this module
member AsyncGetResponse : unit -> Async<System.Net.WebResponse>

Expand All @@ -1084,7 +1095,14 @@ namespace Microsoft.FSharp.Control
///
/// <returns>An asynchronous computation that will wait for the download of the URI.</returns>
///
/// <example-tbd></example-tbd>
/// <example id="async-download-string">
/// <code lang="fsharp">
/// open System
/// let client = new WebClient()
/// Uri("https://www.w3.org") |> client.AsyncDownloadString |> Async.RunSynchronously
/// </code>
/// This will download the server response from https://www.w3.org
/// </example>
[<CompiledName("AsyncDownloadString")>] // give the extension member a nice, unmangled compiled name, unique within this module
member AsyncDownloadString : address:System.Uri -> Async<string>

Expand All @@ -1094,7 +1112,16 @@ namespace Microsoft.FSharp.Control
///
/// <returns>An asynchronous computation that will wait for the download of the URI.</returns>
///
/// <example-tbd></example-tbd>
/// <example id="async-download-data">
/// <code lang="fsharp">
/// open System.Net
/// open System.Text
/// open System
/// let client = new WebClient()
/// client.AsyncDownloadData(Uri("https://www.w3.org")) |> Async.RunSynchronously |> Encoding.ASCII.GetString
/// </code>
/// </example>
/// Downloads the data in bytes and decodes it to a string.
[<CompiledName("AsyncDownloadData")>] // give the extension member a nice, unmangled compiled name, unique within this module
member AsyncDownloadData : address:System.Uri -> Async<byte[]>

Expand All @@ -1105,7 +1132,15 @@ namespace Microsoft.FSharp.Control
///
/// <returns>An asynchronous computation that will wait for the download of the URI to specified file.</returns>
///
/// <example-tbd></example-tbd>
/// <example id="async-download-file">
/// <code lang="fsharp">
/// open System.Net
/// open System
/// let client = new WebClient()
/// Uri("https://www.w3.com") |> fun x -> client.AsyncDownloadFile(x, "output.html") |> Async.RunSynchronouslyl
/// </code>
/// This will download the server response as a file and output it as output.html
/// </example>
[<CompiledName("AsyncDownloadFile")>] // give the extension member a nice, unmangled compiled name, unique within this module
member AsyncDownloadFile : address:System.Uri * fileName: string -> Async<unit>

Expand Down