Skip to content

Conversation

@AllanGuigou
Copy link

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

{
static ExpressionConstants()
{
AddFunction<Case>("case", 3, Byte.MaxValue);
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The new case function lacks test coverage. Based on the coding guidelines for this repository, changes should be accompanied by non-trivial tests that meaningfully exercise the core functionality. Tests should be added to validate the case function with:

  • Correct odd number of arguments (predicate-result pairs plus default)
  • Validation that even number of arguments throws an error
  • Boolean predicate evaluation
  • Proper return values for matched predicates
  • Default value when no predicates match
  • Error handling for non-boolean predicates

Copilot generated this review using guidance from repository custom instructions.
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>
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.

2 participants