Build errors when using CommunityToolkit.MVVM with Visual Studio extensions
Describe the bug
I've asked around on SO and discord, but getting no joy. Forgive me if this is my misunderstanding. My SO post: I'm getting build errors despite the SourceGenerator apparently working correctly. Example code:
namespace VisGit.ViewModels
{
public partial class MainViewModel: ObservableObject
{
[ObservableProperty]
string _exceptionMessageText = "Exception Text";
public MainViewModel()
{
ExceptionMessageText = "Test Change";
}
}
}
Intellisense shows the public property ExceptionMessageText as being generated successfully:
Also, source generator appears to work:
However, I get the build error The name 'ExceptionMessageText' does not exist in the current context:
Full code: https://github.com/stigzler/VisGit/blob/1-setup-base-extension-environment/VisGit/ViewModels/MainViewModel.cs
Not sure what I'm dong wrong. I'm using .net Framework 4.8 (is that the issue?). Any ideas?
Regression
No response
Steps to reproduce
1. Create a new VSIX Project w/Tool Window project
2. Create any Class creating a new ObservableProperty via the Attribute
Expected behavior
priavte var is converted to Public property and usable in same class. Project also builds without error "The name '[x]' does not exist in the current context"
Screenshots
See OP
IDE and version
VS 2022
IDE version
4.8.09032
Nuget packages
- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [X] CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
8.2.2
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item
I've narrowed it down some more. As getting more help on SO, have posted details there:
https://stackoverflow.com/questions/78619310/build-errors-when-using-communitytoolkit-mvvm-with-visual-studio-extensions
It feels like this really doesn't play nicely with VS Extensions. :(


