Skip to content

Replace legacy WebApi.Client multipart parsing with modern WebUtilities - #156

Merged
adrianiftode merged 1 commit into
masterfrom
features/remove-dependency-to-webapi-client
Jul 28, 2026
Merged

Replace legacy WebApi.Client multipart parsing with modern WebUtilities#156
adrianiftode merged 1 commit into
masterfrom
features/remove-dependency-to-webapi-client

Conversation

@adrianiftode

Copy link
Copy Markdown
Owner

Removes the legacy Microsoft.AspNet.WebApi.Client package dependency and its high-allocation MultipartMemoryStreamProvider execution path.

  • Replaces ReadAsMultipartAsync with an efficient custom extension utilizing MultipartReader from Microsoft.AspNetCore.WebUtilities.
  • Safely isolates and eagerly buffers individual multipart section data into memory streams to prevent Unexpected end of Stream exceptions during asynchronous iterations.
  • Preserves downstream HttpContent polymorphic formatting and streaming architectures across all multi-targeted platforms (netstandard2.0, net8.0, and net10.0).
  • Keeps the modern .NET targets clear of unneeded dependencies by cleanly scoping legacy package assets to the .NET Standard target.

Before

λ dotnet list src/FluentAssertions.Web/FluentAssertions.Web.csproj package --include-transitive

Build succeeded in 3.6s
Restore complete (0.6s)

Build succeeded in 0.9s
Project 'FluentAssertions.Web' has the following package references
   [netstandard2.0]:
   Top-level Package             Requested       Resolved
   > FluentAssertions            [6.5.1,8.0.0)   6.5.1
   > NETStandard.Library   (A)   [2.0.3, )       2.0.3

   Transitive Package                            Resolved
   > Microsoft.AspNet.WebApi.Client              6.0.0
   > Microsoft.Bcl.AsyncInterfaces               8.0.0
   > Microsoft.NETCore.Platforms                 1.1.0
   > Newtonsoft.Json                             13.0.3
   > Newtonsoft.Json.Bson                        1.0.2
   > System.Buffers                              4.5.1
   > System.Memory                               4.5.5
   > System.Net.Http.Json                        8.0.1
   > System.Numerics.Vectors                     4.4.0
   > System.Runtime.CompilerServices.Unsafe      6.0.0
   > System.Text.Encodings.Web                   8.0.0
   > System.Text.Json                            8.0.5
   > System.Threading.Tasks.Extensions           4.5.4

(A) : Auto-referenced package.

After

λ dotnet list src/FluentAssertions.Web/FluentAssertions.Web.csproj package --include-transitive
Restore complete (0.7s)

Build succeeded in 1.2s
Project 'FluentAssertions.Web' has the following package references
   [netstandard2.0]:
   Top-level Package             Requested       Resolved
   > FluentAssertions            [6.5.1,8.0.0)   6.5.1
   > NETStandard.Library   (A)   [2.0.3, )       2.0.3

   Transitive Package                            Resolved
   > Microsoft.AspNetCore.WebUtilities           2.3.0
   > Microsoft.Bcl.AsyncInterfaces               8.0.0
   > Microsoft.Extensions.Primitives             8.0.0
   > Microsoft.Net.Http.Headers                  2.3.0
   > Microsoft.NETCore.Platforms                 1.1.0
   > System.Buffers                              4.6.0
   > System.Memory                               4.5.5
   > System.Net.Http.Json                        8.0.1
   > System.Numerics.Vectors                     4.4.0
   > System.Runtime.CompilerServices.Unsafe      6.0.0
   > System.Text.Encodings.Web                   8.0.0
   > System.Text.Json                            8.0.5
   > System.Threading.Tasks.Extensions           4.5.4

Removes the legacy `Microsoft.AspNet.WebApi.Client` package dependency and its high-allocation `MultipartMemoryStreamProvider` execution path.

- Replaces `ReadAsMultipartAsync` with an efficient custom extension utilizing `MultipartReader` from `Microsoft.AspNetCore.WebUtilities`.
- Safely isolates and eagerly buffers individual multipart section data into memory streams to prevent `Unexpected end of Stream` exceptions during asynchronous iterations.
- Preserves downstream `HttpContent` polymorphic formatting and streaming architectures across all multi-targeted platforms (`netstandard2.0`, `net8.0`, and `net10.0`).
- Keeps the modern .NET targets clear of unneeded dependencies by cleanly scoping legacy package assets to the .NET Standard target.
@adrianiftode
adrianiftode force-pushed the features/remove-dependency-to-webapi-client branch from 6036fce to 3603df4 Compare July 28, 2026 09:37
@adrianiftode
adrianiftode merged commit d2d33bd into master Jul 28, 2026
1 check passed
@jetersen

Copy link
Copy Markdown
Contributor

Thanks! That's an even cleaner solution then my PR 😅

@adrianiftode

adrianiftode commented Jul 29, 2026 via email

Copy link
Copy Markdown
Owner Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants