Given that I have created a symbol using SymbolFactory.CreateProperty, how would I add white space. Currently I get accessibility, modifiers, name, type etc. all stringed together when writing out document. Maybe I am writing it out wrong, or I need to add extra step to add white space? I use document.GetText() to write it out to console.
相关问题
- Difference between ISymbol.DeclaringSyntaxReferenc
- Visual Studio IDE0059 C# Unnecessary assignment of
- What's the most efficient way to use Roslyn
- How can we easily find what line in the code cause
- References in Roslyn .rsp files
相关文章
- How do I get a IMethodSymbol or the syntax node of
- Roslyn: Convert C# to VB
- Roslyn getting dependencies for class
- Run Roslyn Code Analyzers on Build Server
- Roslyn scripting: Line number information for run
- Understanding the various options for runtime code
- Replacing a method node using Roslyn
- Closure allocations in C#
Nope, that's what you expect. Generated nodes don't have whitespace, with the intent you'll process it once you're done.
There are two options:
Microsoft.CodeAnalysis.Formatting
. This is the fancy formatter which will attempt to preserve existing whitespace and such, and will only update the nodes that need fixing. This is best if you're updating user code and you don't want to stomp on it.I had the same issue, and I found this to work the best:
where node is a
SyntaxToken
of any kind.