dotnet / dotnet/templating

Inconsistent behavior of conditions involving `boolean` parameters

Open
#5,801 0 comments 0 reactions 0 assignees View on GitHub
area: content-generation Priority:3 triage:transfer-to-sdk triaged
Dominant language
No language data
Stars
1.7k
Forks
399
Avg merge
3d 5h
Merged PRs (30d)
39

Description

Template engine has 4 different expressions evaluators at the moment:
- `CPP` - used for majority of language files
- `CPP2` - used for conditions inside template.json, not used in content generation.
- `MSBuild` - used for conditions in MSBuild files
- `VB` - used for conditions in VB

They act very differently when different syntax is used.

Details:
Given `boolean` parameter `A`
- `CPP2` can process any of those syntax: `if (A)`, `if (A == true)`, `(A == "true")`.
- `CPP` can process those syntax: `if (A)`, `if (A == true)`, but not `(A == "true")`.
- `VB` can process only `if (A)` correctly
- MSBuild can process `if (A)`, `if (A == true)`, `(A == 'true')`, but not `(A == "true")`.

Note MSBuild has 2 ways to define condition as explained [here] (https://github.com/dotnet/templating/wiki/Conditional-processing-and-comment-syntax#msbuild-files).

See https://github.com/dotnet/templating/pull/5800 for more details.
Consider unifying experience, and documenting it better.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.