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

Modify the "conditional" operation or create a new operation that handles un-prefixing matched blocks #56

Closed
mlorbetske opened this issue Jul 8, 2016 · 7 comments
Assignees
Milestone

Comments

@mlorbetske
Copy link
Member

//#if FOO
//Content if FOO was true
//#else
Content if FOO was false
//#endif

Should automatically un-comment Content if FOO was true when FOO is true and should leave Content if FOO was false as a literal if FOO as not true. The operation will need to buffer the content being written to see if the included block is uniformly commented out (needs a more rigorous definition) before committing it to the output stream.

https://github.com/dotnet/cli/issues/2052#issuecomment-231299842

@RehanSaeed
Copy link

It has to be noted that the case where the code block contains a comment should also be handled:

//#if FOO
// Some comment
int i = 0;
//#else
// // Some comment
// int i = 0
//#endif

I do this with the use of a double comment.

@mlorbetske
Copy link
Member Author

Current design is:

//#if (FOO)
// Some comment
int i = 0;
////#else <-- Note the double comment, this indicates that comment stripping will be done if the block is active
// // Some comment
// int i = 0;
//#endif

We'll also change the defaults for languages that don't support preprocessors to use //#if instead of //if (currently used)

@RehanSaeed
Copy link

Support for multiple file formats is essential. I use:

  • // as the default.
  • <!-- --> for HTML and XML based formats.
  • @* *@ for Razor.
  • # for text based formats e.g. nginx.conf, robots.txt etc.

@mlorbetske
Copy link
Member Author

The work to do the block uncommenting (blocks of line comments that is) was done here #69 and updated dotnet/templating#2 (we've moved to https://github.com/dotnet/templating). The work to set the rest of the default commenting styles is being tracked by dotnet/templating#4 in the new repo.

@seancpeters
Copy link
Collaborator

Conditional handling for windows batch files using "rem" line level comments, was setup in this commit:
dotnet/templating@1c0d078

Other commits in the same PR (still in progress) deal with nginx.conf comment processing using "#" line level comments. This is still in progress, but we'll be able to re-use it for other file types using that style of comments.

@seancpeters
Copy link
Collaborator

The nginx.conf and robots.txt setup is complete with dotnet/templating@d33aa93

@sayedihashimi
Copy link
Member

:shipit:

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

No branches or pull requests

4 participants