Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lift try..catch out of an expression and replace with a temporary variable #34912

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChrisJollyAU
Copy link
Contributor

@ChrisJollyAU ChrisJollyAU commented Oct 15, 2024

When EnableDetailedErrors is turned on it wraps the expression to read the field value in a try...catch statement

In certain situations this is not valid C#

  • When the expression is an argument to a method call
  • Assignment of the right hand expression to a variable or instance member
  • When the expression is part of a list
    • List of expressions for array initialize
    • List of expressions for the constructor with a NewExpression

Also fixed some of the catch handling

  • ThrowExtractJsonPropertyException needs to be public for it to be called (like ThrowReadValueException already is)
  • One place needed to refer to property.Name rather than just property
  • There is a case where property is null so handle that for the call to ThrowReadValueException as well

Fixes #34393

@roji
Copy link
Member

roji commented Oct 16, 2024

@ChrisJollyAU thanks for submitting this - this is generally a non-trivial part of EF.

Just to set expectations, it will probably be quite a while before we're able to review this - we're currently heads-down in 9.0 stabilization, docs and various other activities... But we definitely plan to do substantial work on (and hopefully finalize) the NativeAOT support in 10, and this would be part of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.NotImplementedException for Precompiled Query with detailed errors enabled
2 participants