Remove Microsoft.AspNetCore.Http dependency#42
Merged
Conversation
28b17d1 to
35ac4e2
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the Microsoft.AspNetCore.Http dependency from Atc.Rest.Client (netstandard2.0) to enable use in browser-sandboxed and non-ASP.NET environments (e.g., Blazor WASM, MAUI), while keeping file upload support via a new IFileContent abstraction plus reflection-based “duck typing”.
Changes:
- Remove
Microsoft.AspNetCore.Httpusage and introduceIFileContent+ reflection wrapper to support file-like inputs without ASP.NET Core packages. - Add/adjust unit tests for the new file upload behavior and update README documentation.
- Bump several package/analyzer versions and add a custom analyzer rule setting.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Directory.Build.props | Bumps Atc.Test package version used by tests. |
| test/Atc.Rest.Client.Tests/Serialization/JsonSerializerOptionsExtensionsTests.cs | Cleans up usings/formatting; relies on global Json serialization usings. |
| test/Atc.Rest.Client.Tests/GlobalUsings.cs | Adds System.Text.Json.Serialization as a test global using. |
| test/Atc.Rest.Client.Tests/Builder/MessageResponseBuilderStreamingTests.cs | Formatting-only changes to method signatures. |
| test/Atc.Rest.Client.Tests/Builder/MessageResponseBuilderBinaryTests.cs | Formatting-only changes to method signatures. |
| test/Atc.Rest.Client.Tests/Builder/MessageRequestBuilderTests.cs | Formatting changes; no behavioral change indicated. |
| test/Atc.Rest.Client.Tests/Builder/MessageRequestBuilderMultipartTests.cs | Minor formatting change in test helper. |
| test/Atc.Rest.Client.Tests/Builder/MessageRequestBuilderFileContentTests.cs | New tests covering IFileContent and duck-typed file-like objects. |
| test/Atc.Rest.Client.Tests/Builder/MessageRequestBuilderAdditionalTests.cs | Minor formatting change in test helper. |
| test/Atc.Rest.Client.Tests/Builder/HttpMessageFactoryTests.cs | Formatting-only changes to method signature. |
| test/Atc.Rest.Client.Tests/Atc.Rest.Client.Tests.csproj | Bumps Microsoft.Extensions.DependencyInjection package version for tests. |
| src/Directory.Build.props | Bumps SourceLink version. |
| src/Atc.Rest.Client/Serialization/IContractSerializer.cs | Formatting-only signature changes. |
| src/Atc.Rest.Client/Serialization/DefaultJsonContractSerializer.cs | Formatting-only signature changes. |
| src/Atc.Rest.Client/RestClientDeserializationException.cs | Formatting-only constructor wrapping. |
| src/Atc.Rest.Client/IFileContent.cs | Adds new IFileContent interface for file uploads via WithBody(). |
| src/Atc.Rest.Client/GlobalUsings.cs | Removes global using of Microsoft.AspNetCore.Http. |
| src/Atc.Rest.Client/Builder/ReflectedFileContent.cs | Adds internal wrapper to treat file-like objects as IFileContent via reflection. |
| src/Atc.Rest.Client/Builder/MessageResponseBuilder.cs | Formatting-only signature changes. |
| src/Atc.Rest.Client/Builder/MessageRequestBuilder.cs | Replaces IFormFile handling with IFileContent + reflection-based wrapping. |
| src/Atc.Rest.Client/Builder/IMessageResponseBuilder.cs | Formatting-only signature changes. |
| src/Atc.Rest.Client/Builder/IMessageRequestBuilder.cs | Formatting-only signature changes. |
| src/Atc.Rest.Client/Builder/IHttpMessageFactory.cs | Formatting-only signature changes. |
| src/Atc.Rest.Client/Builder/HttpMessageFactory.cs | Formatting-only signature changes. |
| src/Atc.Rest.Client/Atc.Rest.Client.csproj | Removes Microsoft.AspNetCore.Http package reference; bumps dependency versions. |
| README.md | Documents IFileContent and duck-typed file uploads with WithBody(). |
| Directory.Build.props | Updates analyzers; adds Atc.Analyzer PackageReference. |
| .editorconfig | Adds configuration for custom analyzer rule ATC210.max_line_length. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix trailing space in Atc.Analyzer package reference - Fix undefined variable in README IFileContent example - Improve ReflectedFileContent to handle IBrowserFile's maxAllowedSize parameter - Replace BinaryReader with MemoryStream copy for non-seekable streams
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.
Removing
Microsoft.AspNetCore.HttpfromAtc.Rest.ClientMotivation
Atc.Rest.Clienttargetsnetstandard2.0, which should make it usable from Blazor WebAssembly.However, the package reference to
Microsoft.AspNetCore.Http(v2.3.9) prevents this becauseMicrosoft.AspNetCore.Httpis not compatible with the browser sandbox (it depends on server-sideprimitives that do not exist in WASM).
Removing this dependency would allow
Atc.Rest.Clientto be used in: