✅ Register services based on Mediator registrated RequestClassHandlerWrapper &CommandClassHandlerWra
Hello folks 👋. I am not good at Roslyn source gens at all. Can somebody point me what should I do to make
IValidationErrorFactory<>
instances source generated by Roslyn. Or send me a guide lines / docs I needed for this. Appreciate ur help
When the node (record, class, struct, whatever...) which implements interface
Mediator.IRequest<Task_Manager.Common.Result<@TResponse, Task_Manager.Common.OneOfError<@TError, Task_Manager.Common.ValidationError>>>
┌─────────────┬───────────┴────────────────────────────────────┘
found, it is getting it @TResponse
and @TError
types in generic and it's name and produce the following code:
Example of code which should be generated:
https://github.com/tokKurumi/Task-Manager/blob/5ec15cc628bd5d61bd98a10dd7ff6e4306c7fa80/Task%20Manager.Identity.Application/DependencyInjection.cs#L76GitHub
Task-Manager/Task Manager.Identity.Application/DependencyInjection....
Task Manager. Contribute to tokKurumi/Task-Manager development by creating an account on GitHub.
11 Replies
$ig
If you want to make an incremental source generator, please make sure to read through both the design document and the cookbook before starting.
@kurumi If you see me in vc I can help you out a little.
FWIW, this is extremely out of date, and does not follow any current practices
Unknown User•4d ago
Message Not Public
Sign In & Join Server To View
enough I hope
thx @SleepWellPupper, I jump into VC, once u are able. And then once it's done I post the final result here and close this thread
We prepared this plan for working
// 1. List of handlers from services !
// 2. List of implementations from assembly
// 3. Extract TResponse to: T and TError it goes to step 4
// 4. Construct GenericValidationErrorFactory<T, TError>
// 5. Services.TryAddSingleton<IValidationErrorFactory<TResponse>, GenericValidationErrorFactory<T, TError>>
The plan is to not use SGs for now.
Here is high overview how to achieve this registration:
0. Create generic factory
1. Get all services which implements
RequestClassHandlerWrapper<TCommand, Result<T, OneOfError<TError, ValidationError>>>
CommandClassHandlerWrapper<TCommand, Result<T, OneOfError<TError, ValidationError>>>
2. Get it's T
and TError
3. Register IValidationErrorFactory<Result<T, OneOfError<TError, ValidationError>>>
Here is the source code of service scanning
This approach makes me able to remove Scrutor package dependency in addition
thx to @SleepWellPupper
P. S. code is a bit nasty, I gonna improve it soon. But it worksGitHub
Task-Manager/Task Manager.Identity.Application/DependencyInjection....
Task Manager. Contribute to tokKurumi/Task-Manager development by creating an account on GitHub.
code looks good, but why do you check for null here?
https://github.com/tokKurumi/Task-Manager/blob/6fc37c412dade0b802076ab9b9f9c4e9fdf721ce/Task%20Manager.Identity.Application/DependencyInjection.cs#L107
GitHub
Task-Manager/Task Manager.Identity.Application/DependencyInjection....
Task Manager. Contribute to tokKurumi/Task-Manager development by creating an account on GitHub.
just copilot auto completion, I remove it