Consolidate multiple SendAsync overloads with a params object?[] approach #59704
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-signalr
Includes: SignalR clients and servers
Background and Motivation
ASP.NET Core’s ClientProxyExtensions currently offers numerous SendAsync overloads for varying argument counts (from 0 to 10). Each overload simply allocates a fixed-size object[] and calls SendCoreAsync.
While this design provides explicit discoverability (i.e., IntelliSense will show an overload for every possible argument count), it also comes with:
A large API surface and repetitive signatures.
Complexity in maintenance (any future additions potentially require more overloads).
Potential confusion for new contributors or library users due to the large number of nearly identical methods.
Goal: Consolidate these multiple overloads into a smaller API surface by using params object?[] parameters, which can handle an arbitrary number of arguments.
Proposed API
Below is a diff of the suggested API changes in a ref-assembly-style format. The main idea is to introduce one (or two) SendAsync method(s) with a params parameter, and potentially retire or mark obsolete the existing overloads.
Usage Examples
Consider how calling code might look if we adopt this design:
Developers can pass any number of arguments without needing a dedicated overload.
Alternative Designs
Risks
The text was updated successfully, but these errors were encountered: