镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[API Proposal]: Add ReadOnlySequence<char> overload for WriteRawValue #102491

Open

Description

@Tragetaschen

Background and motivation

In #68223, two overloads for Utf8JsonWriter were proposed, one for ReadOnlySequence<byte> and one for ReadOnlySequence<char>. The latter was rejected due to the necessary surrogate pair state handling while writing the ReadOnlySpan<char> segments.

However, #67337 is currently underway to add the building blocks and state handling for that. Adding the rejected overload now seems like an easy addition.

API Proposal

namespace System.Text.Json
{
    public sealed partial class Utf8JsonWriter
    {
+        public void WriteRawValue(ReadOnlySequence<char> json, bool skipInputValidation = false);
    }
}

API Usage

I could avoid building an entire in-memory, contiguous string just to have it written out as JSON. Other proposals like #97570 or #87362 would tie in very nicely as well.

Alternative Designs

No response

Risks

No response

Activity

  1. added
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on May 21, 2024
  2. dotnet-policy-service commented on May 21, 2024

    @dotnet-policy-service
    Contributor

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

  3. added this to the Future milestone on May 21, 2024
  4. Tragetaschen commented on Jan 6, 2025

    @Tragetaschen
    ContributorAuthor

    #67377 is implemented. Where can I send the cake for bribery?

  5. teo-tsirpanis commented on May 1, 2026

    @teo-tsirpanis
    Contributor

    Duplicate of #68223; this API is available since .NET 8.

  6. modified the milestones: Future, 8.0.0 on May 1, 2026
  7. Tragetaschen commented on May 2, 2026

    @Tragetaschen
    ContributorAuthor

    This is wrong. The requested overload is the one specifically dropped during review. There is only a byte overload, not one for char.
    #68223 (comment)

  8. modified the milestones: 8.0.0, Future on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions