You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add explicit handling for collection Contains filters in LINQ expressions
Enhance GoogleTextSearch LINQ filter processing to explicitly detect and reject collection Contains operations (e.g., array.Contains(page.Property)) with a clear, actionable error message.
Changes:
- Added IsMemoryExtensionsContains helper method to detect C# 14+ span-based Contains resolution
- Enhanced TryProcessSingleExpression to distinguish between:
* String.Contains (supported for substring search)
* Enumerable.Contains / MemoryExtensions.Contains (not supported - now explicitly rejected)
- Throws NotSupportedException with guidance on alternatives when collection Contains is detected
- Handles both C# 13- (Enumerable.Contains) and C# 14+ (MemoryExtensions.Contains) resolution paths
Test Coverage:
- Added CollectionContainsFilterThrowsNotSupportedExceptionAsync test
- Verifies exception is thrown for collection Contains operations
- Validates error message contains actionable guidance about OR logic limitations
- Ensures consistent behavior across C# language versions (13 vs 14 Contains resolution)
Rationale:
Google Custom Search API does not support OR logic across multiple values. Collection Contains filters would require OR semantics that cannot be expressed via Google's query parameters. This change provides clear, early feedback to developers attempting to use unsupported filter patterns.
Related to reviewer feedback on LINQ expression filter validation and C# 14 compatibility. Fixes#10456
0 commit comments