Uploaded image for project: 're-motion'
  1. RM-5104

Allow and deal with exceptions within partial evaluation

    Details

    • Type: New Feature
    • Status: Closed (View workflow)
    • Priority: Normal
    • Resolution: Fixed
    • Affects versions: None
    • Fix versions: 1.13.170
    • Components: Data.Linq
    • Labels:
      None
    • Sprint:

      Description

      Currently, when partial evaluation encounters an expression that throws an exception when executed in memory, the exception is propagated to the caller, and query parsing stops.

      As an example, consider the following query:

      string nullValue = null;
      var query = from c in Cooks
                  where nullValue != null && nullValue.Length == c.ID
                  select c;
      

      Since c.ID cannot be evaluated, re-linq evaluates nullValue != null and nullValue.Length separately; the latter causes a NullReferenceException to be thrown.

      It is desirable for partial evaluation to cope with such exceptions and optionally let the back-end decide how to deal with the exception. Therefore, implement the following fix:

      • when partial evaluation encounters an exception, catch the exception and capture it within a PartialEvaluationExceptionExpression;
      • then continue partial evaluation on the child expressions of the throwing expression.

      The PartialEvaluationExceptionExpression reduces itself (when calling ExtensionExpression.Reduce) to the evaluated child expression. This enables back-ends not explicitly dealing with PartialEvaluationExceptionExpressions to just ignore the exception. Back-ends that want to deal with the exception can implement IPartialEvaluationExceptionExpressionVisitor.

      As a result, back-ends unaware of the PartialEvaluationExceptionExpression should behave as if they received the following evaluated query from the front-end (as long as they support ExtensionExpressions):

      from c in Cooks
      where false && null.Length == c.ID
      select c
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                Fabian Schmied
                Reporter:
                Fabian Schmied
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 5 hours
                  5h
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 15 minutes Time Not Required
                  4h 15m