-
Notifications
You must be signed in to change notification settings - Fork 25
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
#region erases newlines #58
Comments
I'm looking into it. To my own surprise it appears there is no support for preserving |
Awesome. Thank you! Let me know when there's something to test and I'll give it a go. |
Fixed in v2.6.2.3. The problem was that code in |
I think there's still some problems here. I just pulled down trunk and compiled (msbuild Loyc-Slim.sln /p:Configuration=Release) and still found some
The original version used an unroll outside the replacePP -- this was just the smallest thing I found that triggered it. It seems like it might be triggered when I use LeMP outside of a method definition -- the invocations inside methods seem to work ok. I'm also seeing behavior where white-space will affect the output here too -- much like #59. For instance, adding a newline after the |
The moment you said it, I realized what the problem is. EC# handles a
( It could be argued that this behavior makes sense for real comments but not so much for |
I wasn't aware of rawText -- I was looking for something similar in the docs but must have missed it. Regarding treating region the same way as comments, I'd submit that that's probably not quite right: regions have a start and end and enclose an arbitrary sequence of intermediate elements. You'll also get a compiler error if they're mismatched (which is how I found this). They seem to me like they'd be better modeled in the same way as code between curly braces, though perhaps without increasing the indentation level in the output. I also wanted to understand the behavior of comments: it seems like you're saying that there's two kinds of comments: those that should be emitted to the output, and those that are considered comments on the LeMP code and should be stripped for output, but it also seems like there's no explicit mechanism for expressing which is which -- do I have that right? For my use case, comments are ultimately a nice to have, so I don't know what priority this deserves, however FWIW, it seems like it would be a nice addition to have some kind of syntax to denote comments that are intended to be written to output vs comments on the LeMP code that should be suppressed. Perhaps the right way to do it would be to assume that C# comment syntax should always be emitted, but add some other piece of syntax for EC# comments that are not intended to be written to the output. I'm unsure if this is how it currently works, but it would be awesome if comments were subject to substitutions the same as any other code when written to the output -- this would facilitate generating docstrings along with the generated code. |
Well, I'm not saying there are two kinds of comments. All comments given to the printer are emitted, but if a node is deleted from the syntax tree then any comments attached to it cannot be printed as they no longer exist. The I will think about changing how |
I posed this question over on Stackoverflow but in the course of investigating it, I think it might be a bug. Here's a minimal test case that shows the issue:
When the region markers are in place, the DllImport + method prototype are emitted like so:
(note: no newline, and #region, #endregion lines are omitted)
Whereas if you comment out the region markers, the newline is preserved:
Though the emitted code still compiles and does what it's supposed to, region markers are super useful in classes large enough to be generated by a macro system. It would be great to have them emitted, and also not affect the whitespace of the enclosed code.
The text was updated successfully, but these errors were encountered: