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

RelayCommandAttribute can't be used with interface and generic class #817

Open
1 of 4 tasks
Dabbel opened this issue Jan 2, 2024 · 0 comments
Open
1 of 4 tasks
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior

Comments

@Dabbel
Copy link

Dabbel commented Jan 2, 2024

Describe the bug

If you have an interface, without a generic type, that requires the implementation of an ICommand property it isn't possible to use the RelayCommandAttribute on a generic class that uses the generic type as parameter on the command method.
The RelayCommandAttribute generates a property of type IRelayCommand<T> that doesn't satisfy the implementation of the interface.

Regression

No response

Steps to reproduce

public interface ITest
{
    ICommand TestSomethingCommand { get; }
}

public partial class Test<T> : ITest
{
    // Generates a property of type IRelayCommand<T>, this doesn't satisfy ITest.ICommand
    [RelayCommand]
    private void TestSomething(T obj)
    {
    }
}

Expected behavior

The generated property should be of type ICommand or RelayCommandAttribute should have an option to generate the property with of type ICommand instead of IRelayCommand<T>.

Screenshots

No response

IDE and version

VS 2022, Rider

IDE version

No response

Nuget packages

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

Nuget package version(s)

8.2.2

Additional context

No response

Help us help you

Yes, but only if others can assist

@Dabbel Dabbel added the bug 🐛 An unexpected issue that highlights incorrect behavior label Jan 2, 2024
@Dabbel Dabbel changed the title RelayCommandAttribute can't be used with interface and generic class RelayCommandAttribute can't be used with interface and generic class Jan 2, 2024
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
Projects
None yet
Development

No branches or pull requests

1 participant