Skip to content

Commit 0d80ffa

Browse files
authored
Fix #10756 by removing some previously-obsoleted SignalR methods (#20015)
* fixes #10756 by removing previously-obsoleted APIs in SignalR * update reference assemblies * missed a ref * think I fixed the test
1 parent ec10429 commit 0d80ffa

13 files changed

+20
-447
lines changed

src/Analyzers/Analyzers/src/StartupFacts.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ public static bool IsSignalRConfigureMethodGesture(IMethodSymbol symbol)
138138
throw new ArgumentNullException(nameof(symbol));
139139
}
140140

141+
// UseSignalR has been removed in 5.0, but we should probably still check for it in this analyzer in case the user
142+
// installs it into a pre-5.0 app.
141143
if (string.Equals(symbol.Name, SymbolNames.SignalRAppBuilderExtensions.UseSignalRMethodName, StringComparison.Ordinal) ||
142144
string.Equals(symbol.Name, SymbolNames.HubEndpointRouteBuilderExtensions.MapHubMethodName, StringComparison.Ordinal) ||
143145
string.Equals(symbol.Name, SymbolNames.ComponentEndpointRouteBuilderExtensions.MapBlazorHubMethodName, StringComparison.Ordinal))

src/Analyzers/Analyzers/test/CompilationFeatureDetectorTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public async Task DetectFeaturesAsync_FindsNoFeatures()
2929
}
3030

3131
[Theory]
32-
[InlineData(nameof(StartupWithUseSignalR))]
3332
[InlineData(nameof(StartupWithMapHub))]
3433
[InlineData(nameof(StartupWithMapBlazorHub))]
3534
public async Task DetectFeaturesAsync_FindsSignalR(string source)

src/Analyzers/Analyzers/test/TestFiles/CompilationFeatureDetectorTest/StartupWithUseSignalR.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/SignalR/common/Http.Connections/ref/Microsoft.AspNetCore.Http.Connections.netcoreapp.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ public static partial class ConnectionEndpointRouteBuilderExtensions
1515
public static Microsoft.AspNetCore.Builder.ConnectionEndpointRouteBuilder MapConnections(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern, Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions options, System.Action<Microsoft.AspNetCore.Connections.IConnectionBuilder> configure) { throw null; }
1616
public static Microsoft.AspNetCore.Builder.ConnectionEndpointRouteBuilder MapConnections(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern, System.Action<Microsoft.AspNetCore.Connections.IConnectionBuilder> configure) { throw null; }
1717
}
18-
public static partial class ConnectionsAppBuilderExtensions
19-
{
20-
[System.ObsoleteAttribute("This method is obsolete and will be removed in a future version. The recommended alternative is to use MapConnections or MapConnectionHandler<TConnectionHandler> inside Microsoft.AspNetCore.Builder.UseEndpoints(...).")]
21-
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseConnections(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action<Microsoft.AspNetCore.Http.Connections.ConnectionsRouteBuilder> configure) { throw null; }
22-
}
2318
}
2419
namespace Microsoft.AspNetCore.Http.Connections
2520
{
@@ -34,15 +29,6 @@ public partial class ConnectionOptionsSetup : Microsoft.Extensions.Options.IConf
3429
public ConnectionOptionsSetup() { }
3530
public void Configure(Microsoft.AspNetCore.Http.Connections.ConnectionOptions options) { }
3631
}
37-
[System.ObsoleteAttribute("This class is obsolete and will be removed in a future version. The recommended alternative is to use MapConnection and MapConnectionHandler<TConnectionHandler> inside Microsoft.AspNetCore.Builder.UseEndpoints(...).")]
38-
public partial class ConnectionsRouteBuilder
39-
{
40-
internal ConnectionsRouteBuilder() { }
41-
public void MapConnectionHandler<TConnectionHandler>(Microsoft.AspNetCore.Http.PathString path) where TConnectionHandler : Microsoft.AspNetCore.Connections.ConnectionHandler { }
42-
public void MapConnectionHandler<TConnectionHandler>(Microsoft.AspNetCore.Http.PathString path, System.Action<Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions> configureOptions) where TConnectionHandler : Microsoft.AspNetCore.Connections.ConnectionHandler { }
43-
public void MapConnections(Microsoft.AspNetCore.Http.PathString path, Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions options, System.Action<Microsoft.AspNetCore.Connections.IConnectionBuilder> configure) { }
44-
public void MapConnections(Microsoft.AspNetCore.Http.PathString path, System.Action<Microsoft.AspNetCore.Connections.IConnectionBuilder> configure) { }
45-
}
4632
public static partial class HttpConnectionContextExtensions
4733
{
4834
public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext(this Microsoft.AspNetCore.Connections.ConnectionContext connection) { throw null; }

src/SignalR/common/Http.Connections/src/ConnectionsAppBuilderExtensions.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/SignalR/common/Http.Connections/src/ConnectionsRouteBuilder.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/SignalR/common/Http.Connections/test/MapConnectionHandlerTests.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ public void MapConnectionHandlerFindsAttributesFromEndPointAndOptions()
150150
public void MapConnectionHandlerEndPointRoutingFindsAttributesOnHub()
151151
{
152152
var authCount = 0;
153-
using (var host = BuildWebHostWithEndPointRouting(routes => routes.MapConnectionHandler<AuthConnectionHandler>("/path", options =>
153+
using (var host = BuildWebHost<AuthConnectionHandler>("/path", options =>
154154
{
155155
authCount += options.AuthorizationData.Count;
156-
})))
156+
}))
157157
{
158158
host.Start();
159159

@@ -179,11 +179,11 @@ public void MapConnectionHandlerEndPointRoutingFindsAttributesOnHub()
179179
public void MapConnectionHandlerEndPointRoutingFindsAttributesFromOptions()
180180
{
181181
var authCount = 0;
182-
using (var host = BuildWebHostWithEndPointRouting(routes => routes.MapConnectionHandler<AuthConnectionHandler>("/path", options =>
182+
using (var host = BuildWebHost<AuthConnectionHandler>("/path", options =>
183183
{
184184
authCount += options.AuthorizationData.Count;
185185
options.AuthorizationData.Add(new AuthorizeAttribute());
186-
})))
186+
}))
187187
{
188188
host.Start();
189189

@@ -215,7 +215,7 @@ void ConfigureRoutes(IEndpointRouteBuilder endpoints)
215215
.RequireAuthorization(new AuthorizeAttribute("Foo"));
216216
}
217217

218-
using (var host = BuildWebHostWithEndPointRouting(ConfigureRoutes))
218+
using (var host = BuildWebHost(ConfigureRoutes))
219219
{
220220
host.Start();
221221

@@ -253,7 +253,7 @@ void ConfigureRoutes(IEndpointRouteBuilder endpoints)
253253
endpoints.MapConnectionHandler<AuthConnectionHandler>("/path");
254254
}
255255

256-
using (var host = BuildWebHostWithEndPointRouting(ConfigureRoutes))
256+
using (var host = BuildWebHost(ConfigureRoutes))
257257
{
258258
host.Start();
259259

@@ -281,7 +281,7 @@ void ConfigureRoutes(IEndpointRouteBuilder endpoints)
281281
endpoints.MapConnectionHandler<CorsConnectionHandler>("/path");
282282
}
283283

284-
using (var host = BuildWebHostWithEndPointRouting(ConfigureRoutes))
284+
using (var host = BuildWebHost(ConfigureRoutes))
285285
{
286286
host.Start();
287287

@@ -308,7 +308,7 @@ public async Task MapConnectionHandlerWithWebSocketSubProtocolSetsProtocol()
308308
var host = BuildWebHost<MyConnectionHandler>("/socket",
309309
options => options.WebSockets.SubProtocolSelector = subprotocols =>
310310
{
311-
Assert.Equal(new [] { "protocol1", "protocol2" }, subprotocols.ToArray());
311+
Assert.Equal(new[] { "protocol1", "protocol2" }, subprotocols.ToArray());
312312
return "protocol1";
313313
});
314314

@@ -377,7 +377,7 @@ public override Task OnConnectedAsync(ConnectionContext connection)
377377
}
378378
}
379379

380-
private IWebHost BuildWebHostWithEndPointRouting(Action<IEndpointRouteBuilder> configure)
380+
private IWebHost BuildWebHost(Action<IEndpointRouteBuilder> configure)
381381
{
382382
return new WebHostBuilder()
383383
.UseKestrel()
@@ -405,12 +405,11 @@ private IWebHost BuildWebHost<TConnectionHandler>(string path, Action<HttpConnec
405405
})
406406
.Configure(app =>
407407
{
408-
#pragma warning disable CS0618 // Type or member is obsolete
409-
app.UseConnections(routes =>
408+
app.UseRouting();
409+
app.UseEndpoints(routes =>
410410
{
411411
routes.MapConnectionHandler<TConnectionHandler>(path, configureOptions);
412412
});
413-
#pragma warning restore CS0618 // Type or member is obsolete
414413
})
415414
.ConfigureLogging(factory =>
416415
{

src/SignalR/server/SignalR/ref/Microsoft.AspNetCore.SignalR.netcoreapp.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ public static partial class HubEndpointRouteBuilderExtensions
1616
public partial interface IHubEndpointConventionBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder
1717
{
1818
}
19-
public static partial class SignalRAppBuilderExtensions
20-
{
21-
[System.ObsoleteAttribute("This method is obsolete and will be removed in a future version. The recommended alternative is to use MapHub<THub> inside Microsoft.AspNetCore.Builder.UseEndpoints(...).")]
22-
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseSignalR(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action<Microsoft.AspNetCore.SignalR.HubRouteBuilder> configure) { throw null; }
23-
}
2419
}
2520
namespace Microsoft.AspNetCore.SignalR
2621
{
@@ -29,13 +24,6 @@ public static partial class GetHttpContextExtensions
2924
public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext(this Microsoft.AspNetCore.SignalR.HubCallerContext connection) { throw null; }
3025
public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext(this Microsoft.AspNetCore.SignalR.HubConnectionContext connection) { throw null; }
3126
}
32-
[System.ObsoleteAttribute("This class is obsolete and will be removed in a future version. The recommended alternative is to use MapHub<THub> inside Microsoft.AspNetCore.Builder.UseEndpoints(...).")]
33-
public partial class HubRouteBuilder
34-
{
35-
public HubRouteBuilder(Microsoft.AspNetCore.Http.Connections.ConnectionsRouteBuilder routes) { }
36-
public void MapHub<THub>(Microsoft.AspNetCore.Http.PathString path) where THub : Microsoft.AspNetCore.SignalR.Hub { }
37-
public void MapHub<THub>(Microsoft.AspNetCore.Http.PathString path, System.Action<Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions> configureOptions) where THub : Microsoft.AspNetCore.SignalR.Hub { }
38-
}
3927
}
4028
namespace Microsoft.Extensions.DependencyInjection
4129
{

src/SignalR/server/SignalR/src/HubRouteBuilder.cs

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)