Skip to content

Commit 30bd2c3

Browse files
committed
Fix AOT compatibility warnings in VectorStoreTextSearch
- Add UnconditionalSuppressMessage attributes for IL2075/IL2060 warnings during AOT analysis - Expand DynamicallyAccessedMembers to include PublicMethods for GetMethod reflection calls - Maintains RequiresDynamicCode attribute to properly indicate AOT incompatibility - Addresses AOT test failures where --warnaserror treats warnings as compilation errors The reflection-based LINQ expression building is inherently incompatible with AOT compilation, but these attributes allow the build system to handle this known limitation gracefully instead of failing with cryptic errors. Regular and AOT compilation phases require different suppression mechanisms - pragma directives for regular builds, UnconditionalSuppressMessage for AOT analysis.
1 parent b328868 commit 30bd2c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Microsoft.SemanticKernel.Data;
1919
/// A Vector Store Text Search implementation that can be used to perform searches using a <see cref="VectorStoreCollection{TKey, TRecord}"/>.
2020
/// </summary>
2121
[Experimental("SKEXP0001")]
22-
public sealed class VectorStoreTextSearch<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRecord> : ITextSearch<TRecord>, ITextSearch
22+
public sealed class VectorStoreTextSearch<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicMethods)] TRecord> : ITextSearch<TRecord>, ITextSearch
2323
#pragma warning restore CA1711 // Identifiers should not have incorrect suffix
2424
{
2525
/// <summary>
@@ -668,6 +668,8 @@ private async IAsyncEnumerable<string> GetResultsAsStringAsync(IAsyncEnumerable<
668668
/// <param name="parameter">The parameter expression.</param>
669669
/// <returns>The body expression for collection contains, or null if not supported.</returns>
670670
[RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
671+
[UnconditionalSuppressMessage("Trimming", "IL2075:UnrecognizedReflectionPattern", Justification = "This method uses reflection for LINQ expression building and is marked with RequiresDynamicCode to indicate AOT incompatibility.")]
672+
[UnconditionalSuppressMessage("Trimming", "IL2060:UnrecognizedReflectionPattern", Justification = "This method uses reflection for LINQ expression building and is marked with RequiresDynamicCode to indicate AOT incompatibility.")]
671673
private static MethodCallExpression? CreateAnyTagEqualToBodyExpression(string fieldName, string value, ParameterExpression parameter)
672674
{
673675
try

0 commit comments

Comments
 (0)