Skip to content

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

@nicolo-castro-hudl

Description

@nicolo-castro-hudl

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";
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions