Skip to content

.Net: Net: Address roji/westey review feedback round 2 on text search connectors (#10456)#13611

Open
alzarei wants to merge 2 commits intomicrosoft:feature-text-search-linqfrom
alzarei:address-roji-review-feedback-2
Open

.Net: Net: Address roji/westey review feedback round 2 on text search connectors (#10456)#13611
alzarei wants to merge 2 commits intomicrosoft:feature-text-search-linqfrom
alzarei:address-roji-review-feedback-2

Conversation

@alzarei
Copy link

@alzarei alzarei commented Mar 1, 2026

.Net: Address roji/westey review feedback round 2 on text search connectors (#10456)

Motivation and Context

Addresses second round of review feedback from @roji and @westey-m on PR #13384 (feature-text-search-linq). This round focuses on code quality improvements: adding [Obsolete] attributes to legacy types, consolidating expression processing with pattern matching, and removing dead code.

Issue: #10456

Description

Obsolete attributes

Marked the following legacy types as [Obsolete] to signal the transition to LINQ-based filtering:

  • FilterClause, EqualToFilterClause, AnyTagEqualToFilterClause (VectorData.Abstractions) — base filter clause hierarchy replaced by LINQ expressions
  • TextSearchFilter (SemanticKernel.Abstractions) — replaced by TextSearchOptions<TRecord>.Filter
  • TextSearchOptions (non-generic, SemanticKernel.Abstractions) — replaced by TextSearchOptions<TRecord>

Google connector refactoring

Consolidated 8 expression-processing methods into 3 using C# pattern matching:

  • ProcessFilterNode: Recursive switch-based handler for AND, equality, inequality, string Contains, null-guard, collection Contains (error), and negation patterns
  • ProcessNegatedFilterNode: Handles !(expr) patterns, mapping to Google's excludeTerms
  • MapPropertyToGoogleFilter: Converted to expression-bodied member
  • Removed: TryProcessSingleExpression, TryProcessEqualityExpression, TryProcessInequalityExpression, TryProcessContainsExpression, TryProcessNotExpression, CollectAndCombineFilters, IsMemoryExtensionsContains, MapGoogleFilterToProperty (dead code)

Bing/Brave/Tavily connector cleanup

  • Pattern matching switch expressions replacing if-chains
  • Removed MemoryExtensions type checks — replaced with Object: null for static method detection
  • Expression-bodied property mapper methods

Error handling improvements

  • Collection Contains: Google and Bing now throw NotSupportedException with actionable guidance when collection.Contains(page.Property) is used (unsupported by these APIs)
  • ExtractFiltersFromLegacy: All four connectors now throw on unsupported FilterClause subtypes instead of silently skipping
  • Null-guard patterns: Google correctly handles page.Property != null comparisons (silently skipped)

Pragma consolidation

  • Replaced scattered #pragma warning disable/restore CS0618 pairs with single file-level pragmas across 22 files (library, tests, samples, integration tests)
  • Fixed AgentWithTextSearchProvider.cs where a local #pragma warning restore CS0618 was re-enabling the warning mid-method

Files Changed

Commit 1: Core changes (15 files, +198/-445)

File Change
FilterClause.cs Added [Obsolete]
EqualToFilterClause.cs Added [Obsolete]
AnyTagEqualToFilterClause.cs Added [Obsolete]
TextSearchFilter.cs Added [Obsolete], file-level pragma
TextSearchOptions.cs Added [Obsolete] on non-generic class
GoogleTextSearch.cs Major refactoring: 8→3 methods, pattern matching, null-guard, dead code removal
BingTextSearch.cs Pattern matching, removed MemoryExtensions, collection Contains error
BraveTextSearch.cs Pattern matching, removed MemoryExtensions, file-level pragma
TavilyTextSearch.cs Pattern matching, removed MemoryExtensions, file-level pragma
VectorStoreTextSearch.cs File-level pragma consolidation
TextSearchExtensions.cs File-level pragma consolidation
TextSearchProviderOptions.cs File-level pragma
MockTextSearch.cs (UnitTests) File-level pragma
MockTextSearch.cs (AotTests) File-level pragma
VectorStoreTextSearchTests.cs File-level pragma

Commit 2: Pragma fixes for samples/tests (7 files, +16/-1)

File Change
Bing_RagWithTextSearch.cs Added file-level #pragma warning disable CS0618
Bing_FunctionCallingWithTextSearch.cs Added file-level pragma
Bing_TextSearch.cs Added file-level pragma
Google_TextSearch.cs Added file-level pragma
Tavily_TextSearch.cs Added file-level pragma
Step3_Search_With_FunctionCalling.cs Added file-level pragma
AgentWithTextSearchProvider.cs Added file-level pragma, removed conflicting local restore

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • I didn't break anyone 😄

Validation

Check Result
Format (dotnet format --verify-no-changes) ✅ Pass
Build (dotnet build SK-dotnet.slnx -c Release --warnaserror --no-incremental) ✅ Pass (0 warnings, 0 errors)
Unit tests (full solution) ✅ 1606/1606 passed
AOT publish (dotnet publish -f net10.0) ✅ Pass
Validated twice — clean build both rounds

- Add [Obsolete] to FilterClause, EqualToFilterClause, AnyTagEqualToFilterClause
- Add [Obsolete] to non-generic TextSearchOptions and TextSearchFilter
- Refactor Google connector: merge 8 methods into 3 using pattern matching
- Refactor Bing/Brave/Tavily: pattern matching, remove MemoryExtensions
- Add explicit error for collection Contains (Enumerable.Contains) in Google/Bing
- Handle null-guard patterns (x != null) in Google expression processing
- Remove dead code (MapGoogleFilterToProperty)
- Consolidate pragma CS0618 to file-level in all affected files
- ExtractFiltersFromLegacy: throw on unsupported FilterClause types
@alzarei alzarei requested a review from a team as a code owner March 1, 2026 10:17
@moonbox3 moonbox3 added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core labels Mar 1, 2026
@github-actions github-actions bot changed the title Net: Address roji/westey review feedback round 2 on text search connectors (#10456) .Net: Net: Address roji/westey review feedback round 2 on text search connectors (#10456) Mar 1, 2026
@alzarei alzarei force-pushed the address-roji-review-feedback-2 branch from 7d5f751 to 45e852b Compare March 2, 2026 07:14
@alzarei alzarei deployed to integration March 2, 2026 07:48 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel.core kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants