[Infra] Use char polyfills - #4975
Merged
martincostello merged 1 commit intoAug 13, 2026
Merged
Conversation
Use `char` polyfills for non-`NET` code to remove conditional compilation and simplify code.
martincostello
marked this pull request as ready for review
August 13, 2026 13:44
martincostello
enabled auto-merge
August 13, 2026 13:45
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies ASCII character classification across the repo by relying on char.IsAscii* APIs consistently, backed by a CharExtensions polyfill for non-NET TFMs to remove scattered conditional compilation.
Changes:
- Extend
src/Shared/CharExtensions.cswith additional polyfilled members (IsAsciiLetter,IsAsciiHexDigit) for non-NETtargets. - Replace hand-rolled /
#if NETASCII checks in shared SQL parsing and exporter/resource code withchar.IsAscii*calls. - Link
CharExtensions.csinto the affected library, test, fuzz, and benchmark projects that consume these APIs.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/OpenTelemetry.Contrib.Shared.Tests/OpenTelemetry.Contrib.Shared.Tests.csproj | Links CharExtensions.cs into shared tests. |
| test/OpenTelemetry.Contrib.Shared.FuzzTests/OpenTelemetry.Contrib.Shared.FuzzTests.csproj | Links CharExtensions.cs into fuzz tests. |
| test/OpenTelemetry.Contrib.Shared.Benchmarks/OpenTelemetry.Contrib.Shared.Benchmarks.csproj | Links CharExtensions.cs into benchmarks. |
| src/Shared/SqlProcessor.cs | Removes per-TFM ASCII helpers/conditionals by using char.IsAscii* throughout parsing/sanitization. |
| src/Shared/CharExtensions.cs | Adds missing polyfilled members for non-NET targets. |
| src/OpenTelemetry.Resources.Container/Utils/EncodingUtils.cs | Uses char.IsAsciiHexDigit for hex validation. |
| src/OpenTelemetry.Resources.Container/OpenTelemetry.Resources.Container.csproj | Links CharExtensions.cs into the container resource detector package. |
| src/OpenTelemetry.Instrumentation.SqlClient/OpenTelemetry.Instrumentation.SqlClient.csproj | Links CharExtensions.cs into SqlClient instrumentation (consumes shared SQL parser). |
| src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj | Links CharExtensions.cs into EF Core instrumentation. |
| src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj | Links CharExtensions.cs into OneCollector exporter. |
| src/OpenTelemetry.Exporter.OneCollector/Internal/EventNameManager.cs | Replaces manual ASCII range check with char.IsAsciiLetterLower. |
| src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj | Links CharExtensions.cs into Geneva exporter. |
| src/OpenTelemetry.Exporter.Geneva/Internal/Tld/TldLogCommon.cs | Replaces manual ASCII validation/sanitization checks with char.IsAscii*. |
| src/OpenTelemetry.Exporter.Geneva/Internal/TableNameSerializer.cs | Replaces manual ASCII validation/sanitization checks with char.IsAscii*. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Kielek
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#4629 (comment)
Changes
Use
charpolyfills for non-NETcode to remove conditional compilation and simplify code.Merge requirement checklist
Unit tests added/updatedAppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)