-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Polyfill SearchValues and optimize Activity, W3CPropagator #119673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Pull Request Overview
This PR adds polyfills for modern .NET APIs like SearchValues
to enable optimization of string searching operations across different target frameworks. The key change is replacing many manual character-by-character validation loops and character array lookups with more efficient SearchValues
operations.
Key changes:
- Adds polyfill infrastructure for
SearchValues<char>
,Ascii.IsValid
, and span extension methods for downlevel targets - Optimizes W3CPropagator by replacing bitmask-based validation with SearchValues and simplifying trace parent validation logic
- Converts various libraries to use SearchValues instead of IndexOfAny with character arrays or manual loops
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/libraries/Directory.Build.targets |
Adds MSBuild logic to include polyfill files when IncludeSpanPolyfills is enabled |
src/libraries/Common/src/System/Text/AsciiPolyfills.cs |
Polyfill implementation of Ascii.IsValid methods for downlevel targets |
src/libraries/Common/src/System/MemoryExtensionsPolyfills.cs |
Polyfill for ContainsAnyExcept span extension method |
src/libraries/Common/src/System/Buffers/SearchValuesPolyfills.cs |
Complete polyfill implementation of SearchValues APIs using bitmap for ASCII chars |
Multiple library projects | Enable polyfills and convert to use SearchValues instead of manual validation loops |
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/W3CPropagator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParser.cs
Show resolved
Hide resolved
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/W3CPropagator.cs
Show resolved
Hide resolved
f823ab1
to
6ab683b
Compare
Tagging subscribers to this area: @dotnet/area-meta |
cea32e2
to
190cb7d
Compare
src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj
Show resolved
Hide resolved
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.
LGTM
Polyfilling such helpers seems like a neat way of avoiding duplication in a bunch of places where we might want to use newer APIs.
W3cPropagator
being an extreme example where we were already duplicating a bunch of logic, but still not usingSearchValues
everywhere because it would add even more.Benchmark source