Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'isEnabled' not evaluated for generated symbols #8478

Open
l-schueber opened this issue Oct 17, 2024 · 0 comments
Open

'isEnabled' not evaluated for generated symbols #8478

l-schueber opened this issue Oct 17, 2024 · 0 comments

Comments

@l-schueber
Copy link

Product

dotnet CLI (dotnet new)

Describe The Bug

when I use 'isEnabled' in a generated symbol it does not seem to evaluate and always processes.

example:
Foo.cs

public class Foo
{
    public readonly int FooId { get; init; }
}

template.json

{
  "name": "Tests",
  "identity": "Tests",
  "shortName": "tests",
  "symbols": {
    "ChangeFoo": {
      "type": "parameter",
      "dataType": "bool",
      "isRequired": true
    },
    "IdentifierName": {
      "type": "generated",
      "generator": "constant",
      "parameters": {
        "value": "Bar"
      },
      "isEnabled": "ChangeFoo",
      "replaces": "Foo",
      "fileRename": "Foo"
    }
  }
}

When executing dotnet new tests --ChangeFoo false, I expect it to generate 'Foo.cs' as is.
Instead, it generates 'Bar.cs' with all Foo replaced to 'Bar', which I expect to happen when I execute dotnet new tests --ChangeFoo true instead.

It seems to correctly evaluate if I change 'IdentifierName' to 'parameter' without changing the 'isEnabled' condition

"IdentifierName": {
      "type": "parameter",
      "dataType": "string",
      "isEnabled": "ChangeFoo",
      "replaces": "Foo",
      "fileRename": "Foo"
    }

Calling `dotnet new tests --ChangeFoo false --IdentifierName Bar' will not replace 'Foo' as expected

To Reproduce

Steps:

  1. create (and install) basic template setup with .template.config\template.json and Foo.cs as described
    .
    ├── .template.config
    │   └── template.json
    └── Foo.cs

  2. run dotnet new tests --ChangeFoo false

  3. check generated file

dotnet Info

output .NET SDK: Version: 8.0.401 Commit: 811edcc344 Workload version: 8.0.400-manifests.b6724b7a MSBuild version: 17.11.4+37eb419ad

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.401\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5

.NET SDKs installed:
8.0.304 [C:\Program Files\dotnet\sdk]
8.0.401 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Visual Studio Version

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant