@@ -963,37 +963,42 @@ private Expression VisitIndex(IndexExpression ie)
963963 return Expression . Convert ( Expression . Call ( objectExpression , objectExpression . Type . GetProperty ( "Item" ) . GetGetMethod ( ) , new [ ] { Expression . Constant ( evaluatedArgument ) } ) , fieldInfo . ValueType ) ;
964964 }
965965
966- private static bool IsConditionalOrWellknown ( Expression expression , bool isRoot = true )
966+ private static bool IsConditionalOrWellknown ( Expression expression )
967967 {
968- var conditionalExpression = expression as ConditionalExpression ;
969- if ( conditionalExpression != null )
970- return IsConditionalOrWellknown ( conditionalExpression . IfTrue , false )
971- && IsConditionalOrWellknown ( conditionalExpression . IfFalse , false ) ;
968+ return IsConditionalOrWellknownRecursive ( expression , true ) ;
972969
973- if ( isRoot )
974- return false ;
970+ static bool IsConditionalOrWellknownRecursive ( Expression expression , bool isRootCall )
971+ {
972+ var conditionalExpression = expression as ConditionalExpression ;
973+ if ( conditionalExpression != null )
974+ return IsConditionalOrWellknownRecursive ( conditionalExpression . IfTrue , false )
975+ && IsConditionalOrWellknownRecursive ( conditionalExpression . IfFalse , false ) ;
975976
976- if ( expression . NodeType == ExpressionType . Constant )
977- return true ;
977+ if ( isRootCall )
978+ return false ;
978979
979- if ( expression . NodeType == ExpressionType . Convert ) {
980- var unary = ( UnaryExpression ) expression ;
981- return IsConditionalOrWellknown ( unary . Operand , false ) ;
982- }
980+ if ( expression . NodeType == ExpressionType . Constant )
981+ return true ;
983982
984- if ( ! ( expression is ExtendedExpression ) )
985- return false ;
983+ if ( expression . NodeType == ExpressionType . Convert ) {
984+ var unary = ( UnaryExpression ) expression ;
985+ return IsConditionalOrWellknownRecursive ( unary . Operand , false ) ;
986+ }
986987
987- var memberType = expression . GetMemberType ( ) ;
988- switch ( memberType ) {
989- case MemberType . Primitive :
990- case MemberType . Key :
991- case MemberType . Structure :
992- case MemberType . Entity :
993- case MemberType . EntitySet :
994- return true ;
995- default :
988+ if ( ! ( expression is ExtendedExpression ) )
996989 return false ;
990+
991+ var memberType = expression . GetMemberType ( ) ;
992+ switch ( memberType ) {
993+ case MemberType . Primitive :
994+ case MemberType . Key :
995+ case MemberType . Structure :
996+ case MemberType . Entity :
997+ case MemberType . EntitySet :
998+ return true ;
999+ default :
1000+ return false ;
1001+ }
9971002 }
9981003 }
9991004
0 commit comments