dotnet / dotnet/aspnetcore

Casing Consistency Between SignalR Clients

Open
#48,746 0 comments 0 reactions 0 assignees View on GitHub
area-signalr design-proposal
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

## Summary

At the moment, we have 4 officially supported versions for SignalR Clients. Two of these clients register handlers as case insensitive and the other two don't.

Case sensitive clients: C# and Java
Case insensitive clients: JS and C++

## Motivation and goals

The issue here is consistency between implementations. When integrate testing my backend I found the difference between c# and js clients, wich lead me to false positives tests.

## In scope

The proposal here is to make all clients case insensitive when registering a handler, that way, we can expect all clients to behave the same way.

## Out of scope

The idea is to be more flexible, so making them all case sensitive is out of scope.

## Risks / unknowns

Despite being more flexible, I believe in some edge cases, we may have older clients registering both handlers to match casing.

## Examples

No matter what SignalR Client my hub client decides to use, I expect the same behavior.
The following declarations should be about the same invocation:

```csharp
// C#
connection.On("MyMethod", MyMethodHandler);
connection.On("mymethod", MyMethodHandler);
```
```cpp
//Java
connection.on("MyMethod", myMethodHandler);
connection.on("mymethod", myMethodHandler);
```

### Current Implementations

The Javascript client, register the handlers with lower case target name:
https://github.com/dotnet/aspnetcore/blob/239b00d00cb271ab3719ef3843570727778c11f6/src/SignalR/clients/ts/signalr/src/HubConnection.ts#L468

The C++ client uses an unordered map with case insensitive comparers:
https://github.com/aspnet/SignalR-Client-Cpp/blob/facb478884450ee805a21e8e794dec4c156e3a11/src/signalrclient/hub_connection_impl.h#L59

The Java client uses a hash map:
https://github.com/dotnet/aspnetcore/blob/239b00d00cb271ab3719ef3843570727778c11f6/src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/CallbackMap.java#L14

And the C# client uses a concurrent dictionary with ordinal string comparer:
https://github.com/dotnet/aspnetcore/blob/239b00d00cb271ab3719ef3843570727778c11f6/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs#L78

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.