✅ Attribute based definition vs. Interface based definition
Greetings,
I'm working on my Source Generator that generates boilerplate code for SignalR communication. For this I have basically two ways of defining the interface the generator uses to generate the actual code.
public interface IInterfaceBasedHubServerMethods{ // This will have the server-to-client methods Task SentByTheServer(string message);}public interface IInterfaceBasedHubClientMethods{ // This will have the client-to-server methods Task<string> SentByTheClient(string message);}[HubClient(HubUri = "interface-based-hub")]public interface IInterfaceBasedHub : IBidirectionalHub<IInterfaceBasedHubServerMethods, IInterfaceBasedHubClientMethods>{}
public interface IInterfaceBasedHubServerMethods{ // This will have the server-to-client methods Task SentByTheServer(string message);}public interface IInterfaceBasedHubClientMethods{ // This will have the client-to-server methods Task<string> SentByTheClient(string message);}[HubClient(HubUri = "interface-based-hub")]public interface IInterfaceBasedHub : IBidirectionalHub<IInterfaceBasedHubServerMethods, IInterfaceBasedHubClientMethods>{}
Which do you prefer and why? Thanks for your feedback
Description Currently the source generator runs on HubClients defined via attributes (e.g. the ClientToServerMethod and ServerToClientMethod). Attribute-based example: [HubClient(HubUri = "exa...