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

[BUG] When upgrading to dev kit the source generators no longer work. #37

Closed
michaelstaib opened this issue Jun 7, 2023 · 9 comments
Closed
Assignees

Comments

@michaelstaib
Copy link

Describe the Issue

I have a project with a source generator which worked with Visual Studio full, Rider and VSCode omnisharp... after upgrading this no longer works. If I build with dotnet build I have no errors but the intellisense does not recognise generated code.

Steps To Reproduce

  1. dotnet new install hotchocolate.templates
  2. dotnet new graphql
  3. dotnet build
  4. code .

In the program.cs the extension method AddTypes has squiggles. This method is created by the source generator.

Expected Behavior

Source generators work like in the previous version.

Environment Information

  • OS macOS
@michaelstaib michaelstaib added bug Something isn't working needs-triage labels Jun 7, 2023
@mvromer
Copy link

mvromer commented Jun 7, 2023

I see the same thing in my projects where I make extensive use of the OneOf.SourceGenerator package. The GenerateOneOf marker attribute is produced by the generator during its post-initialization phase. With OmniSharp and in VS, this worked just fine, but with the new dev kit extension, VS Code has a red squiggle under each usage of [GenerateOneOf] with the following error:

The type or namespace name 'GenerateOneOfAttribute' could not be found (are you missing a using directive or an assembly reference?) Roslyn CS0246

Building the projects with dotnet build works as expected.

@sailro
Copy link
Member

sailro commented Jun 7, 2023

I spotted as well that custom Roslyn Analyzers (in general I mean, not only source generators) are not always called in the context of the new C# extension + C# Dev Kit.

@mavasani do you think it can be something similar to what you fixed for diagnostic suppressors ?
dotnet/roslyn#68270

I also spotted that if you open simultaneously the same project with both VSCode and VS, then sometimes it is "fixing" analyzers execution with VSCode. Quite weird.

cc @jbevain

@MarsonShine
Copy link

+1
same MacOS

@arunchndr arunchndr added enhancement New feature or request area-roslyn triaged The issue has been triaged and removed enhancement New feature or request labels Jun 8, 2023
@jasonmalinowski
Copy link
Member

We do expect generators to be running; we don't quite have full support for generators yet. Other folks who commented on this issue (@sailro and @mvromer) are you also on macOS?

@MarsonShine
Copy link

MarsonShine commented Jun 8, 2023

Just now, I was running vscode in windows and everything was fine, recognizing ISourceGenerator and GeneratorAttribute

@mvromer
Copy link

mvromer commented Jun 8, 2023

I was on a Win10 machine at the time.

EDIT: I also just tried this on a MacBook, and the same behavior occurs on that (source generator's marker attribute shows up as a compiler error within VS Code).

@sailro
Copy link
Member

sailro commented Jun 8, 2023

On my side analyzers are not correctly running and I repro both on windows and ubuntu. (Perhaps we need another issue given it is not a source generator). But I have the feeling it is quite the same issue, and related to the Roslyn LSP.

@jasonmalinowski
Copy link
Member

(Perhaps we need another issue given it is not a source generator)

We've got #61 tracking looking at analyzers as well, although there's a good chance they've both got the same root cause.

@jasonmalinowski
Copy link
Member

@mvromer OK, thanks for confirming it's not just macOS!

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

No branches or pull requests

7 participants