Skip to content

Conversation

@TimothyMakkison
Copy link
Contributor

@TimothyMakkison TimothyMakkison commented Dec 21, 2025

Remove redundant manual string.Replace code. string.Replace is almost certainly faster, doesn't allocate when there aren't any changes to the string, uses string.Create, uses Vectorised lookups to find targets and won't allocate an intermediary buffer when the input string is larger than 256 characters.

Contains call isn't needed because string.Replace does the same thing and early returns with the original string.

Copy link

Copilot AI left a comment

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 removes a manual span-based string manipulation implementation in favor of using the built-in string.Replace method. The change simplifies code in ArgumentFormatter.FormatDefault where dots are replaced with middle dots (·) to prevent VS Test Explorer from misinterpreting them as namespace separators.

Key Changes:

  • Removes the #if NET8_0_OR_GREATER conditional compilation block with manual Span<char> manipulation
  • Replaces it with a simple str.Replace(".", "·") call that works across all target frameworks
  • Maintains the existing optimization that skips replacement when no dots are present

@thomhurst
Copy link
Owner

Thanks!

This was referenced Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants