The MediatR handlers that are generated from the IWebApiService declarations are not debuggable at runtime (to do with how Source Generators work).
The code in the IWebApiService class is also not debuggable since it is not part of the execution pipeline.
This experience could be better for developers.
Solution
A better experience might be achieved if we did this:
Source Generate the MediatR handlers, but instead of including the original code in them, we generate code that calls the original code.
To do this, we would have to instantiate the IWebApiService class (in the handler) and call the appropriate method.
To do that, we need to construct the instance of the class (in the handler) using the selected ctor, and local variables in the selected ctor.
This approach seems feasible because:
Each HTTP request would already need to create an instance of the IWebApiService class and inject dependencies. Otherwise, we would not be able to use Scoped dependencies
We have the variable names of all the injected dependencies of the IWebApiService class in the generator already.
The MediatR handlers that are generated from the
IWebApiService
declarations are not debuggable at runtime (to do with how Source Generators work).The code in the
IWebApiService
class is also not debuggable since it is not part of the execution pipeline.This experience could be better for developers.
Solution
A better experience might be achieved if we did this:
IWebApiService
class (in the handler) and call the appropriate method.This approach seems feasible because:
IWebApiService
class and inject dependencies. Otherwise, we would not be able to use Scoped dependenciesIWebApiService
class in the generator already.