Repository navigation
C#: Update StringBuilder query help links to HTTPS - #23268
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
Both affected query-help references now use the corresponding HTTPS Microsoft Learn URL while preserving their existing link text, with no active issues identified.
No open issues 🎉
What changed in this PR
Updates the C# Performance query-help references for System.Text.StringBuilder from legacy HTTP MSDN URLs to the corresponding HTTPS Microsoft Learn page, preserving the existing link text.
Changes:
- Updated the
StringBuilderreference inStringConcatenationInLoop.qhelp. - Updated the
StringBuilderreference inStringBuilderInLoop.qhelp.
| File | Description |
|---|---|
| csharp/ql/src/Performance/StringConcatenationInLoop.qhelp | Replaces the HTTP MSDN link with the HTTPS Microsoft Learn URL. |
| csharp/ql/src/Performance/StringBuilderInLoop.qhelp | Replaces the HTTP MSDN link with the HTTPS Microsoft Learn URL. |
Review effort: Lite (adaptive)
|
QHelp previews: csharp/ql/src/Performance/StringBuilderInLoop.qhelpStringBuilder creation in loopCreating a RecommendationCreate the ExampleThe following example creates a new static void Main(string[] args)
{
foreach (var arg in args)
{
var sb = new StringBuilder(); // BAD: Creation in loop
sb.Append("Hello ").Append(arg);
Console.WriteLine(sb);
}
}The code has been rewritten so that the same static void Main(string[] args)
{
var sb = new StringBuilder(); // GOOD: Creation outside loop
foreach (var arg in args)
{
sb.Clear();
sb.Append("Hello ").Append(arg);
Console.WriteLine(sb);
}
}References
csharp/ql/src/Performance/StringConcatenationInLoop.qhelpString concatenation in loopThis rule finds code that performs string concatenation in a loop using the RecommendationIt is better to use Exampleclass StringConcatenationInLoop
{
public static void Main(string[] args)
{
String numberList = "";
for (int i = 0; i <= 100; i++)
{
numberList += i + " ";
}
Console.WriteLine(numberList);
}
}Fix With StringBuilderThis code performs the same function as the example except it uses class StringConcatenationInLoopFix
{
public static void Main(string[] args)
{
StringBuilder numberList = new StringBuilder();
for (int i = 0; i <= 100; i++)
{
numberList.Append(i);
numberList.Append(" ");
}
Console.WriteLine(numberList);
}
}References
|
Update two references in C#
Performancequery help to the Microsoft Learn HTTPS page forSystem.Text.StringBuilder. Both links keep their existing text.Related to #5163.
Validation:
git diff --checkpassed. Both files parsed as XML and rendered to Markdown withcodeql generate query-help(CLI 2.27.6, warnings treated as errors). Both rendered links point to the expected Microsoft Learn page.AI assistance: OpenAI Codex prepared the URL changes and ran the validation above.