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

Unclear errors on field with ObservableProperty #947

Open
1 of 4 tasks
elad770 opened this issue Sep 10, 2024 · 2 comments
Open
1 of 4 tasks

Unclear errors on field with ObservableProperty #947

elad770 opened this issue Sep 10, 2024 · 2 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

@elad770
Copy link

elad770 commented Sep 10, 2024

Describe the bug

I have a wpf (core based) project, with net6.0 (with visual studio 2022 enterprise), where I installed from nuget the toolkit mvvm version 8.0.0. In the project I have a very basic class that is defined as partial and inherits ObservableObject (just like any guide that explains how to work with the toolkit's MVVM) and contains 3 fields
each wrapped respectively in an ObservableProperty attribute.
When I try to compile I get errors that I have no idea why they actually happen, the errors actually refer to cs g files that are dynamically created using the toolkit, I will give an example for example I have a field in the basic class (called AstroInfo) called star and on it I get an error below that directs it to the g.cs file
The type 'AstroInfo' already contains a definition for 'Star'
In addition to this, more unclear errors in relation to functions that describe events such as
'AstroInfo' already defines a member called 'OnStarChanging' with the same parameter
and-
A partial method may not have multiple defining

I would appreciate guidance in this regard

Regression

No response

Steps to reproduce

using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AstroMatch.Models
{
    public partial class AstroInfo : ObservableObject
    {
        [ObservableProperty]
        private string star;

        [ObservableProperty]
        private int degree;

        [ObservableProperty]
        private int hour;
    }

}

Expected behavior

The compilation goes without any errors

Screenshots

image

image

IDE and version

VS 2022

IDE version

No response

Nuget packages

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

Nuget package version(s)

8.0.0

Additional context

No response

Help us help you

Yes, but only if others can assist

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

Mmh @manodasanW I wonder if this sounds similar to that issue you noticed with the CsWinRT generators running multiple times in WPF? I can't think of another explanation for those errors otherwise 😐

@elad770 would you be able to provide a binlog?

That is, build with -v:diag /bl and share the file.
Thank you!

@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 10, 2024
@elad770
Copy link
Author

elad770 commented Sep 10, 2024

@Sergio0694 It is not possible to upload bl or rar files here, just change the extension of the file to bl
Thank you very much
msbuild.txt

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

2 participants