[Infra] Disallow instance string.Equals methods#4332
Merged
martincostello merged 2 commits intoApr 29, 2026
Merged
Conversation
- Disallow use of string instance `Equals()` methods and require the static versions be used instead. - Apply minor refactoring suggested by Visual Studio in files touched.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens repository-wide string comparison consistency by banning instance string.Equals(...) overloads and updating touched code to use the static string.Equals(...) alternatives.
Changes:
- Added banned-symbol entries to disallow
System.String.Equals(string)andSystem.String.Equals(string, StringComparison). - Replaced instance
Equalscalls withstring.Equals(...)across several AWS, Geneva exporter, and sampler components. - Applied minor IDE refactorings (expression-bodied members) in AWS instrumentation utilities.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/OpenTelemetry.Sampler.AWS/SamplingRuleApplier.cs | Switched tag/resource key comparisons to string.Equals(...). |
| src/OpenTelemetry.Instrumentation.AWS/Implementation/Utils.cs | Updated tag key comparison and refactored small helpers to expression-bodied members. |
| src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSServiceType.cs | Replaced instance comparisons with string.Equals(..., OrdinalIgnoreCase). |
| src/OpenTelemetry.Exporter.Geneva/Metrics/TlvMetricExporter.cs | Updated reserved-dimension key checks to use static string.Equals(...). |
| src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporterOptions.cs | Updated reserved-dimension validation comparisons to use static string.Equals(...). |
| src/OpenTelemetry.Exporter.Geneva/Internal/ConnectionStringBuilder.cs | Updated private-preview flag parsing comparisons to use static string.Equals(...). |
| build/BannedSymbols.txt | Added new banned-symbol rules for instance string.Equals overloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
martincostello
commented
Apr 29, 2026
Add note about why.
Kielek
approved these changes
Apr 29, 2026
Merged
via the queue into
open-telemetry:main
with commit Apr 29, 2026
e0e10cc
316 of 317 checks passed
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.
Relates to open-telemetry/opentelemetry-dotnet#7210.
Changes
Equals()methods and require the static versions be used instead.Merge requirement checklist
Unit tests added/updatedAppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)