Skip to content

StringTruncationInCSharp: .NET 10, regex line-break fix and emoji-safe truncation - #2352

Merged
vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/104048-csharp-how-to-truncate-a-string
Nov 2, 2026
Merged

vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/104048-csharp-how-to-truncate-a-string

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Retargets the sample to net10.0 with current BenchmarkDotNet and xUnit packages, fixes the regex truncation so strings that contain line breaks are cut (RegexOptions.Singleline), adds two truncation methods that do not split surrogate pairs or text elements, makes the benchmark methods return their results, adds the text element method to the benchmark, passes args to BenchmarkRunner, and adds 10 tests (40 in total).

…ulti-line strings, add emoji-safe truncation

Retarget both projects to net10.0 and update BenchmarkDotNet and the xUnit test packages. The regex method now uses RegexOptions.Singleline so strings with line breaks are truncated. Add TruncateWithSurrogateCheck and TruncateWithTextElements, benchmark the text element method, return results from every benchmark method, pass args to BenchmarkRunner, and add 10 tests.
@vladimir-pecanac-main
vladimir-pecanac-main merged commit 16be384 into CodeMazeBlog:main Nov 2, 2026
4 checks passed
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.

1 participant