Skip to content

Partial ObservableProperty in ObservableObject shows error CS0229 ambiguity between property and property #1056

@jpageacsys

Description

@jpageacsys

Describe the bug

I'm developing a WinUI application with Community Toolkit MVVM 8.4.0.
I switched the properties in my application to use the new format. Here's one example:

[ObservableProperty]
public partial bool Returned { get; set; } = returned;

And this is a simplified version of the constructor for the object:
public partial class Item(bool returned) : ObservableObject

This all works as expected and compiles fine but all uses of the property elsewhere show the Compiler Error CS0229. In this case it shows:
Ambiguity between Item.Returned and Item.Returned.
I only have the one property called Returned.
As I said, it all compiles fine and works correctly but I'm not able to get rid of the error.

Regression

No response

Steps to reproduce

Create a class with the type ObservableObject and create a partial Observable Property. Use it elsewhere in the app.

Example:

public partial class Item(bool returned) {
    [ObservableProperty]
    public partial bool Returned { get; set; } = returned;
}

Then access the property somewhere else in the app.

Example:

var newItem = new Item(false);
newItem.Returned = true;

This shows the compiler error.

Expected behavior

I would like to remove the false alarm.

Screenshots

Image

IDE and version

VS 2022

IDE version

Version 17.13.1

Nuget packages

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

Nuget package version(s)

8.4.0

Additional context

No response

Help us help you

Yes, but only if others can assist

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions