Skip to content

#if DEBUG not properly escaped #1373

@alexishorner

Description

@alexishorner

Describe the bug
An #if DEBUG in file LoginStepDefinitions.cs is not escaped, leading to it not being present in the generated code.

Code snippet:

        var options = new BrowserTypeLaunchOptions();

#if DEBUG
        options.Headless = false;
        options.SlowMo = 500;
#endif

        var browser = await playwright.Chromium.LaunchAsync(options);

To Reproduce
Steps to reproduce the behavior:

  1. dotnet new install Clean.Architecture.Solution.Template::9.0.12
  2. Create directory, e.g. MyProjectInstantiation
  3. cd MyProjectInstantiation
  4. dotnet new ca-sln
  5. Open file tests/Web.AcceptanceTests/StepDefinitions/LoginStepDefinitions.cs
  6. The #if DEBUG in BeforeLoginScenario is not present (line 20):
        var options = new BrowserTypeLaunchOptions();


        var browser = await playwright.Chromium.LaunchAsync(options);

Expected behavior
The template should generate the #if DEBUG:

        var options = new BrowserTypeLaunchOptions();

#if DEBUG
        options.Headless = false;
        options.SlowMo = 500;
#endif

        var browser = await playwright.Chromium.LaunchAsync(options);

Screenshots
After instantiation, line 20 is missing the #if DEBUG:
Image

Expected output:
Image

Additional context
To fix this, surround the #if DEBUG with //-:cnd:noEmit and //+:cnd:noEmit as described in the template wiki:

        var options = new BrowserTypeLaunchOptions();

//-:cnd:noEmit
#if DEBUG
        options.Headless = false;
        options.SlowMo = 500;
#endif
//+:cnd:noEmit

        var browser = await playwright.Chromium.LaunchAsync(options);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions