@@ -767,6 +767,7 @@ private Expression ProduceComparatorExpressionForSingleFieldCondition(Expression
767767 return null ;
768768 }
769769
770+ [ UnconditionalSuppressMessage ( "AOT" , "IL2075" , Justification = "The DocumentIngress class and its derived classes have DynamicallyAccessedMembers attribute applied to preserve public properties." ) ]
770771 private Expression ProduceComparatorExpressionForAnyFieldCondition ( ParameterExpression documentExpression )
771772 {
772773 // this.predicate is either Predicate.Contains or Predicate.DoesNotContain at this point
@@ -786,7 +787,16 @@ private Expression ProduceComparatorExpressionForAnyFieldCondition(ParameterExpr
786787 if ( string . Equals ( propertyInfo . Name , CustomDimensionsPropertyName , StringComparison . Ordinal ) )
787788 {
788789 // ScanList(document.<CustomDimensionsPropertyName>, <this.comparand>)
789- MemberExpression customDimensionsProperty = Expression . Property ( documentExpression , CustomDimensionsPropertyName ) ;
790+ PropertyInfo customDimensionsPropertyInfo = documentExpression . Type . GetProperty (
791+ CustomDimensionsPropertyName , BindingFlags . Instance | BindingFlags . Public ) ;
792+
793+ if ( customDimensionsPropertyInfo == null )
794+ {
795+ continue ; // Skip if property doesn't exist
796+ }
797+
798+ MemberExpression customDimensionsProperty = Expression . Property ( documentExpression , customDimensionsPropertyInfo ) ;
799+
790800 propertyComparatorExpression = Expression . Call (
791801 null ,
792802 ListKeyValuePairStringScanMethodInfo ,
@@ -801,7 +811,16 @@ private Expression ProduceComparatorExpressionForAnyFieldCondition(ParameterExpr
801811 else if ( string . Equals ( propertyInfo . Name , CustomMetricsPropertyName , StringComparison . Ordinal ) )
802812 {
803813 // ScanDictionary(document.<CustomMetricsPropertyName>, <this.comparand>)
804- MemberExpression customMetricsProperty = Expression . Property ( documentExpression , CustomMetricsPropertyName ) ;
814+ PropertyInfo customMetricsPropertyInfo = documentExpression . Type . GetProperty (
815+ CustomMetricsPropertyName , BindingFlags . Instance | BindingFlags . Public ) ;
816+
817+ if ( customMetricsPropertyInfo == null )
818+ {
819+ continue ; // Skip if property doesn't exist
820+ }
821+
822+ MemberExpression customMetricsProperty = Expression . Property ( documentExpression , customMetricsPropertyInfo ) ;
823+
805824 propertyComparatorExpression = Expression . Call (
806825 null ,
807826 DictionaryStringDoubleScanMethodInfo ,
0 commit comments