Skip to content

Replace Microsoft.AspNet.WebApi.Client with built-in abstractions#134

Open
jmbryan4 wants to merge 2 commits intoPathoschild:developfrom
jmbryan4:remove-webapi-client-dependency
Open

Replace Microsoft.AspNet.WebApi.Client with built-in abstractions#134
jmbryan4 wants to merge 2 commits intoPathoschild:developfrom
jmbryan4:remove-webapi-client-dependency

Conversation

@jmbryan4
Copy link

@jmbryan4 jmbryan4 commented Feb 27, 2026

Summary

  • Remove Microsoft.AspNet.WebApi.Client dependency (end of support since July 2019, no releases since Oct 2020) - https://github.com/aspnet/AspNetWebStack
  • Replace System.Net.Http.Formatting types with lightweight built-in abstractions (IMediaTypeFormatter, MediaTypeFormatterCollection, JsonMediaTypeFormatter, XmlMediaTypeFormatter, FormatterContent<T>)
  • XmlMediaTypeFormatter supports both DataContractSerializer (default) and XmlSerializer via UseXmlSerializer property, matching the original API
  • Update target frameworks from netstandard1.3;netstandard2.0;net452;net5.0 to netstandard2.0;net8.0
  • Bump version to 5.0.0
  • Keep Newtonsoft.Json as an explicit dependency for backward compatibility (a future update could change to use System.Text.Json)

Resolves #133

…ctions

Remove the legacy Microsoft.AspNet.WebApi.Client dependency (end of
support since 2019, no releases since 2020) and replace it with
lightweight built-in abstractions:

- New IMediaTypeFormatter interface replacing System.Net.Http.Formatting.MediaTypeFormatter
- New MediaTypeFormatterCollection replacing the System.Net.Http.Formatting version
- New JsonMediaTypeFormatter using Newtonsoft.Json directly
- New XmlMediaTypeFormatter using DataContractSerializer
- New FormatterContent<T> replacing ObjectContent<T>
- New HttpContentExtensions.ReadAsAsync<T> replacing the extension from System.Net.Http.Formatting

Target frameworks updated from netstandard1.3/netstandard2.0/net452/net5.0
to netstandard2.0/net8.0. Version bumped to 5.0.0.

Resolves Pathoschild#133.
- Make MediaTypeFormatterBase.ReadFromStreamAsync/WriteToStreamAsync virtual
  and replace TaskCompletionSource anti-pattern with Task.FromResult/CompletedTask
- Rewrite JsonMediaTypeFormatter with async stream read/write via
  ReadToEndAsync + JsonConvert and Stream.WriteAsync
- Rewrite XmlMediaTypeFormatter with async CopyToAsync buffering strategy
- Add async overrides to PlainTextFormatter using ReadToEndAsync/WriteAsync
  and fix leaveOpen:true on StreamReader/StreamWriter constructors
- Add CancellationToken-accepting SerializeToStreamAsync override to
  FormatterContent on net8.0
- Flow CancellationToken on net8.0 throughout all async formatter methods
- Add 55 new tests covering JsonMediaTypeFormatter, XmlMediaTypeFormatter,
  MediaTypeFormatterCollection, FormatterContent, HttpContentExtensions,
  and expanded PlainTextFormatter coverage
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.

Replace Microsoft.AspNet.WebApi.Client with built-in abstractions

1 participant