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

Provide analyzer + code fix for turning sync command to async and viceversa #38

Closed
kzu opened this issue Nov 2, 2022 · 0 comments · Fixed by #39
Closed

Provide analyzer + code fix for turning sync command to async and viceversa #38

kzu opened this issue Nov 2, 2022 · 0 comments · Fixed by #39
Labels
enhancement New feature or request

Comments

@kzu
Copy link
Member

kzu commented Nov 2, 2022

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 or IAsyncCommandHandler 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> to IAsyncCommandHandler<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.

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 kzu closed this as completed in #39 Nov 3, 2022
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 kzu added the enhancement New feature or request label Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant