Skip to content

Conversation

lilinus
Copy link
Contributor

@lilinus lilinus commented Oct 2, 2025

Fixes #118018
Fixes #118113

@Copilot Copilot AI review requested due to automatic review settings October 2, 2025 14:24
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 2, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 2, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

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 adds new UTF-16 validation APIs to System.Text.Unicode, introducing Utf16.IsValid and Utf16.IndexOfInvalidSubsequence methods alongside similar functionality for UTF-8. It also refactors existing code to use these new standardized validation APIs instead of custom validation logic.

  • Adds new Utf16 class with validation methods IsValid and IndexOfInvalidSubsequence
  • Adds Utf8.IndexOfInvalidSubsequence method to complement existing Utf8.IsValid
  • Refactors multiple codebases to use the new standardized validation APIs

Reviewed Changes

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

Show a summary per file
File Description
System.Private.CoreLib.Shared.projitems Adds the new Utf16.cs file to the build
Utf16.cs New class implementing UTF-16 validation methods
Utf8.cs Adds IndexOfInvalidSubsequence method and updates class documentation
System.Runtime.cs Adds public API surface for new UTF-16 and UTF-8 validation methods
HttpEncoder.cs Refactors surrogate validation to use new Utf16.IndexOfInvalidSubsequence
Normalization.Icu.cs Replaces custom validation logic with Utf16.IsValid
StringSearchValues.cs Simplifies surrogate validation using Utf16.IsValid
Utf8UtilityTests.ValidateBytes.cs Adds test coverage for new Utf8.IndexOfInvalidSubsequence method
Utf16UtilityTests.ValidateChars.cs Adds test coverage for new Utf16 validation methods

{
/// <summary>
/// Provides static methods that convert chunked data between UTF-8 and UTF-16 encodings.
/// Provides static methods that convert chunked data between UTF-8 and UTF-16 encodings, and methods that validates UTF-8 sequences.
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Grammar error: 'methods that validates' should be 'methods that validate'.

Suggested change
/// Provides static methods that convert chunked data between UTF-8 and UTF-16 encodings, and methods that validates UTF-8 sequences.
/// Provides static methods that convert chunked data between UTF-8 and UTF-16 encodings, and methods that validate UTF-8 sequences.

Copilot uses AI. Check for mistakes.

namespace System.Text.Unicode
{
/// <summary>
/// Provides static methods that validates UTF-16 strings.
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Grammar error: 'methods that validates' should be 'methods that validate'.

Suggested change
/// Provides static methods that validates UTF-16 strings.
/// Provides static methods that validate UTF-16 strings.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates that the PR has been added by a community member needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: Indexed version of Utf8.IsValid [API Proposal]: UTF-16 version of Utf8.IsValid
1 participant