From 32b5a35a4d5003a9d5a8b2060c944482f05f9f1e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 4 Apr 2026 10:47:34 +0000 Subject: [PATCH] eng: replace deprecated WebClient with HttpClient; bump Newtonsoft.Json and System.Memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace System.Net.WebClient with System.Net.Http.HttpClient in createImageSaver (BuildCommand.fs). Removes #nowarn "44" suppression and uses GetByteArrayAsync/File.WriteAllBytes instead of the deprecated DownloadFile API. - Bump Newtonsoft.Json transitive-dep pin: 13.0.3 → 13.0.4 - Bump System.Memory transitive-dep pin: 4.5.5 → 4.6.3 Build: succeeded (0 warnings, 0 errors) Tests: all pass (281 Markdown, 30 CodeFormat, 12 fsdocs-tool, 143 Literate, 88 ApiDocs) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Directory.Packages.props | 4 ++-- RELEASE_NOTES.md | 5 +++++ src/fsdocs-tool/BuildCommand.fs | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 0123a257..d52396a1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -14,9 +14,9 @@ - + - + diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a6dc6d09..565049ca 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Changed +* Replace deprecated `System.Net.WebClient` with `System.Net.Http.HttpClient` in the image downloader used by `--saveimages`. Removes the `#nowarn "44"` suppression. +* Bump `Newtonsoft.Json` transitive-dependency pin from 13.0.3 to 13.0.4. +* Bump `System.Memory` transitive-dependency pin from 4.5.5 to 4.6.3. + ## [22.0.0-alpha.3] - 2026-04-02 ### Fixed diff --git a/src/fsdocs-tool/BuildCommand.fs b/src/fsdocs-tool/BuildCommand.fs index b5abd1db..2940f844 100644 --- a/src/fsdocs-tool/BuildCommand.fs +++ b/src/fsdocs-tool/BuildCommand.fs @@ -8,6 +8,7 @@ open System.Diagnostics open System.IO open System.Globalization open System.Net +open System.Net.Http open System.Reflection open System.Text @@ -29,7 +30,6 @@ open Suave.Filters open Suave.Logging open FSharp.Formatting.Markdown -#nowarn "44" // Obsolete WebClient /// Convert markdown, script and other content into a static site type internal DocContent @@ -48,7 +48,7 @@ type internal DocContent let createImageSaver (rootOutputFolderAsGiven) = // Download images so that they can be embedded - let wc = new WebClient() + let http = new HttpClient() let mutable counter = 0 fun (url: string) -> @@ -65,7 +65,8 @@ type internal DocContent ensureDirectory (sprintf "%s/savedimages" rootOutputFolderAsGiven) printfn "downloading %s --> %s" url fn - wc.DownloadFile(url, fn) + let bytes = http.GetByteArrayAsync(url).GetAwaiter().GetResult() + File.WriteAllBytes(fn, bytes) url2 else url