-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add TextReader/Writer Memory-based virtuals #24434
Add TextReader/Writer Memory-based virtuals #24434
Conversation
@@ -117,6 +118,35 @@ public override int Read(char[] buffer, int index, int count) | |||
return n; | |||
} | |||
|
|||
public override int Read(Span<char> destination) | |||
{ | |||
if (GetType() != typeof(StringReader)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add the comment on why we do the check for derived classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll add comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1435,8 +1435,12 @@ public partial class StringReader : System.IO.TextReader | |||
public override int Peek() { throw null; } | |||
public override int Read() { throw null; } | |||
public override int Read(char[] buffer, int index, int count) { throw null; } | |||
public override int Read(System.Span<char> destination) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is specifying System required in the type name? If not, remove (here and elsewhere) to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the full type name is consistent with how the ref generator tool generates the code.
@@ -1523,6 +1533,7 @@ public abstract partial class TextWriter : System.MarshalByRefObject, System.IDi | |||
public virtual System.Threading.Tasks.Task WriteAsync(char value) { throw null; } | |||
public System.Threading.Tasks.Task WriteAsync(char[] buffer) { throw null; } | |||
public virtual System.Threading.Tasks.Task WriteAsync(char[] buffer, int index, int count) { throw null; } | |||
public virtual System.Threading.Tasks.Task WriteAsync(ReadOnlyMemory<char> source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the full type name is consistent with how the ref generator tool generates the code.
There are some places where the full type name is not being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix those.
@dotnet/dnceng, I'm seeing an error I've not seen before. The given tests completed successfully, and then there was some kind of connection failure in the infrastructure:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dotnet/dnceng, another example of the tests finishing successfully and then the leg failing:
|
@dotnet/dnceng, and an "Execution may have been compromised" error?
|
* Add Memory-based Read/WriteAsync virtuals to TextReader/Writer * Override Span/Memory-based APIs on StringReader/Writer * Address PR feedback
Just hit a Needing/Wanting Cancellation token support for StreamReader.ReadLineAsync() just now, Was it added in 2.1.0 >> only, or still open-not in yet? |
These overloads were added in 2.1. |
* Add Memory-based Read/WriteAsync virtuals to TextReader/Writer * Override Span/Memory-based APIs on StringReader/Writer * Address PR feedback Commit migrated from dotnet/corefx@03d7056
And override both the Span and Memory-based virtuals on StringReader and StringWriter.
Fixes https://github.com/dotnet/corefx/issues/22410
Fixes https://github.com/dotnet/corefx/issues/22406
Fixes https://github.com/dotnet/corefx/issues/22411
cc: @JeremyKuhne, @pjanotti, @KrzysztofCwalina, @ahsonkhan