Skip to content

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

Open
ChrisJollyAU wants to merge 1 commit intodotnet:mainfrom
ChrisJollyAU:fix34393
Open

Lift try..catch out of an expression and replace with a temporary variable#34912
ChrisJollyAU wants to merge 1 commit intodotnet:mainfrom
ChrisJollyAU:fix34393

Conversation

@ChrisJollyAU
Copy link
Copy Markdown
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
Copy Markdown
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.

@roji roji requested a review from a team as a code owner January 13, 2026 17:12
@roji roji force-pushed the main branch 2 times, most recently from 249ae47 to 6b86657 Compare January 13, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.NotImplementedException for Precompiled Query with detailed errors enabled

3 participants