Commit d1f2733
committed
.NET: Implement Option 3 dual interface for Issue #10456
Add ITextSearch<TRecord> generic interface with LINQ filtering while maintaining
existing ITextSearch non-generic interface for backward compatibility.
## Background: Architectural Decision (Issue #10456)
Three options considered:
Option 1 (Native LINQ): Replace TextSearchFilter with Expression<Func<T, bool>>
- Breaking change: requires user migration
- Best long-term architecture
Option 2 (Translation Layer): Convert TextSearchFilter to LINQ internally
- Breaking change: RequiresDynamicCode propagates through API surface
- Reflection overhead, AOT incompatible
Option 3 (Dual Interface): Add ITextSearch<TRecord> alongside ITextSearch
- No breaking changes
- Maintains AOT compatibility
- Uses obsolete VectorSearchFilter in legacy path (temporary during transition)
## Implementation
### Generic Interface
- ITextSearch<TRecord> with 3 methods accepting TextSearchOptions<TRecord>
- TextSearchOptions<TRecord> with Expression<Func<TRecord, bool>>? Filter
- Explicit interface implementation in VectorStoreTextSearch<TRecord>
### Dual-Path Architecture
Two independent code paths, no translation layer:
Legacy path (non-generic):
- ITextSearch with TextSearchOptions and TextSearchFilter (clause-based)
- Uses VectorSearchOptions.OldFilter (obsolete) with pragma warning suppression
- No dynamic code, AOT compatible
- 10 existing tests unchanged
Modern path (generic):
- ITextSearch<TRecord> with TextSearchOptions<TRecord> and Expression filter
- Uses VectorSearchOptions.Filter (LINQ native, not obsolete)
- No dynamic code, AOT compatible
- 7 new tests
## Changes
- Added ITextSearch<TRecord> interface and TextSearchOptions<TRecord> class
- Implemented dual interface in VectorStoreTextSearch<TRecord>
- Deleted ~150 lines of Option 2 translation layer code
- Removed all RequiresDynamicCode attributes
- Removed DynamicallyAccessedMemberTypes.PublicMethods from 5 locations:
- VectorStoreTextSearch.cs
- TextSearchServiceCollectionExtensions.cs (3 methods)
- TextSearchKernelBuilderExtensions.cs (1 method)
- Deleted 7 Option 2 translation tests
- Added 7 LINQ filtering tests
- Added DataModelWithTags to test base
- Reverted Program.cs to original state
## Files Changed
8 files, +144 insertions, -395 deletions
- ITextSearch.cs
- TextSearchOptions.cs (added generic class)
- VectorStoreTextSearch.cs (removed translation layer, added dual interface)
- TextSearchServiceCollectionExtensions.cs (removed PublicMethods annotation)
- TextSearchKernelBuilderExtensions.cs (removed PublicMethods annotation)
- VectorStoreTextSearchTestBase.cs (added DataModelWithTags)
- VectorStoreTextSearchTests.cs (removed 7 tests, added 7 tests)
- Program.cs in AotTests (removed suppression, restored tests)1 parent a802eaa commit d1f2733
File tree
8 files changed
+143
-396
lines changed- dotnet/src
- SemanticKernel.Abstractions/Data/TextSearch
- SemanticKernel.AotTests
- UnitTests/Search
- SemanticKernel.Core/Data/TextSearch
- SemanticKernel.UnitTests/Data
8 files changed
+143
-396
lines changedLines changed: 2 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
| |||
34 | 31 | | |
35 | 32 | | |
36 | 33 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 34 | | |
42 | 35 | | |
43 | 36 | | |
| |||
49 | 42 | | |
50 | 43 | | |
51 | 44 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | 45 | | |
57 | 46 | | |
58 | 47 | | |
| |||
61 | 50 | | |
62 | 51 | | |
63 | 52 | | |
| 53 | + | |
64 | 54 | | |
65 | 55 | | |
66 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | | - | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
| |||
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
| |||
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
42 | | - | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
0 commit comments