CommunityToolkit / CommunityToolkit/dotnet
`RelayCommandAttribute` can't be used with interface and generic class
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 400
- PR merge metrics
- No merged PRs in 30d
Description
### 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` that doesn't satisfy the implementation of the interface.
### Regression
_No response_
### Steps to reproduce
```text
public interface ITest
{
ICommand TestSomethingCommand { get; }
}
public partial class Test : ITest
{
// Generates a property of type IRelayCommand, 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`.
### Screenshots
_No response_
### IDE and version
VS 2022, Rider
### IDE version
_No response_
### Nuget packages
- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [X] 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
Contributor guide
Assessment
This issue has not been assessed yet.