| | | 1 | | using Microsoft.AspNetCore.Builder; |
| | | 2 | | using Microsoft.Extensions.Logging; |
| | | 3 | | |
| | | 4 | | using NexusLabs.Needlr.AspNet; |
| | | 5 | | |
| | | 6 | | namespace NexusLabs.Needlr.SignalR; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Marker interface for source-generated SignalR hub registration. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <remarks> |
| | | 12 | | /// When using source generation, the generator emits a |
| | | 13 | | /// <c>SignalRHubRegistrations.MapGeneratedHubs(WebApplication)</c> extension method |
| | | 14 | | /// that can be called directly in your Program.cs: |
| | | 15 | | /// <code> |
| | | 16 | | /// var app = builder.Build(); |
| | | 17 | | /// app.MapGeneratedHubs(); // Generated at compile-time |
| | | 18 | | /// </code> |
| | | 19 | | /// |
| | | 20 | | /// This approach is preferred for AOT/trimmed applications because it avoids |
| | | 21 | | /// all runtime reflection. The <see cref="SignalRHubRegistrationPlugin"/> uses |
| | | 22 | | /// reflection and is marked with appropriate AOT warnings. |
| | | 23 | | /// |
| | | 24 | | /// To enable hub registration generation, implement <see cref="IHubRegistrationPlugin"/> |
| | | 25 | | /// with compile-time constant property values: |
| | | 26 | | /// <code> |
| | | 27 | | /// public class ChatHubPlugin : IHubRegistrationPlugin |
| | | 28 | | /// { |
| | | 29 | | /// public string HubPath => "/chat"; |
| | | 30 | | /// public Type HubType => typeof(ChatHub); |
| | | 31 | | /// } |
| | | 32 | | /// </code> |
| | | 33 | | /// </remarks> |
| | | 34 | | public static class GeneratedSignalRHubRegistration |
| | | 35 | | { |
| | | 36 | | /// <summary> |
| | | 37 | | /// Extension method placeholder that provides documentation for source-generated hub registration. |
| | | 38 | | /// The actual implementation is generated by NexusLabs.Needlr.Generators when |
| | | 39 | | /// IHubRegistrationPlugin implementations are discovered. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <remarks> |
| | | 42 | | /// This method exists to provide IntelliSense documentation. The generated |
| | | 43 | | /// <c>NexusLabs.Needlr.Generated.SignalRHubRegistrations.MapGeneratedHubs()</c> |
| | | 44 | | /// extension method should be called instead. |
| | | 45 | | /// </remarks> |
| | | 46 | | public static void DocumentationPlaceholder() |
| | | 47 | | { |
| | | 48 | | // This method is intentionally empty. |
| | | 49 | | // It exists only for documentation purposes. |
| | | 50 | | // The actual MapGeneratedHubs() method is source-generated. |
| | 1 | 51 | | } |
| | | 52 | | } |
| | | 53 | | |