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

Fix to #34056 - AOT/Query: for queries with JSON, interceptors generate code with labels that are not uniquified #34323

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Jul 31, 2024

Problem was that when we generate shaper for extracting json values from the reader (streaming) we use hard-coded name for a label that's used in the loop going through json properties. This is fine for normal scenarios, since compiler can figure out the right label to jump to based on scope/reference, but when we generate c# code from that expression, we run into issues for case of nested JSON. Existing code already works if the label is not named explicitly - LinqToCSharpSyntaxTranslator generates names for unnamed labels and uniquifies the names when needed. Fix is to add the uniquification to all labels, not only the unnamed one.

Also fixed another small bug in LinqToCSharpSyntaxTranslator encountered in the testing - when we process LambdaExpression and are dealing with lifted statements (that need to be incorporated into the lambda body), we assumed it would always be a single expression, but it could also be a block. Fix is to add handling for the block case, which is simply pre-pending lifted statements to the ones already in the block.

Added JSON entities to Blog so that we can test the scenario, also added some posts (there were none) for cases which don't work with JSON entities, e.g. set ops.

Fixes #34056

…te code with labels that are not uniquified

Problem was that when we generate shaper for extracting json values from the reader (streaming) we use hard-coded name for a label that's used in the loop going through json properties. This is fine for normal scenarios, since compiler can figure out the right label to jump to based on scope/reference, but when we generate c# code from that expression, we run into issues for case of nested JSON.
Existing code already works if the label is not named explicitly - LinqToCSharpSyntaxTranslator generates names for unnamed labels and uniquifies the names when needed. Fix is to add the uniquification to all labels, not only the unnamed one.

Also fixed another small bug in LinqToCSharpSyntaxTranslator encountered in the testing - when we process LambdaExpression and are dealing with lifted statements (that need to be incorporated into the lambda body), we assumed it would always be a single expression, but it could also be a block. Fix is to add handling for the block case, which is simply pre-pending lifted statements to the ones already in the block.

Added JSON entites to Blog so that we can test the scenario, also added some posts (there were none) for cases which don't work with JSON entities, e.g. set ops.

Fixes #34056
@maumar maumar requested a review from roji July 31, 2024 06:21
@maumar maumar merged commit ccf0247 into main Jul 31, 2024
7 checks passed
@maumar maumar deleted the fix34056 branch July 31, 2024 07:41
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.

AOT/Query: for queries with JSON, interceptors generate code with labels that are not uniquified
2 participants