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

Updating FunctionExecutorGenerator to avoid long if/else chains. #2749

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

fabiocav
Copy link
Member

@fabiocav fabiocav commented Oct 6, 2024

Issue describing the changes in this PR

resolves #2748

This change updates the FunctionExecutorGenerator to avoid using long if/else chains that may lead to a compiler error.

The generation changes the emitted code from:

// ...
if (string.Equals(context.FunctionDefinition.EntryPoint, "FunctionName1", StringComparison.Ordinal))
{
 // generated body
}
else if (string.Equals(context.FunctionDefinition.EntryPoint, "FunctionName2", StringComparison.Ordinal))
{
   // generated body
}

to:

// ...
if (string.Equals(context.FunctionDefinition.EntryPoint, "FunctionName1", StringComparison.Ordinal))
{
 // generated body
    return;
}
if (string.Equals(context.FunctionDefinition.EntryPoint, "FunctionName2", StringComparison.Ordinal))
{
   // generated body
    return;
}

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

@fabiocav fabiocav merged commit a98b271 into main Oct 7, 2024
29 checks passed
@fabiocav fabiocav deleted the fabiocav/fesgfix branch October 7, 2024 17:47
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.

Function executor source generator uses a pattern that may lead to a compiler error
2 participants