Add ToLowerInvariant()/ToUpperInvariant() interceptor for .NET Framework - #9175
Add ToLowerInvariant()/ToUpperInvariant() interceptor for .NET Framework#9175andrewlock wants to merge 2 commits into
ToLowerInvariant()/ToUpperInvariant() interceptor for .NET Framework#9175Conversation
|
@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. 🚀 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. |
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9175) and master. ✅ No regressions detected |
93324fa to
7603282
Compare
BenchmarksBenchmark execution time: 2026-09-08 08:26:44 Comparing candidate commit 7603282 in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 71 metrics, 0 unstable metrics, 71 known flaky benchmarks, 55 flaky benchmarks without significant changes.
|
Summary of changes
Adds an interceptor that replaces all usages of
string.ToLowerInvariant()/string.ToUpperInvariant()withStringUtil.ToLowerInvariant()/StringUtil.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 did not update call sites (there are about ~80 today in Datadog.Trace). With this interceptor, we don't have to touch any of those files (including the vendored code) or add the indirection for non-.NET Framework, and it covers new usages too.Implementation details
ToLowerInvariant()andToUpperInvariant()[SkipStringCaseInterception]to allow opting out of the interception, e.g. on IAST we want to run exactly the method the customer requestedTest coverage
Added unit tests for the interceptor, and if you decompile the binary, you can see that the method is being intercepted as expected
Other details
Stacked on
ToLowerInvariant()/ToUpperInvariant()for .NET Framework #9173Compare this approach to
StringUtil.ToLowerInvariant()/StringUtil.ToUpperInvariant()on .NET Framework #9180Only one of those approaches will be merged!