dotnet / dotnet/templating

`isRequired` symbol should throw an error rather than greedly eat the following symbol

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

Description

### Is your feature request related to a problem? Please describe.

When defining a required symbol, if no value is provided during the call, and the symbol is followed by another symbol, the required symbol will consume the following one rather than throw an error.

### Describe the solution you'd like.

If no parameter is explicitly provided for a required symbol an error shuld be thrown rather than consuming the following symbol.

### Additional context

given the following `template.json`
```
"symbols": {
"foo": {
"description": "",
"type": "parameter",
"dataType": "string",
"replaces": "foo",
"isRequired": true
},
"bar": {
"description": "",
"type": "parameter",
"dataType": "string",
"replaces": "bar",
"defaultValue": "bar"
}
}
```
when called like so:
`dotnet new new-template --foo --bar -n TestProj `
the result is
Template
```
namespace TestNamespace;

public static class MyClass
{
public static string Foo { get; set; } = "foo";
public static string Bar { get; set; } = "bar";
}
```

Actual
```
namespace TestNamespace;

public static class MyClass
{
public static string Foo { get; set; } = "--bar";
public static string Bar { get; set; } = "bar";
}
```

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.