© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
5 replies
liekong1991

❔ How to correctly use Roslyn to parse RegionDirectiveTriviaSyntax in a project?

I would like to ask a question about parsing syntax tree for #region preprocessor directive. For example, for the simple code shown in the picture, I have tried several methods but failed to parse the SyntaxNode for the #region block. Do I need to set any special options?
Here's the parsing method I'm currently using, but it doesn't seem to be able to parse it out no matter what I try. However, the syntax analyzer that comes with Visual Studio can see the relevant Node.
image.png
LTVA4EOOIGMSYN.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ How to use switch correctly?
C#CC# / help
3y ago
❔ How to parse a json response?
C#CC# / help
4y ago
❔ how to use Docker for 2 apps in a project
C#CC# / help
4y ago