FairPlayTube
FairPlayTube copied to clipboard
Implement the Clients Service Generator
Note: A branch with initial progress already exists: https://github.com/efonsecab/FairPlayTube/tree/ClientServicesGenerator
Important After doing some initial testing it seems the Source Generators projects only have access to the project being compiled and dependencies.
- Create a new class library project named "FairPlayTube.Controllers.Interfaces"
- Add an interface class for each controller, format: "I[ControllerName]" e.g.: IPlaylistController
- Add the corresponding endpoints signatures to the respective interface
After doing that, reference the interfaces project from both "FairPlayTube.Controllers" and "FairPlayTube.ClientService", in theory, this will allow the Source Generator to have access to the interfaces, and with those signatures we can automatically generate the client classes.
We want to automatically generate some of the client services using C# Source Generators.
- Create a class named "GenerateClientServiceAttribute" in the Controllers project, under a folder named "CustomAttributes"
- Mark the PlaylistController with "[GenerateClientService]"
- Create a new project named "FairPlayTube.Generators.ClientServices", with a class named "ClientServicesGenerator"
- Reference the generator project from the "FairPlayTube.ClientServices" existent project
The "ClientServiceGenerator" class must implement "IIncrementalGenerator".
This class would search for all of the controllers marked the "[GenerateClientService]", inspect all of the endpoints and create a class named "{ControllerPrefix}ClientService" in a file with extension ".g.cs" under a folder named "Generated".
The class must contain all of the client methods to call the endpoint methods, using the existent pattern from the other client services.
@LuisiitoDev , you can start it whenever you want, please let me know if you have any questions
@efonsecab perfect, I will be starting the task.