Use StringUtil.ToLowerInvariant()/StringUtil.ToUpperInvariant() on .NET Framework - #9180
Use StringUtil.ToLowerInvariant()/StringUtil.ToUpperInvariant() on .NET Framework#9180andrewlock wants to merge 5 commits into
StringUtil.ToLowerInvariant()/StringUtil.ToUpperInvariant() on .NET Framework#9180Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
BenchmarksBenchmark execution time: 2026-09-08 08:26:19 Comparing candidate commit a715a1a in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 72 metrics, 0 unstable metrics, 74 known flaky benchmarks, 52 flaky benchmarks without significant changes.
|
Makes it easier to replace usage sites
…net461 Adds a net461-only banned-symbols file to force using StringUtil on .NET Framework. The two IAST aspects intentionally keep calling the BCL directly
…ringUtil Switches every shared Datadog.Trace call site from the allocating BCL methods to StringUtil.ToUpperInvariant/ToLowerInvariant, so the non-allocating .NET Framework fast path added in previous commits actually gets used. Prepares for banning the raw BCL methods on net461.
…ringUtil on .NET Framework The EnumExtensions generator's fallback methods called string.ToUpperInvariant() directly in the generated code, which will trip the upcoming net461 ban on that BCL method. Emit a single private helper with an #if NETFRAMEWORK branch to StringUtil.ToUpperInvariant instead, and regenerate the four checked-in outputs.
3d7f80a to
a715a1a
Compare
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9180) and master. ✅ No regressions detected |
Summary of changes
Updates .NET Framework code to use
StringUtil.ToLowerInvariant()/StringUtil.ToUpperInvariant()instead ofstring.ToLowerInvariant()/string.ToUpperInvariant()Reason for change
On .NET Framework
ToLowerInvariant()allocates, even if there's no change of case required. #9173 added a non-allocating version, but id dnot update call sites.This PR updates all the callsites to use the new method, and adds a BannedSymbols analyzer to force you to use it.
Implementation details
StringUtilfor non-.NET Framework usage#if NETFRAMEWORKeverywhere, basically pass throughStringUtilmethods to accept nullable string, to make it easier to updatex?.ToLowerInvariant()constructsNote it would also be possible to make the
StringUtilmethods be extension methods, but then we'd need to rename them, e.g.StringUtil.ToLowerInvariantSafe()or somethingTest coverage
Covered by existing tests
Other details
Stacked on
ToLowerInvariant()/ToUpperInvariant()for .NET Framework #9173Compare this to the alternative approach:
ToLowerInvariant()/ToUpperInvariant()interceptor for .NET Framework #9175Only one of those approaches will be merged!