Skip to content

Commit 78fe164

Browse files
committed
.NET: Performance improvements for VectorStoreTextSearch
- Fix CA1859: Use specific return types BinaryExpression? and MethodCallExpression? instead of generic Expression? for better performance - Improve test model: Use IReadOnlyList<string> instead of string[] for Tags property to follow .NET collection best practices These changes address code analyzer warnings and apply reviewer applicable feedback from other PRs in the Issue #10456 modernization series.
1 parent 871d0cd commit 78fe164

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dotnet/src/SemanticKernel.Core/Data/TextSearch/VectorStoreTextSearch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ private async IAsyncEnumerable<string> GetResultsAsStringAsync(IAsyncEnumerable<
580580
/// <param name="value">The value to compare against.</param>
581581
/// <param name="parameter">The parameter expression.</param>
582582
/// <returns>The body expression for equality, or null if not supported.</returns>
583-
private static Expression? CreateEqualityBodyExpression(string fieldName, object value, ParameterExpression parameter)
583+
private static BinaryExpression? CreateEqualityBodyExpression(string fieldName, object value, ParameterExpression parameter)
584584
{
585585
try
586586
{
@@ -682,7 +682,7 @@ private async IAsyncEnumerable<string> GetResultsAsStringAsync(IAsyncEnumerable<
682682
/// <param name="parameter">The parameter expression.</param>
683683
/// <returns>The body expression for collection contains, or null if not supported.</returns>
684684
[RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
685-
private static Expression? CreateAnyTagEqualToBodyExpression(string fieldName, string value, ParameterExpression parameter)
685+
private static MethodCallExpression? CreateAnyTagEqualToBodyExpression(string fieldName, string value, ParameterExpression parameter)
686686
{
687687
try
688688
{

dotnet/src/SemanticKernel.UnitTests/Data/VectorStoreTextSearchTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public sealed class DataModelWithTags
249249
public required string Tag { get; init; }
250250

251251
[VectorStoreData(IsIndexed = true)]
252-
public required string[] Tags { get; init; }
252+
public required IReadOnlyList<string> Tags { get; init; }
253253

254254
[VectorStoreVector(1536)]
255255
public string? Embedding { get; init; }

0 commit comments

Comments
 (0)