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

Build errors when using CommunityToolkit.MVVM with Visual Studio extensions #889

Open
1 of 4 tasks
stigzler opened this issue Jun 13, 2024 · 1 comment
Open
1 of 4 tasks
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior

Comments

@stigzler
Copy link

stigzler commented Jun 13, 2024

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:

enter image description here

Also, source generator appears to work:

enter image description here

However, I get the build error The name 'ExceptionMessageText' does not exist in the current context:

enter image description here

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
  • 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

@stigzler stigzler added the bug 🐛 An unexpected issue that highlights incorrect behavior label Jun 13, 2024
@stigzler
Copy link
Author

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. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior
Projects
None yet
Development

No branches or pull requests

1 participant