Skip to content

[Infra] Use char polyfills - #4975

Merged
martincostello merged 1 commit into
open-telemetry:mainfrom
martincostello:char-polyfills
Aug 13, 2026
Merged

[Infra] Use char polyfills#4975
martincostello merged 1 commit into
open-telemetry:mainfrom
martincostello:char-polyfills

Conversation

@martincostello

Copy link
Copy Markdown
Member

#4629 (comment)

Changes

Use char polyfills for non-NET code to remove conditional compilation and simplify code.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Use `char` polyfills for non-`NET` code to remove conditional compilation and simplify code.
@github-actions github-actions Bot added comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva comp:exporter.onecollector Things related to OpenTelemetry.Exporter.OneCollector comp:instrumentation.entityframeworkcore Things related to OpenTelemetry.Instrumentation.EntityFrameworkCore comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient comp:resources.container Things related to OpenTelemetry.Resources.Container perf Performance related labels Aug 13, 2026
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.84%. Comparing base (9ad732f) to head (e193c80).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4975      +/-   ##
==========================================
- Coverage   78.04%   77.84%   -0.21%     
==========================================
  Files         471      472       +1     
  Lines       20177    20169       -8     
==========================================
- Hits        15747    15700      -47     
- Misses       4430     4469      +39     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 89.92% <100.00%> (-0.34%) ⬇️
unittests-Exporter.Geneva 56.72% <100.00%> (-0.59%) ⬇️
unittests-Exporter.InfluxDB 97.96% <ø> (ø)
unittests-Exporter.OneCollector 95.60% <100.00%> (ø)
unittests-Extensions 96.17% <ø> (ø)
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Extensions.Enrichment.AspNetCore 86.27% <ø> (ø)
unittests-Extensions.Enrichment.Http 94.33% <ø> (ø)
unittests-Instrumentation.AWS 85.35% <ø> (ø)
unittests-Instrumentation.AspNet 79.01% <ø> (ø)
unittests-Instrumentation.AspNetCore 87.20% <ø> (ø)
unittests-Instrumentation.Cassandra 92.30% <ø> (ø)
unittests-Instrumentation.ConfluentKafka 82.83% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.36% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 81.02% <ø> (ø)
unittests-Instrumentation.EventCounters 75.45% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.12% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 78.09% <ø> (ø)
unittests-Instrumentation.Hangfire 88.88% <ø> (ø)
unittests-Instrumentation.Http 75.61% <ø> (ø)
unittests-Instrumentation.Kusto 92.42% <ø> (ø)
unittests-Instrumentation.Owin 89.02% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 77.77% <ø> (ø)
unittests-Instrumentation.Remoting 65.59% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 39.91% <ø> (ø)
unittests-Instrumentation.SqlClient 83.36% <ø> (ø)
unittests-Instrumentation.StackExchangeRedis 94.98% <ø> (ø)
unittests-Instrumentation.Wcf 82.64% <ø> (ø)
unittests-OpAmp.Client 86.60% <ø> (-0.45%) ⬇️
unittests-PersistentStorage 69.20% <ø> (ø)
unittests-Resources.AWS 72.78% <ø> (ø)
unittests-Resources.Azure 84.18% <ø> (ø)
unittests-Resources.Container 80.76% <100.00%> (ø)
unittests-Resources.Gcp 80.70% <ø> (ø)
unittests-Resources.Host 72.34% <ø> (ø)
unittests-Resources.OperatingSystem 77.16% <ø> (ø)
unittests-Resources.Process 90.90% <ø> (ø)
unittests-Resources.ProcessRuntime 80.76% <ø> (ø)
unittests-Sampler.AWS 96.05% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ry.Exporter.Geneva/Internal/TableNameSerializer.cs 100.00% <100.00%> (ø)
...metry.Exporter.Geneva/Internal/Tld/TldLogCommon.cs 66.66% <100.00%> (-0.26%) ⬇️
...Exporter.OneCollector/Internal/EventNameManager.cs 100.00% <100.00%> (ø)
...lemetry.Resources.Container/Utils/EncodingUtils.cs 100.00% <100.00%> (ø)
src/Shared/CharExtensions.cs 50.00% <100.00%> (ø)
src/Shared/SqlProcessor.cs 98.70% <100.00%> (-0.04%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello
martincostello marked this pull request as ready for review August 13, 2026 13:44
@martincostello
martincostello requested a review from a team as a code owner August 13, 2026 13:44
Copilot AI lite review requested due to automatic review settings August 13, 2026 13:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.cs with additional polyfilled members (IsAsciiLetter, IsAsciiHexDigit) for non-NET targets.
  • Replace hand-rolled / #if NET ASCII checks in shared SQL parsing and exporter/resource code with char.IsAscii* calls.
  • Link CharExtensions.cs into 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.

@martincostello
martincostello added this pull request to the merge queue Aug 13, 2026
Merged via the queue into open-telemetry:main with commit 4843598 Aug 13, 2026
322 checks passed
@martincostello
martincostello deleted the char-polyfills branch August 13, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva comp:exporter.onecollector Things related to OpenTelemetry.Exporter.OneCollector comp:instrumentation.entityframeworkcore Things related to OpenTelemetry.Instrumentation.EntityFrameworkCore comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient comp:resources.container Things related to OpenTelemetry.Resources.Container perf Performance related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants