Support for conditional parameters
Currently all parameters are shown unless hidden via isHidden flag in dotnetcli.host.json.
The feature suggests parameters:
- to be enabled based on condition
- to be required based on condition
Example:
"symbols": {
"username": {
"type": "parameter",
"description": "the username to be used for auth",
"datatype": "text",
"enabled": "Platform == ios",
"required": "Platform == ios",
"replaces": "%USERNAME%",
}
}
Enabled will allow the option to be suggested as part of tab completion in dotnet new. If Enabled is evaluated to false, and parameter is specified the error occurs.
In IDE, Enabled may be represented by enabling/disabling the corresponding control.
Required defines if the parameter is required. In case Required is evaluated to "true" but parameter is not specified, the error occurs.
Notes:
- validation should be implemented to ensure the template doesn't have circular dependencies in conditions.
- for initial release, likely the symbols in these conditions will be limited to parameters only.
- keep an eye on performance of evaluating the enabled/required conditions. This should be very simple and very fast.
- the initial set of variables that should be included for variables are:
- template symbols of the 'parameter' type
- more can be added easily later based on user input
This feature partially already suggested here: https://github.com/dotnet/templating/issues/2173, https://github.com/dotnet/templating/issues/4102
Discuss if we need additional config for visible.
Subtasks:
- [x] Documentation: In Progress: https://github.com/dotnet/templating/pull/4876
- [x] Implementation: In Progress: https://github.com/dotnet/templating/pull/4872
- [ ] Schemastore update: TBD
- [ ] Tab completition rich support: TBD
The work is completed