-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat: convert Node.Print
to use switch (node.Kind())
#1509
base: main
Are you sure you want to change the base?
Conversation
a35b8e9
to
3531fc6
Compare
The special cases seem to be a bit painful to manage but I don't really see special cases being changed though, possibly just new ones added as the language evolves. The last few language versions have been really straightforward for CSharpier to support though and a few of them didn't even require any changes beyond updating the I thought CSharpier's code coverage was solid until you uncovered the missing tests for There may be a tiny benefit to using RawSyntaxKind which I added a while back. I just heard of FrozenDictionary today although with the dictionary you added only being in the generator I don't know how beneficial it would be. |
Noticed that tests weren't failing for #1509 when I forgot to account for `SyntaxKind.UncheckedStatement`. This will hopefully catch it Co-authored-by: Bela VanderVoort <[email protected]>
Fair enough, for whats its worth I have manually checked each printer type case I missed any
Did you change anything with CLI tests? 4 days ago they started failing.
Good shout, it can't hurt to add it.
Yeah, I've been looking for an excuse to use it for ages. Unfortunately it would be a bad fit for the generator 😞 . Briefly considered it for |
3531fc6
to
4ef540c
Compare
switch (syntaxNode.Kind())
instead ofis
. Should be slightly faster 🤞Debug.Assert
in the default branch to ensure that future changes to roslyn / mistakes withSyntaxKind
are caughtBenchmarks
Ran
FormatAsync
in a for loop 10 times to try and average performance. Seems to show a small 1.5% increase in performance at the cost of more complexity and the potential for errors. Do you think its worth merging this pr @belav ? TBH I'm a little dissapointed 😅I did wonder if using chained
or
might affect the generated code 🤷 the massiveSyntaxKind
switch statements in roslyn use severalcase
tags instead. Perhaps this is lowered into better code? Looking at the IL I think it creates a jump table, although I'm not sure - I'm not fluent in IL 😄 .Before
After