Fix several new CA1830 diagnostics#121131
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses CA1830 code analyzer diagnostics by replacing inefficient new string(char, int) constructor calls with the more performant StringBuilder.Append(char, int) overload across multiple files in the codebase. This analyzer rule recommends using StringBuilder.Append(char, int) instead of creating temporary string objects when appending repeated characters.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/illink/src/linker/Linker/Driver.cs | Updated backslash appending in response file parsing to use the optimized Append overload |
| src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexNode.cs | Modified indentation string building in ToString() to use the optimized Append overload |
| src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests/CustomConverterTests.ReadAhead.cs | Updated test string generation to use the optimized Append overload |
| src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs | Changed array rank comma separator generation to use the optimized Append overload |
| src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs | Changed array rank comma separator generation to use the optimized Append overload |
jkotas
approved these changes
Oct 28, 2025
Member
Author
|
/ba-g wasm |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
From updates in dotnet/sdk#51215