Replace Microsoft.AspNet.WebApi.Client with built-in abstractions#134
Open
jmbryan4 wants to merge 2 commits intoPathoschild:developfrom
Open
Replace Microsoft.AspNet.WebApi.Client with built-in abstractions#134jmbryan4 wants to merge 2 commits intoPathoschild:developfrom
jmbryan4 wants to merge 2 commits intoPathoschild:developfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Microsoft.AspNet.WebApi.Clientdependency (end of support since July 2019, no releases since Oct 2020) - https://github.com/aspnet/AspNetWebStackSystem.Net.Http.Formattingtypes with lightweight built-in abstractions (IMediaTypeFormatter,MediaTypeFormatterCollection,JsonMediaTypeFormatter,XmlMediaTypeFormatter,FormatterContent<T>)XmlMediaTypeFormattersupports bothDataContractSerializer(default) andXmlSerializerviaUseXmlSerializerproperty, matching the original APInetstandard1.3;netstandard2.0;net452;net5.0tonetstandard2.0;net8.0Newtonsoft.Jsonas an explicit dependency for backward compatibility (a future update could change to use System.Text.Json)Resolves #133