Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PipeWriter overloads to Json #101461

Merged
merged 18 commits into from
May 13, 2024
Merged

Conversation

BrennanConroy
Copy link
Member

Adds PipeWriter part of #68586.
Also closes #28760.

No new unique tests were added so far, just hooked into existing test groups. Could definitely add a few new tests centered around writes that span buffers, as well as partial writes. Pointers to where those should live, and if there are tests like that would be helpful.

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@@ -220,7 +221,6 @@
Microsoft.Extensions.Options.DataAnnotations;
Microsoft.Extensions.Primitives;
System.Diagnostics.EventLog;
System.IO.Pipelines;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these properties do, out of curiosity?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property makes the assembly get included in the transport package for aspnetcore. Aspnetcore includes everything from that transport package in their shared framework.

Given that you move this assembly inbox into Microsoft.NETCore.App, this change is correct.

@eiriktsarpalis
Copy link
Member

Could definitely add a few new tests centered around writes that span buffers, as well as partial writes. Pointers to where those should live, and if there are tests like that would be helpful.

I think this warrants a new test class, probably a set of files that sit next to Stream.WriteTests.cs and Stream.ReadTests.cs. Echoing that naming convention, perhaps Pipes.WriteTests.cs?

Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Any changes you need to make on your side before I get this merged?

@BrennanConroy
Copy link
Member Author

Thanks! Any changes you need to make on your side before I get this merged?

Nope! All good here 😄

eiriktsarpalis and others added 2 commits May 11, 2024 19:29
…rialization/Pipe.WriteTests.cs

Co-authored-by: David Fowler <davidfowl@gmail.com>
Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits

@eiriktsarpalis eiriktsarpalis merged commit 741af4a into dotnet:main May 13, 2024
83 checks passed
@BrennanConroy BrennanConroy deleted the brecon/pipe branch May 13, 2024 15:58
@eiriktsarpalis
Copy link
Member

@wtgodbe heads up, the PR just got merged.

ThrowHelper.ThrowOperationCanceledException_PipeWriteCanceled();
}

ThrowHelper.ThrowOperationCanceledException_PipeWriteCompleted();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to throw in this case? I think this is going to end up throwing a lot of unwanted exceptions.

For normal HTTP/1.1 response bodies, this just means that the client has closed the connection. BodyWriter.FlushAsync with return a completed flush result, but Body.FlushAsync would not throw because it doesn't want to create a bunch of unnecessary noise in applications writing small responses. Things that actually care about connection close like the static files middleware subscribe to RequestAborted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right @halter73. Let's remove this exception in a follow up PR.

Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
* Add PipeWriter overloads to Json

* test

* organize and tests

* cleanup

* FlushThreshold

* cleanup

* system.buffer is special

* tests

* fixup

* de-dupe

* minor

* fb

* no async!

* Update src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Pipe.WriteTests.cs

Co-authored-by: David Fowler <davidfowl@gmail.com>

---------

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
Co-authored-by: David Fowler <davidfowl@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider moving System.IO.Pipelines into the shared framework
7 participants