From 4b3b80dc9d704b802d74922a04e86b5d1dafc13f Mon Sep 17 00:00:00 2001
From: Thorsten Sommer <mail@tsommer.org>
Date: Wed, 12 Mar 2025 18:56:57 +0100
Subject: [PATCH] In .NET 9 & C# 13 we can use spans inside async methods
---
.../Agents/AgentDataSourceSelection.cs | 20 -------------------
.../Agents/AgentRetrievalContextValidation.cs | 3 ---
2 files changed, 23 deletions(-)
diff --git a/app/MindWork AI Studio/Agents/AgentDataSourceSelection.cs b/app/MindWork AI Studio/Agents/AgentDataSourceSelection.cs
index 6a0f0957..6fe1f4e2 100644
--- a/app/MindWork AI Studio/Agents/AgentDataSourceSelection.cs
+++ b/app/MindWork AI Studio/Agents/AgentDataSourceSelection.cs
@@ -315,26 +315,6 @@ public sealed class AgentDataSourceSelection (ILogger<AgentDataSourceSelection>
return [];
}
}
-
- /// <summary>
- /// Extracts the JSON list from the given text. The text may contain additional
- /// information around the JSON list. The method tries to extract the JSON list
- /// from the text.
- /// </summary>
- /// <remarks>
- /// Algorithm: The method searches for the first line that contains only a '[' character.
- /// Then, it searches for the first line that contains only a ']' character. The method
- /// returns the text between these two lines (including the brackets). When the method
- /// cannot find the JSON list, it returns an empty string.
- /// <br/><br/>
- /// This overload is using strings instead of spans. We can use this overload in any
- /// async method. Thus, it is a wrapper around the span-based method. Yes, we are losing
- /// the memory efficiency of the span-based method, but we still gain the performance
- /// of the span-based method: the entire search algorithm is span-based.
- /// </remarks>
- /// <param name="text">The text that may contain the JSON list.</param>
- /// <returns>The extracted JSON list.</returns>
- private static string ExtractJson(string text) => ExtractJson(text.AsSpan()).ToString();
/// <summary>
/// Extracts the JSON list from the given text. The text may contain additional
diff --git a/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs b/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs
index 3f4bf4c2..9a4fdff5 100644
--- a/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs
+++ b/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs
@@ -319,9 +319,6 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
}
}
- // A wrapper around the span version, because we need to call this method from an async context.
- private static string ExtractJson(string text) => ExtractJson(text.AsSpan()).ToString();
-
private static ReadOnlySpan<char> ExtractJson(ReadOnlySpan<char> input)
{
//