From 9872531450dc709a2f4ef2e45544775f7308258a Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 8 Sep 2025 17:09:00 -0400 Subject: [PATCH] Use string.Concat instead of string.Join("" --- src/Custom/Responses/Items/Reasoning/ReasoningResponseItem.cs | 3 +-- src/Custom/Responses/OpenAIResponse.cs | 2 +- tests/Responses/ResponsesTests.cs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Custom/Responses/Items/Reasoning/ReasoningResponseItem.cs b/src/Custom/Responses/Items/Reasoning/ReasoningResponseItem.cs index 5c684f1c3..d5396d48c 100644 --- a/src/Custom/Responses/Items/Reasoning/ReasoningResponseItem.cs +++ b/src/Custom/Responses/Items/Reasoning/ReasoningResponseItem.cs @@ -19,8 +19,7 @@ public ReasoningResponseItem(string summaryText) : this(summaryParts: [new Reaso // CUSTOM: Added for convenience. public string GetSummaryText() { - return string.Join( - separator: string.Empty, + return string.Concat( values: SummaryParts.Select(part => (part as ReasoningSummaryTextPart)?.Text ?? string.Empty)); } } diff --git a/src/Custom/Responses/OpenAIResponse.cs b/src/Custom/Responses/OpenAIResponse.cs index bf445e677..7e976c39f 100644 --- a/src/Custom/Responses/OpenAIResponse.cs +++ b/src/Custom/Responses/OpenAIResponse.cs @@ -67,6 +67,6 @@ public string GetOutputText() .Select(item => item as MessageResponseItem) .SelectMany(message => message.Content.Where(contentPart => contentPart.Kind == ResponseContentPartKind.OutputText) .Select(outputTextPart => outputTextPart.Text)); - return outputTextSegments.Any() ? string.Join(string.Empty, outputTextSegments) : null; + return outputTextSegments.Any() ? string.Concat(outputTextSegments) : null; } } diff --git a/tests/Responses/ResponsesTests.cs b/tests/Responses/ResponsesTests.cs index 50c88b77d..20d9c8d88 100644 --- a/tests/Responses/ResponsesTests.cs +++ b/tests/Responses/ResponsesTests.cs @@ -252,7 +252,7 @@ public async Task StreamingResponses() } Assert.That(deltaTextSegments, Has.Count.GreaterThan(0)); Assert.That(finalResponseText, Is.Not.Null.And.Not.Empty); - Assert.That(string.Join(string.Empty, deltaTextSegments), Is.EqualTo(finalResponseText)); + Assert.That(string.Concat(deltaTextSegments), Is.EqualTo(finalResponseText)); } [Test]