Skip to content

Conversation

@MihaZupan
Copy link
Member

No description provided.

@MihaZupan MihaZupan added this to the 11.0.0 milestone Jan 27, 2026
@MihaZupan MihaZupan self-assigned this Jan 27, 2026
@dotnet-policy-service
Copy link
Contributor

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

Copilot AI review requested due to automatic review settings January 30, 2026 01:07
Copy link
Contributor

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 pull request adds polyfills for Contains(T) methods on ReadOnlySpan<T> and introduces corresponding Contains(char), StartsWith(char), and EndsWith(char) extension methods for strings to support downlevel targets (primarily .NET Standard 2.0 and .NET Framework).

Changes:

  • Adds StringPolyfills.cs with extension methods for string.Contains(char), string.StartsWith(char), and string.EndsWith(char) for pre-.NET Standard 2.1 targets
  • Adds ReadOnlySpan<T>.Contains(T) polyfill to MemoryExtensionsPolyfills.cs
  • Converts numerous IndexOf checks throughout the codebase to use the more readable Contains, StartsWith, and EndsWith methods
  • Removes CA warning suppressions (CA1866, CA2249, CA1865, CA1867) that are no longer needed after the conversions
  • Adds IncludeSpanPolyfills property to projects targeting downlevel frameworks

Reviewed changes

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

Show a summary per file
File Description
src/libraries/Common/src/System/StringPolyfills.cs New polyfill file providing Contains(char), StartsWith(char), and EndsWith(char) for strings
src/libraries/Common/src/System/MemoryExtensionsPolyfills.cs Adds Contains<T> polyfill for ReadOnlySpan<T>
src/libraries/Directory.Build.targets Includes StringPolyfills.cs in the IncludeSpanPolyfills build configuration
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs Converts StartsWith("v") to StartsWith('v')
src/tasks/Crossgen2Tasks/RunReadyToRunCompiler.cs Converts IndexOf("warning:") != -1 to Contains("warning:")
src/tasks/Crossgen2Tasks/CommonFilePulledFromSdkRepo/NuGetUtils.NuGet.cs Converts IndexOf checks to Contains
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/TypeNameBuilder.cs Converts IndexOf(c) != -1 to Contains(c) for span
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexInterpreter.cs Converts IndexOf < 0 to !Contains for span
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.WriteValues.Comment.cs Converts IndexOf checks, one using Contains with StringComparison
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverter.cs Converts IndexOf(',') >= 0 to Contains(',')
src/libraries/System.Text.Json/src/System/Text/Json/Reader/*.cs Multiple conversions of IndexOf delimiter checks to Contains
src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs Converts IndexOf check to Contains
src/libraries/System.Speech/src/Result/RecognizedPhrase.cs Converts Contains("$") to Contains('$')
src/libraries/System.Speech/src/Internal/SrgsParser/XmlParser.cs BUG: Converts to ContainsAny without .AsSpan() call
src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceController.cs Converts StartsWith and Contains checks, removes outdated comment
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Aes.cs Converts IndexOfAnyExcept >= 0 to ContainsAnyExcept
src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/*.cs Converts IndexOf("<") to IndexOf('<')
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/*.cs Converts Contains checks and removes #if NET conditionals
src/libraries/System.Net.ServerSentEvents/src/System/Net/ServerSentEvents/SseParser_1.cs Converts IndexOf < 0 to !Contains
src/libraries/System.Memory/src/System/Buffers/SequenceReader.Search.cs Converts IndexOf != -1 to Contains in loop condition
src/libraries/System.Management/src/System/Management/*.cs Converts IndexOfAny and StartsWith checks
src/libraries/System.IO.Packaging/src/System/IO/Packaging/*.cs Converts Contains checks and removes #if NET conditionals
src/libraries/System.DirectoryServices*/src/**/*.cs Converts StartsWith and Contains checks
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs Optimizes EndsWith(".") to direct character comparison
src/libraries/System.Data./src/**/.cs Multiple conversions removing comments about .NET Core 2.1 availability
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/StringValidator.cs BUG: Changes field type to SearchValues but still formats it as string in error message
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/*.cs Multiple conversions and removal of #if NET conditionals
src/libraries/System.CodeDom/src/Microsoft/**/*.cs Converts Contains checks and removes #if NET conditionals
src/libraries/Microsoft.Extensions./src/**/.cs Multiple conversions and conditional removal
src/libraries/Common/src/**/*.cs Multiple conversions in common code
src/coreclr/tools//src/**/.cs Multiple conversions and warning suppressions removed
Multiple .csproj files Removes CA warning suppressions and adds IncludeSpanPolyfills/polyfill references

Copy link
Contributor

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

Copilot reviewed 75 out of 75 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings February 1, 2026 22:35
Copy link
Contributor

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

Copilot reviewed 75 out of 75 changed files in this pull request and generated no new comments.

@MihaZupan MihaZupan merged commit 12d6350 into dotnet:main Feb 2, 2026
172 of 176 checks passed
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.

2 participants