Closed lildude closed 2 years ago
can c# also switch to tree-sitter https://github.com/tree-sitter/tree-sitter-c-sharp?
given github c# code navigation is using tree-sitter for a while https://github.blog/changelog/2020-10-19-code-navigation-for-c-repositories/
We use the tree-sitter library to find definitions and call sites in your code.
can c# also switch to tree-sitter https://github.com/tree-sitter/tree-sitter-c-sharp?
Unfortunately that's not within Linguist's control (and also not relevant to this issue). Tree-sitter grammars are pulled in directly by the new syntax highlighting engine regardless of what Linguist states. We only keep the list up-to-date to make it easier to refer people to the correct source in the event there is a syntax highlighting issue.
Is the change as simple as {
→[{;]
?
Possibly. That's what I would do but I don't know anything about C# to know if I'm missing something else. I only worked out the cause from searching DDG for C# namespaces 😁
Hello @lildude and @Nixinova - being a C# developer, I can assure you the change is just as simple as that. Namespaces can now be declared either using a {
with the relevant closing }
. Or if you want the entire file within the namespace, the recommended syntax now is to use ;
. That's literally it.
I'm not familiar with the linguist project to know what exactly you need to change (hence, hesitant regarding making a PR myself), but I hope I could provide some context.
C# 10 introduced support for file scoped namespaces which are namespace declarations without a body, for example:
As there is no body, and thus no
{
char, this won't match the heuristic:^(\s*namespace\s*[\w\.]+\s*{|\s*\/\/)
The heuristic should be updated to cater for these new declarations.
Discussed in https://github.com/github/linguist/discussions/5869