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

Source Generator for [ObservableProperty] doesn't work anymore since upgrading to visual studio 17.11.2. #940

Open
1 of 4 tasks
JorisZwaenepoel opened this issue Sep 6, 2024 · 9 comments
Labels
analyzer 👓 A new analyzer being implemented or updated external ⤴️ Something related to or caused by an external project mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit need more info 📌 More info are needed to investigate this

Comments

@JorisZwaenepoel
Copy link

Describe the bug

I'm using the CommunityToolkit.Mvvm version 8.2.2.

Since I updated Visual Studio 2022 to the latest version 17.11.2, I keep having problems when adding new properties using [ObservableProperty]. The source generator doesn't work automatically, and some keyboard keys (like backspace or delete) don't work anymore. I have to close and restart Visual Studio to be able to continue my work.

I don't know if this is a Visual Studio bug or a toolkit bug.

If this cannot be fixed quickly, I would like to know what the most recent version of Visual Studio where this still works.

Regression

No response

Steps to reproduce

Update Visual Studio 2022 to version 17.11.2

Expected behavior

The sourcegenerator should make the required code for [ObservableProperty] properties on the background without messing up the editor experience.

Screenshots

image

IDE and version

VS 2022

IDE version

Version 17.11.2

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.2.2

Additional context

No response

Help us help you

No, just wanted to report this

@JorisZwaenepoel JorisZwaenepoel added the bug 🐛 An unexpected issue that highlights incorrect behavior label Sep 6, 2024
@Sergio0694
Copy link
Member

Sergio0694 commented Sep 7, 2024

Is your code actually building correctly? Or does it eg. fail to build if you try referencing the generated property?

@Sergio0694 Sergio0694 added external ⤴️ Something related to or caused by an external project need more info 📌 More info are needed to investigate this mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit analyzer 👓 A new analyzer being implemented or updated and removed bug 🐛 An unexpected issue that highlights incorrect behavior labels Sep 7, 2024
@JorisZwaenepoel
Copy link
Author

It builds correctly. But the editor is behaving weird (keyboard not functioning correctly, only inside of Visual Studio).
After restarting Visual Studio, it works correct until I make a new ObservableProperty.
Rolling back to version 17.10.6 of Visual Studio helped to get rid of the problem.
A colleague has experienced the same issues with the same versions. The bug is probably in Visual Studio, not in the Mvvm Toolkit.

@Sergio0694
Copy link
Member

Yeah this sounds like an issue in the IDE. Try reporting it either in the Roslyn repo or with VS Feedback, and link this one.

@Balkoth
Copy link

Balkoth commented Sep 11, 2024

If you do raise an issue elsewhere please post back here that we can vote it up. I have also seen the IDE go nuts about the source generated files, but decided to just ignore it for the time being.

@JorisZwaenepoel
Copy link
Author

I just raised the issue using Visual Studio feedback:
https://developercommunity.visualstudio.com/t/Source-Generator-for-ObservableProperty/10743355

@hawkerm
Copy link

hawkerm commented Sep 20, 2024

I too had been noticing that source generators didn't seem to be updating nicely as they have in the past and I was needing to rebuild on 17.11.3, I noticed this response there in the issue from Joris:

In 17.11 Preview 2, we changed the default source generation execution behavior from “Automatic” to “Balanced”. The easiest action to trigger source generators in this mode is saving the current file. If you would like to restore the old behavior, the option can be found in Tools → Options… → Text Editor → C# → Advanced → Source generator execution.

Thank you,
Sam Harwell

Seems like a big behavior change for those that rely on these features. I guess it's for performance reasons. Would be nice though if they could separate the options for the old source generators vs. the incremental ones or something too.

@JorisZwaenepoel
Copy link
Author

I have no idea if the issues I had were related to this option setting, and I don't think I was using a preview version of Visual Studio either.
Apart from the source generator not regenerating automatically, I also had keyboard issues in Visual Studio at the same time. Those were making it much more difficult to write code (especially the backspace and delete keys that were not working), and required a restart of Visual Studio.

@mischiminator
Copy link

mischiminator commented Sep 25, 2024

I too had been noticing that source generators didn't seem to be updating nicely as they have in the past and I was needing to rebuild on 17.11.3, I noticed this response there in the issue from Joris:

In 17.11 Preview 2, we changed the default source generation execution behavior from “Automatic” to “Balanced”. The easiest action to trigger source generators in this mode is saving the current file. If you would like to restore the old behavior, the option can be found in Tools → Options… → Text Editor → C# → Advanced → Source generator execution.
Thank you,
Sam Harwell

Seems like a big behavior change for those that rely on these features. I guess it's for performance reasons. Would be nice though if they could separate the options for the old source generators vs. the incremental ones or something too.

Thanks !! this made the source generation work as expected.

EDIT: nevermind, worked for like a minute or so ... now i have to build the project again for the source generator to run

@ilGianfri
Copy link

ilGianfri commented Oct 9, 2024

I'm having the same issue with Visual Studio 17.12.0 Preview 2.1, I think this issue is related to the ServiceHub.RoslynCodeAnalysisServiceS.exe skyrocketing in CPU and RAM usage. When this process "goes crazy", Visual Studio becomes unresponsive and stuff like F12 or "the squiggle" stops working for minutes.
I've been able to repro this issue on two different machines -> related feedback https://developercommunity.visualstudio.com/t/ServiceHubRoslynCodeAnalysisServiceSex/10764773

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 👓 A new analyzer being implemented or updated external ⤴️ Something related to or caused by an external project mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit need more info 📌 More info are needed to investigate this
Projects
None yet
Development

No branches or pull requests

6 participants