CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
3.07k stars 299 forks source link

[RelayCommand] attribute causes CS0260 类型“MainViewModel”的声明上缺少 partial 修饰符;存在此类型的其他分部声明 #819

Closed tangmanger closed 10 months ago

tangmanger commented 10 months ago

Describe the bug

When using [ReplayCommand] to mark a method in MainViewModel, there is a cs0260 error prompt when compiling

Regression

No response

Steps to reproduce

platform:.net 6
    [RelayCommand]
    public void Loaded()
    {

    }

Expected behavior

Normal compilation passed

Screenshots

QQ截图20240105225312

IDE and version

VS 2022

IDE version

17.8.3

Nuget packages

Nuget package version(s)

8.2.1

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Sergio0694 commented 10 months ago

This is not a bug, it's by design. The error message is telling you what the issue is. You forgot to add partial to your class 🙂 Just make MainViewModel a partial class and this will work fine.