Partial ObservableProperty in ObservableObject shows error CS0229 ambiguity between property and property
还没有人认领这个 Issue。
评估
调研方向
未指定任何仓库文件或测试。首先使用 CommunityToolkit.Mvvm 8.4.0 重现最小的部分 ObservableProperty 示例,并检查 ObservableProperty 的源代码生成路径;当对 Item.Returned 的外部访问不再产生 CS0229,同时生成的属性仍能正确编译和运行时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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
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
- 主要语言
- C#
- 星标
- 3.8k
- 派生
- 403
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
CommunityToolkit/dotnet 的其他 Issue
-
RelayCommand<T>.CanExecute(null) returns false for value types without a predicate可能已有人在做 @apachezy 于 90 天前认领。 未关闭bug :bug:
难度 2/5 1-3 小时 新手友好度 84/100
CommunityToolkit/dotnet#1206 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
CommunityToolkit/dotnet#1186 ·
-
bug :bug:
难度 1/5 1 小时以内 新手友好度 68/100
CommunityToolkit/dotnet#648 ·
-
难度 5/5 一周以上 新手友好度 35/100
CommunityToolkit/dotnet#1217 ·
-
bug :bug:
难度 3/5 1-2 天 新手友好度 68/100
CommunityToolkit/dotnet#1215 ·
查看 CommunityToolkit/dotnet 的全部 Issue
相似的 Issue
-
area-multitenancy area-security p1-recommended priority-high technical-debt
难度 2/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
kind/enhancement Provider Upgrade pulumi/pulumi-azure R1 Task
难度 2/5 1-3 小时 新手友好度 65/100
pulumi/pulumi-azure#3669 ·
-
type/bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
webclient does not start可能已有人在做 @PawelTroka 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
PawelTroka/Computator.NET#257 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
eriknihlen/OpenAC#255 ·
维护者通常 1 天内回复