perf: avoid MeasurementUnit enum boxing allocations #5218
1 issue
High
GetPredefinedName returns PascalCase names instead of lowercase, changing serialized output - `src/Sentry/MeasurementUnit.cs:22-26`
The new implementation uses Enum.GetNames<Duration>() (etc.) to precompute names, but Enum.GetNames<T>() returns names exactly as declared in the enum (PascalCase like "Second", "Byte", "Percent"). The previous implementation used _unit.ToString().ToLowerInvariant() which lowercased them. This regresses the public serialized form sent to Sentry from e.g. "second" to "Second", breaks existing tests (MeasurementUnitTests asserts "second"/"byte"/"percent"), and changes what Sentry receives via ToString()/ToNullableString(). The PR claims tests pass, but CanUseDurationUnits, CanUseInformationUnits, and CanUseFractionUnits would all fail with this code.
Also found at:
src/Sentry/MeasurementUnit.cs:109-111
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| security-review | 0 | 7.2s | $0.04 |
| code-review | 0 | 9.6s | $0.05 |
| find-bugs | 1 | 1m 5s | $1.49 |
| gha-security-review | 0 | 9.3s | $0.10 |
⏱ 1m 31s · 327.4k in / 4.3k out · $1.68 (+verification: $1.09, +merge: $0.00, +dedup: $0.00)