In Roslyn (Microsoft.CodeAnalysis), SyntaxToken
s have Text
and ValueText
fields. In all of the situations that I've observed so far, these two values are the same. ValueText
has documentation while Text
does not. As far as I can tell, that's the only difference.
Why do both exist? In what situation would they be different, and why?
Why do both exist?
Because they're sometimes different and both are useful.
In what situation would they be different, and why?
int @interface = 123;
The Text
of the @interface
token is @interface
. The ValueText
is interface
. The text tell you what is the text as it appeared in the source code. The value text tells you logically, what is the text of this thing? An escaped keyword used as an identifier is logically the text of the keyword; that's the name of the identifier.
There are other situations in which the text and the value text can be different; see if you can find some.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With