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.

closing a condition block on the last line of file fails when followed by a blank line

See original GitHub issue

Part of my dotnet project template has a yml file for which i have had to add my own SpecialCustomOperations configuration so comments can be detected

template.json:

  "SpecialCustomOperations": {
    "*.yml" : {
      "Operations": [
        {
          "type": "conditional",
          "configuration": {
            "style": "line",
            "token": "#"
          }
        }
      ]
    }
  }

I have found that when an #endif statement is on the last line of the file followed by a blank line (as posix requires) the dotnet new operation fails to initialise the template completely. However if the file has no blank lines or more than one blank line the template is processed correctly.

my-config-file.yml:


thing:
  - thing1
  - thing2
##if( condition )
  -- thing3
##endif

The error i get is

Template "DemoProject" could not be created.
Error while processing file /my-config-file.yml
Non-negative number required.
Parameter name: srcOffset

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
AR-Maycommented, Aug 26, 2020

Fixed!

0reactions
genaltcommented, Aug 28, 2020

@RehanSaeed I will try to do my best to include this fix into .NET 5 release (5.0.100 mid of November). Also, feel free to join our Gitter channel, where you can ask questions like this (https://gitter.im/dotnet/templating).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stopping condition for when the last line of a file is blank C++
From what I understand, you have something like this: std::ifstream file("file.txt"); std::string line; while(getline(file,line)) { //read ...
Read more >
SyntaxError: unexpected EOF while parsing
EOF stands for "end of file," and this syntax error occurs when Python detects an unfinished statement or block of code. This can...
Read more >
if / else errors - learn how to fix these
When you put a semicolon at the end of a condition, like this: if ... the `;` was the end of your if...
Read more >
PSR-12: Extended Coding Style
All PHP files MUST end with a non-blank line, terminated with a single LF. ... Any closing brace MUST NOT be followed by...
Read more >
block-closing-brace-empty-line-before
This rule is deprecated and will be removed in the future. See the migration guide. Require or disallow an empty line before the...
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