Skip to content
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

Full compatibility with Roslyn #57

Closed
cybernaut4 opened this issue Aug 4, 2023 · 11 comments
Closed

Full compatibility with Roslyn #57

cybernaut4 opened this issue Aug 4, 2023 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@cybernaut4
Copy link

cybernaut4 commented Aug 4, 2023

Situation

Visual Studio Code's C# extension just got a massive update from 1.26.0 to 2.0.320 (see here), which replaces Omnisharp with Roslyn as the default language server.

I can tell it has an amazing processing speed and is more current than OmniSharp.

Problem

The current Godot plugin doesn't communicate with Roslyn about any existent, project-based SignalNames and MethodNames.

Example

image

Suggestions

  • Add an option in the extension's settings to switch between OmniSharp and Roslyn, making Roslyn as the default.
  • Any mentioning about overlooked details is appreciated.
@cybernaut4 cybernaut4 added the enhancement New feature or request label Aug 4, 2023
@raulsntos
Copy link
Member

There's no communication with Roslyn, the SignalName and MethodName classes are generated by C# source generators and unrelated to this extension. Roslyn generates these classes by invoking the generators as part of the compilation.

If VSCode's C# extension doesn't recognize them then it's a bug in their extension. Looks like this is the same issue or related to dotnet/vscode-csharp#5999.

@jasonmalinowski
Copy link

Just chiming in here from the Roslyn team: we do expect generators to be running but we have had some reports of various generators not working with new extension. We are investigating those reports (dotnet/roslyn#68590 is one bug, dotnet/vscode-csharp#5999 is the other you pointed to). If you see those bugs get closed and your stuff is still not working, do file a bug and we'll take a look.

@geekley
Copy link

geekley commented Sep 7, 2023

As a temporary workaround, you can tell C# extension to use Omnisharp instead of Roslyn with "dotnet.server.useOmnisharp": true in settings.json and get proper support to generated code.
Note that this setting seems to not be declared in the extension manifest, so it may appear to be unrecognized by VSCode, but it still works.

@geekley
Copy link

geekley commented Sep 11, 2023

This likely won't solve the issue, but still, it's probably better just in case.
You might wanna add to the generated sources:

For reference, you can see how .NET 7 GeneratedRegexAttribute adds those to its generated code.

@raulsntos
Copy link
Member

A file is considered generated by .NET1 if it has a // <auto-generated /> comment as the first line of the file, or if the file name ends with one of these suffixes: .designer, .generated, .g or .g.i.

We use the .generated suffix for all our generated source code (see godotengine/godot#67766) so that shouldn't be a problem.

Footnotes

  1. This is described in the Microsoft documentation for nullable references: https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references

@jasonmalinowski
Copy link

FYI we should have a fix on the way for this: dotnet/roslyn#70331 (and yes, I'm embarrassed here.)

@jasonmalinowski
Copy link

And version 2.7.25 is now out to the VS Code extension marketplace, so that should fix this. If there's still issues do let me know and we'll dig further!

@raulsntos
Copy link
Member

Tested 2.7.25 and works great, so I'll close this issue as fixed. Thank you so much!

@ana-rchy
Copy link

still doesnt work with the newest version of the extension

@raulsntos
Copy link
Member

@ana-rchy If you still have issues with the Microsoft C# extension, it would probably be better to report it in their repository (https://github.com/dotnet/vscode-csharp). Make sure to mention the version of the extension you are using, and whether or not you're also using the C# Dev Kit extension (https://github.com/microsoft/vscode-dotnettools).

@geekley
Copy link

geekley commented Oct 27, 2023

@ana-rchy @jasonmalinowski For me on v2.8.23 of Code C# extension it's now partially working. I no longer get error squiggles on references defined in generated code. But when I try to use "jump to definition" or "find all references" where it involves generated code, I get this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants