-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Provide analyzer + code fix for turning sync command to async and viceversa #38
Labels
enhancement
New feature or request
Comments
kzu
added a commit
that referenced
this issue
Nov 3, 2022
…eversa The new analyer detects the need for changes in the command definition itself, allowing the command handler to drive changes to it in a more automated fashion, as follows: * If during the command implementation, you find that the command needs to be made async, you can just change implemented interface in the handler from ICommandHandler > IAsyncCommandHandler and an analyzer + codefix will suggest changing the command from ICommand to IAsyncCommand in turn. * If during the implementation, you find that you'd like to return a value, or perhaps even change the return type you previously had, an analyzer + codefix will suggest the relevant changes to the command too, setting/removing the return type as needed (by changing the ICommand<TResult> or IAsyncCommand<TResult> as needed, even removing the TResult entirely as needed. Closes #38
kzu
added a commit
that referenced
this issue
Nov 3, 2022
…eversa The new analyer detects the need for changes in the command definition itself, allowing the command handler to drive changes to it in a more automated fashion, as follows: * If during the command implementation, you find that the command needs to be made async, you can just change implemented interface in the handler from ICommandHandler > IAsyncCommandHandler and an analyzer + codefix will suggest changing the command from ICommand to IAsyncCommand in turn. * If during the implementation, you find that you'd like to return a value, or perhaps even change the return type you previously had, an analyzer + codefix will suggest the relevant changes to the command too, setting/removing the return type as needed (by changing the ICommand<TResult> or IAsyncCommand<TResult> as needed, even removing the TResult entirely as needed. Closes #38
kzu
added a commit
that referenced
this issue
Nov 3, 2022
…eversa The new analyer detects the need for changes in the command definition itself, allowing the command handler to drive changes to it in a more automated fashion, as follows: * If during the command implementation, you find that the command needs to be made async, you can just change implemented interface in the handler from ICommandHandler > IAsyncCommandHandler and an analyzer + codefix will suggest changing the command from ICommand to IAsyncCommand in turn. * If during the implementation, you find that you'd like to return a value, or perhaps even change the return type you previously had, an analyzer + codefix will suggest the relevant changes to the command too, setting/removing the return type as needed (by changing the ICommand<TResult> or IAsyncCommand<TResult> as needed, even removing the TResult entirely as needed. Closes #38
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The command class is annotated with a marker interface that determines if the command is synchronous or asynchronous. This marker interface needs to be kept in sync with the command handler, which must use either
ICommandHandler
orIAsyncCommandHandler
and there's a type constraint on that interface as well to ensure both align.This makes it cumbersome to turn a sync implementation into async by just changing the command handler interface being implemented from
ICommandHandler<T>
toIAsyncCommandHandler<T>
, since we need to also go to the command T and change the interface there. Since it's the handler the one that drives the implementation/invocation style required of the command, it would be convenient to have an analyzer + codefix that can automatically change the command's interface if we change the implementation (handler) one.The text was updated successfully, but these errors were encountered: