-
Notifications
You must be signed in to change notification settings - Fork 4k
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
CompilationUnitSyntax.Members[i].ToFullString()
skips #endif
if it's at the end of the file
#66019
Comments
The |
Yes. This is by-design. |
I see, thanks both of you! I'm always impressed how awesome sharplab is, btw. Do you folks happen to know/remember/can think of any other gotchas of the following approach to translate
I'd be happy to be pointed to any documentation/code if you know a good source to learn about it 😃 |
If you have it as |
I'm afraid that's not the case, since I'm mixing multiple files into one, but good to know, thanks! |
What exactly the scenario where you want to do this? Why it is needed to merge multiple trees? Anyway, my suggestion for that is:
|
It's for dotnet-combine tool, which aims to do exactly that, merge multiple C# files into a single one and keep everything working. I'm fully aware there are some scenarios that will very tricky or just impossible to support, such as the one with multiple top-level statements that you mention, but I'm fine with that. I got it working more or less as I expected 2 years ago, following a process similar to what you described, but I'm revisiting now (i.e. added support for file-scoped namespaces) and realizing that the devil's in the detail, of course.
I need to have a look that last part of this, since I'm definitely not doing that right now. |
Basically what I mean here is for something like this #if DEBUG
using System;
#endif
public class C { } In this case, |
Thanks a lot @Youssef1313, good example of edge case that represents a bug in the tool as it is right now. |
@eduherminio If you want to figure out what are all the parts of a roslyn/src/Compilers/CSharp/Portable/Syntax/Syntax.xml Lines 3020 to 3033 in 0d6ace5
|
Awesome, thanks a lot @svick! |
Version Used:
Microsoft.CodeAnalysis.CSharp.Workspaces
v4.4.0Steps to Reproduce:
Expected Behavior:
This piece of code:
prints the whole content of
valid_file.cs
:Actual Behavior:
The mentioned piece of code prints:
Skipping the
#endif
The text was updated successfully, but these errors were encountered: