question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditionals Fail in .editorconfig Files

See original GitHub issue

I have an .editorconfig file with the following conditional in it:

...omitted

##if (StyleCop)
##########################################
# StyleCop
##########################################

...omitted

#endif

...omitted

In my template.json file, I have then added the following boolean option:

    "StyleCop": {
      "type": "parameter",
      "datatype": "bool",
      "description": "Adds and enforces StyleCop analyzers.",
      "defaultValue": "true"
    },

When I create a project using dotnet new and turn off the StyleCop option, the .editorconfig file failes to remove the code above. Is there a bug with files that start with a . or have no file extension?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
RehanSaeedcommented, Jun 16, 2020

I got both .editorconfig and Dockerfile working like so:

"SpecialCustomOperations": {
    "**/.editorconfig": {
      "operations": [
        {
          "type": "conditional",
          "configuration": {
            "if": [ "#if" ],
            "else": [ "#else" ],
            "elseif": [ "#elseif" ],
            "endif": [ "#endif" ],
            "actionableIf": [ "##if" ],
            "actionableElse": [ "##else" ],
            "actionableElseif": [ "##elseif" ],
            "actions": [ "uncomment", "reduceComment" ],
            "trim": "true",
            "wholeLine": "true",
            "evaluator": "C++"
          }
        },
        {
          "type": "replacement",
          "configuration": {
            "original": "#",
            "replacement": "",
            "id": "uncomment"
          }
        },
        {
          "type": "replacement",
          "configuration": {
            "original": "##",
            "replacement": "#",
            "id": "reduceComment"
          }
        }
      ]
    },
    "**/Dockerfile": {
      "operations": [
        {
          "type": "conditional",
          "configuration": {
            "if": [ "#if" ],
            "else": [ "#else" ],
            "elseif": [ "#elseif" ],
            "endif": [ "#endif" ],
            "actionableIf": [ "##if" ],
            "actionableElse": [ "##else" ],
            "actionableElseif": [ "##elseif" ],
            "actions": [ "uncomment", "reduceComment" ],
            "trim": "true",
            "wholeLine": "true",
            "evaluator": "C++"
          }
        },
        {
          "type": "replacement",
          "configuration": {
            "original": "#",
            "replacement": "",
            "id": "uncomment"
          }
        },
        {
          "type": "replacement",
          "configuration": {
            "original": "##",
            "replacement": "#",
            "id": "reduceComment"
          }
        }
      ]
    }
  },
1reaction
RehanSaeedcommented, Jun 16, 2020

@brettrowberry You’re awesome! Thanks.

There should still probably be some more support for common file extensions like .editorconfig and Dockerfile built into the templating engine. So I’ll leave this open but it’s nice to know we can add custom types.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaking change: EditorConfig files implicitly included - .NET
Reason for change ... The compiler now supports .editorconfig files, and they're implicitly included in a project if the file is in the...
Read more >
c# - MSBuild - Treat Warnings from editorconfig as Errors ...
I set up an editorconfig file for my project and it works perfectly in my IDE and throws the right warnings. Examples: IDE0052...
Read more >
EditorConfig settings - Visual Studio (Windows)
Settings in EditorConfig files let you maintain consistent coding styles and settings in a codebase, such as indent style, tab width, ...
Read more >
Pipeline should fail if the code violates the .editorConfig file
Hello, I do have an editorConfig which works fine. Inside my IDE, if I violates the rules from that editorConfig, I received an...
Read more >
Unable to open .editorconfig files - Developer Community
Attempting to add a new .editorconfig file to either Project or Solution results in a crash. This is using either the Default or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found