Skip to content

Commit 7a652f2

Browse files
azp: iif allow complex objects / disable short circuit (#535)
1 parent 59c0337 commit 7a652f2

5 files changed

Lines changed: 79 additions & 3 deletions

File tree

  • src/Sdk/DTExpressions2/Expressions2/Sdk/Functions/v1
  • testworkflows/azpipelines

src/Sdk/DTExpressions2/Expressions2/Sdk/Functions/v1/Iif.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ internal sealed class Iif : Function
88

99
protected sealed override Object EvaluateCore(EvaluationContext context, out ResultMemory memory)
1010
{
11-
// TODO learn the semantics of this function
1211
memory = null;
1312
bool cond = Parameters[0].EvaluateBoolean(context);
14-
String body = Parameters[cond ? 1 : 2].EvaluateString(context) as String ?? String.Empty;
15-
return body;
13+
EvaluationResult then = Parameters[1].Evaluate(context);
14+
EvaluationResult otherwise = Parameters[2].Evaluate(context);
15+
return cond ? then.Raw ?? then.Value : otherwise.Raw ?? otherwise.Value;
1616
}
1717
}
1818
}

testworkflows/azpipelines/iff-functions-ado-2025/pipeline.yml renamed to testworkflows/azpipelines/iif-functions-ado-2025/pipeline.yml

File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# src: https://learn.microsoft.com/en-us/azure/devops/release-notes/2025/pipelines/sprint-248-update#new-pipeline-expression-functions
2+
parameters:
3+
- name: test
4+
type: object
5+
default:
6+
pool: ManagedDevOpsPool
7+
- name: test2
8+
type: object
9+
default:
10+
pool: Azure Devops
11+
variables:
12+
poolToUse: ${{ iif(eq(variables['Build.Reason'], 'PullRequest'), parameters.test2, parameters.test).pool}}
13+
poolToUse2: ${{ iif(ne(variables['Build.Reason'], 'PullRequest'), parameters.test2, parameters.test).pool}}
14+
15+
stages:
16+
- stage: build
17+
pool: ${{variables.poolToUse}}
18+
jobs:
19+
- job:
20+
steps:
21+
- task: DotNetCoreCLI@2
22+
inputs:
23+
command: 'build'
24+
- ${{ if ne(variables.poolToUse2, 'Azure Devops') }}:
25+
- assert: failure
26+
27+
- ${{ if ne(variables.poolToUse, 'ManagedDevOpsPool') }}:
28+
- assert: failure
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
parameters:
2+
- name: test
3+
type: object
4+
default:
5+
pool: ManagedDevOpsPool
6+
- name: test2
7+
type: object
8+
default:
9+
pool: Azure Devops
10+
variables:
11+
poolToUse: ${{ iif(eq(variables['Build.Reason'], 'PullRequest'), parameters.test2, parameters.test).pool}}
12+
13+
stages:
14+
- stage: build
15+
pool: ${{variables.poolToUse}}
16+
jobs:
17+
- job:
18+
steps:
19+
- task: DotNetCoreCLI@2
20+
inputs:
21+
command: 'build'
22+
- ${{ if ne(variables.poolToUse, 'ManagedDevOpsPool') }}:
23+
- assert: failure
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ExpectedException: TemplateValidationException
2+
# ExpectedMessage: parameters.test3
3+
parameters:
4+
- name: test
5+
type: object
6+
default:
7+
pool: ManagedDevOpsPool
8+
- name: test2
9+
type: object
10+
default:
11+
pool: Azure Devops
12+
variables:
13+
poolToUse: ${{ iif(eq(variables['Build.Reason'], 'PullRequest'), parameters.test3, parameters.test).pool}}
14+
15+
stages:
16+
- stage: build
17+
pool: ${{variables.poolToUse}}
18+
jobs:
19+
- job:
20+
steps:
21+
- task: DotNetCoreCLI@2
22+
inputs:
23+
command: 'build'
24+
- ${{ if ne(variables.poolToUse, 'ManagedDevOpsPool') }}:
25+
- assert: failure

0 commit comments

Comments
 (0)