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

Cannot add [ObservableProperty] tag to a variable. #174

Closed
1 of 14 tasks
jeranio opened this issue Mar 13, 2022 · 4 comments
Closed
1 of 14 tasks

Cannot add [ObservableProperty] tag to a variable. #174

jeranio opened this issue Mar 13, 2022 · 4 comments
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@jeranio
Copy link

jeranio commented Mar 13, 2022

Describe the bug

The project won't run and this error comes up.
Severity Code Description Project File Line Suppression State
Error CS0102 The type 'Test' already contains a definition for 'FirstName' LCI_WCT E:\SOFTWARE PROJECTS\LCIProject\LCI QC App\LCI_WCT\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator\LCI_WCT.Test.cs 12 Active

No matter what name I give the variable, the same error comes up but with the new variable name.

Regression

No response

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

1. Create a new blank WPF C# Desktop application.
2. Bring in via Nuget, either Microsoft/Community MVVM Toolkit currently version 7.1.2
3. Create a view model for the MainWindow.xaml , eg. MainWindowViewModel
4. In the view model make class partial, extend ObservableObject (import the toolkit namespace)
5. Add a variable e.g string FirstName;
6. Add the [ObservableProperty] tag.
7. Build

Expected behavior

To build successfully.

Screenshots

MVVM_VM_CODE
TOOLKIT_ERROR
TOOLKIT_IMPORT_VERSION

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Other SDK version

20H2

Visual Studio Version

2022

Visual Studio Build Number

17.1.1

Device form factor

Desktop

Nuget packages

Community.Toolkit.Mvcm(7.1.2)

Additional context

No response

Help us help you

No.

@jeranio jeranio added the bug 🐛 An unexpected issue that highlights incorrect behavior label Mar 13, 2022
@ghost ghost added the needs triage 🔍 This issue is awaiting triage by maintainers label Mar 13, 2022
@ghost
Copy link

ghost commented Mar 13, 2022

Hello jeranio, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@jeranio
Copy link
Author

jeranio commented Mar 15, 2022

The YouTube presenter got back to me and says I should try the demo on WCT 8 which I believe is still in preview release. I am going to see if I can get the v8 and see if that solves the issue.

@michael-hawker michael-hawker transferred this issue from CommunityToolkit/WindowsCommunityToolkit Mar 21, 2022
@Sergio0694
Copy link
Member

The issue is that you're using a field name that collides with the name of the generated property.

This was tracked by #140 and has already been solved with #141. Will be included in 8.0.0-Preview3 🙂

@Sergio0694 Sergio0694 added mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit and removed needs triage 🔍 This issue is awaiting triage by maintainers labels Mar 21, 2022
@jeranio
Copy link
Author

jeranio commented Mar 21, 2022 via email

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 mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
None yet
Development

No branches or pull requests

2 participants