Skip to content

Commit f2b601d

Browse files
dsymegithub-actions[bot]Copilot
authored
eng: replace deprecated WebClient with HttpClient; bump Newtonsoft.Json and System.Memory (#1144)
- 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: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8d7f4ef commit f2b601d

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="" PrivateAssets="all" />
1515
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="" PrivateAssets="all" />
1616
<PackageVersion Include="Ionide.ProjInfo" Version="0.74.2" />
17-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
17+
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
1818
<PackageVersion Include="Suave" Version="2.6.2" />
19-
<PackageVersion Include="System.Memory" Version="4.5.5" />
19+
<PackageVersion Include="System.Memory" Version="4.6.3" />
2020
<PackageVersion Include="System.Text.Json" Version="10.0.5" />
2121
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
2222
<PackageVersion Include="NUnit" Version="4.5.1" />

RELEASE_NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [Unreleased]
44

5+
### Changed
6+
* Replace deprecated `System.Net.WebClient` with `System.Net.Http.HttpClient` in the image downloader used by `--saveimages`. Removes the `#nowarn "44"` suppression.
7+
* Bump `Newtonsoft.Json` transitive-dependency pin from 13.0.3 to 13.0.4.
8+
* Bump `System.Memory` transitive-dependency pin from 4.5.5 to 4.6.3.0
9+
510
### Fixed
611
* Fix `Markdown.ToMd` silently dropping `EmbedParagraphs` nodes: the serialiser now delegates to the node's `Render()` method and formats the resulting paragraphs, consistent with the HTML and LaTeX back-ends.
712
* Fix `Markdown.ToMd` dropping link titles in `DirectLink` and `DirectImage` spans. Links with a title attribute (e.g. `[text](url "title")`) now round-trip correctly; without this fix the title was silently discarded on serialisation.

src/fsdocs-tool/BuildCommand.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ open System.Diagnostics
88
open System.IO
99
open System.Globalization
1010
open System.Net
11+
open System.Net.Http
1112
open System.Reflection
1213
open System.Text
1314

@@ -29,7 +30,6 @@ open Suave.Filters
2930
open Suave.Logging
3031
open FSharp.Formatting.Markdown
3132

32-
#nowarn "44" // Obsolete WebClient
3333

3434
/// Convert markdown, script and other content into a static site
3535
type internal DocContent
@@ -48,7 +48,7 @@ type internal DocContent
4848

4949
let createImageSaver (rootOutputFolderAsGiven) =
5050
// Download images so that they can be embedded
51-
let wc = new WebClient()
51+
let http = new HttpClient()
5252
let mutable counter = 0
5353

5454
fun (url: string) ->
@@ -65,7 +65,8 @@ type internal DocContent
6565

6666
ensureDirectory (sprintf "%s/savedimages" rootOutputFolderAsGiven)
6767
printfn "downloading %s --> %s" url fn
68-
wc.DownloadFile(url, fn)
68+
let bytes = http.GetByteArrayAsync(url).GetAwaiter().GetResult()
69+
File.WriteAllBytes(fn, bytes)
6970
url2
7071
else
7172
url

0 commit comments

Comments
 (0)