Skip to content

Override IndentedTextWriter APIs that write spans.#130586

Open
teo-tsirpanis wants to merge 4 commits into
dotnet:mainfrom
teo-tsirpanis:indentedtextwriter-span-override
Open

Override IndentedTextWriter APIs that write spans.#130586
teo-tsirpanis wants to merge 4 commits into
dotnet:mainfrom
teo-tsirpanis:indentedtextwriter-span-override

Conversation

@teo-tsirpanis

Copy link
Copy Markdown
Contributor

Saves an array pool rent/return cycle and copying.

Saves an array pool rent/return cycle and copying.
Copilot AI review requested due to automatic review settings July 12, 2026 21:00
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 12, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates System.CodeDom.Compiler.IndentedTextWriter to override the span-based TextWriter write APIs so span writes can be forwarded directly to the inner writer without the base TextWriter array-pool rent/copy path.

Changes:

  • Add IndentedTextWriter.Write(ReadOnlySpan<char>) and WriteLine(ReadOnlySpan<char>) overrides in CoreLib.
  • Add the corresponding members to the System.Runtime reference assembly for IndentedTextWriter.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/libraries/System.Private.CoreLib/src/System/CodeDom/Compiler/IndentedTextWriter.cs Adds span-based Write / WriteLine overrides to avoid the TextWriter pooling/copy path.
src/libraries/System.Runtime/ref/System.Runtime.cs Updates the public contract to include the new IndentedTextWriter override members.

public override void Write(char value) { }
public override void Write(char[]? buffer) { }
public override void Write(char[] buffer, int index, int count) { }
public override void Write(ReadOnlySpan<char> buffer) { }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think overriding a method needs approval.

Comment thread src/libraries/System.Runtime/ref/System.Runtime.cs Outdated
Comment thread src/libraries/System.Runtime/ref/System.Runtime.cs Outdated
Copilot AI review requested due to automatic review settings July 12, 2026 21:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Fixes race conditions if a synchronous operation is queued to run on another thread.
Copilot AI review requested due to automatic review settings July 12, 2026 22:03
@teo-tsirpanis teo-tsirpanis force-pushed the indentedtextwriter-span-override branch from 8569c2b to 1f0b6d5 Compare July 12, 2026 22:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/libraries/System.Runtime/tests/System.IO.Tests/IndentedTextWriter.cs Outdated
Comment on lines 8123 to 8126
public override void Write(char[]? buffer) { }
public override void Write(char[] buffer, int index, int count) { }
public override void Write(System.ReadOnlySpan<char> buffer) { }
public override void Write(double value) { }
Comment on lines +139 to +143
public override void Write(ReadOnlySpan<char> buffer)
{
OutputTabs();
_writer.Write(buffer);
}
Copilot AI review requested due to automatic review settings July 12, 2026 23:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines 8121 to 8126
@@ -8122,6 +8122,7 @@ public override void Write(bool value) { }
public override void Write(char value) { }
public override void Write(char[]? buffer) { }
public override void Write(char[] buffer, int index, int count) { }
public override void Write(System.ReadOnlySpan<char> buffer) { }
public override void Write(double value) { }
Comment on lines +139 to +143
public override void Write(ReadOnlySpan<char> buffer)
{
OutputTabs();
_writer.Write(buffer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Runtime community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants