SyntaxTree: How to read full ValueText
of a multi-line Raw Literal String (or: why is it different from a multi-line verbatim string?)
#72271
-
Edit: It looks like I made a mistake in passing my "source code" to the parser. And I got confused .. so my bad ;-) QuestionHow can I use a parsed How I Parse my CodeUsing CSharpSyntaxTree
.ParseText(
"source code - I'll give examples below",
path: "dummy",
options: CSharpParseOptions
.Default
.WithLanguageVersion(LanguageVersion.Latest)); Actual BehaviorVerbatim multi-line stringwith the following source text: S[@"a verbatim
string text"]; Just to be sure that I don't make any mistakes, this is how I define it in my c# code: @"
S[""""""a raw literal
multiline string
""""""];" --> since i use a @-verbatim multiline string to declare the source, I need Result
=> I can get the string value via Multiline Raw Literal StringS["""a raw literal
multiline string
"""]; Result
Note that Question: how am I supposed to extract |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Ok so it looks like I just got confused and didn't properly specify the multiline raw literal. Here's how it works: @"
S[""""""
a raw literal
multiline string
""""""];" resulting in a single argument with |
Beta Was this translation helpful? Give feedback.
-
Your raw string literal is incorrect. It cannot cross multiple lines without starting with a new line after the initial quotes. |
Beta Was this translation helpful? Give feedback.
-
Check the diagnostics on the syntax tree instance you get back. It should indicate the problem. |
Beta Was this translation helpful? Give feedback.
Your raw string literal is incorrect. It cannot cross multiple lines without starting with a new line after the initial quotes.