Skip to content

Conversation

@AllanGuigou
Copy link
Contributor

No description provided.

@AllanGuigou AllanGuigou requested a review from a team as a code owner December 11, 2025 18:42
Copilot AI review requested due to automatic review settings December 11, 2025 18:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for a new case expression function that provides conditional evaluation similar to a switch/case or if-else-if chain. The function accepts an odd number of arguments: pairs of boolean predicates and their corresponding results, plus a default value.

  • Implements the Case function in multiple expression namespaces (GitHub.Actions.Expressions and GitHub.DistributedTask.Expressions2)
  • Adds an AllowCaseFunction flag to control whether the case function is available in specific contexts
  • Includes parser-level validation to ensure the case function receives an odd number of parameters

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Sdk/Expressions/Sdk/Functions/Case.cs New implementation of the Case function for GitHub Actions expressions
src/Sdk/DTExpressions2/Expressions2/Sdk/Functions/Case.cs Duplicate Case function implementation for DistributedTask expressions
src/Sdk/Expressions/ExpressionConstants.cs Registers the case function with min 3 and max 255 parameters
src/Sdk/DTExpressions2/Expressions2/ExpressionConstants.cs Registers the case function in DTExpressions2 namespace
src/Sdk/Expressions/ParseExceptionKind.cs Adds EvenParameters exception type for case function validation
src/Sdk/DTExpressions2/Expressions2/ParseExceptionKind.cs Adds EvenParameters exception type in DTExpressions2
src/Sdk/Expressions/ParseException.cs Adds error message for even parameter count
src/Sdk/DTExpressions2/Expressions2/ParseException.cs Adds error message for even parameter count in DTExpressions2
src/Sdk/Expressions/ExpressionParser.cs Adds allowCaseFunction parameter and validation logic for even parameters
src/Sdk/DTExpressions2/Expressions2/ExpressionParser.cs Adds allowCaseFunction parameter and validation logic in DTExpressions2
src/Sdk/WorkflowParser/ObjectTemplating/TemplateContext.cs Adds AllowCaseFunction property defaulting to true
src/Sdk/DTObjectTemplating/ObjectTemplating/TemplateContext.cs Adds AllowCaseFunction property in DTObjectTemplating
src/Sdk/WorkflowParser/ObjectTemplating/Tokens/TemplateToken.cs Passes AllowCaseFunction to expression parser in 4 evaluation methods
src/Sdk/DTObjectTemplating/ObjectTemplating/Tokens/TemplateToken.cs Passes AllowCaseFunction to expression parser in 4 evaluation methods
src/Sdk/WorkflowParser/Conversion/WorkflowTemplateConverter.cs Passes AllowCaseFunction when converting if conditions
src/Sdk/DTPipelines/Pipelines/ObjectTemplating/PipelineTemplateConverter.cs Passes AllowCaseFunction when converting if conditions
src/Runner.Worker/ActionManifestManager.cs Disables case function for action manifest parsing
src/Runner.Worker/ActionManifestManagerLegacy.cs Disables case function for legacy action manifest parsing

AllanGuigou and others added 3 commits December 12, 2025 11:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
try
{
var tree = new ExpressionParser().CreateTree(expression, null, context.GetExpressionNamedValues(), context.ExpressionFunctions);
var tree = new ExpressionParser().CreateTree(expression, null, context.GetExpressionNamedValues(), context.ExpressionFunctions, allowCaseFunction: context.AllowCaseFunction);
Copy link
Collaborator

@ericsciple ericsciple Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this for the evaluator? Do we hardcode to true for the evaluator?

Basically I just want to make sure we set to true for evaluation. If evaluation works E2E then 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this is defaulted to true but will allow the manifest manager code paths to disable it.

@AllanGuigou AllanGuigou enabled auto-merge (squash) December 17, 2025 15:54
@AllanGuigou AllanGuigou merged commit 6510776 into main Dec 17, 2025
11 checks passed
@AllanGuigou AllanGuigou deleted the allanguigou/case branch December 17, 2025 15:57
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.

3 participants