Skip to content

Fix #10756 by removing some previously-obsoleted SignalR methods #20015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
4 commits merged into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Analyzers/Analyzers/src/StartupFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public static bool IsSignalRConfigureMethodGesture(IMethodSymbol symbol)
throw new ArgumentNullException(nameof(symbol));
}

// UseSignalR has been removed in 5.0, but we should probably still check for it in this analyzer in case the user
// installs it into a pre-5.0 app.
if (string.Equals(symbol.Name, SymbolNames.SignalRAppBuilderExtensions.UseSignalRMethodName, StringComparison.Ordinal) ||
string.Equals(symbol.Name, SymbolNames.HubEndpointRouteBuilderExtensions.MapHubMethodName, StringComparison.Ordinal) ||
string.Equals(symbol.Name, SymbolNames.ComponentEndpointRouteBuilderExtensions.MapBlazorHubMethodName, StringComparison.Ordinal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public async Task DetectFeaturesAsync_FindsNoFeatures()
}

[Theory]
[InlineData(nameof(StartupWithUseSignalR))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a provision for building the analyzer tests against older runtimes, though it might be feasible with TFM pivots. Doesn't feel super necessary though.

[InlineData(nameof(StartupWithMapHub))]
[InlineData(nameof(StartupWithMapBlazorHub))]
public async Task DetectFeaturesAsync_FindsSignalR(string source)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ public static partial class ConnectionEndpointRouteBuilderExtensions
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; }
public static Microsoft.AspNetCore.Builder.ConnectionEndpointRouteBuilder MapConnections(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern, System.Action<Microsoft.AspNetCore.Connections.IConnectionBuilder> configure) { throw null; }
}
public static partial class ConnectionsAppBuilderExtensions
{
[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(...).")]
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseConnections(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action<Microsoft.AspNetCore.Http.Connections.ConnectionsRouteBuilder> configure) { throw null; }
}
}
namespace Microsoft.AspNetCore.Http.Connections
{
Expand All @@ -34,15 +29,6 @@ public partial class ConnectionOptionsSetup : Microsoft.Extensions.Options.IConf
public ConnectionOptionsSetup() { }
public void Configure(Microsoft.AspNetCore.Http.Connections.ConnectionOptions options) { }
}
[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(...).")]
public partial class ConnectionsRouteBuilder
{
internal ConnectionsRouteBuilder() { }
public void MapConnectionHandler<TConnectionHandler>(Microsoft.AspNetCore.Http.PathString path) where TConnectionHandler : Microsoft.AspNetCore.Connections.ConnectionHandler { }
public void MapConnectionHandler<TConnectionHandler>(Microsoft.AspNetCore.Http.PathString path, System.Action<Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions> configureOptions) where TConnectionHandler : Microsoft.AspNetCore.Connections.ConnectionHandler { }
public void MapConnections(Microsoft.AspNetCore.Http.PathString path, Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions options, System.Action<Microsoft.AspNetCore.Connections.IConnectionBuilder> configure) { }
public void MapConnections(Microsoft.AspNetCore.Http.PathString path, System.Action<Microsoft.AspNetCore.Connections.IConnectionBuilder> configure) { }
}
public static partial class HttpConnectionContextExtensions
{
public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext(this Microsoft.AspNetCore.Connections.ConnectionContext connection) { throw null; }
Expand Down

This file was deleted.

62 changes: 0 additions & 62 deletions src/SignalR/common/Http.Connections/src/ConnectionsRouteBuilder.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public void MapConnectionHandlerFindsAttributesFromEndPointAndOptions()
public void MapConnectionHandlerEndPointRoutingFindsAttributesOnHub()
{
var authCount = 0;
using (var host = BuildWebHostWithEndPointRouting(routes => routes.MapConnectionHandler<AuthConnectionHandler>("/path", options =>
using (var host = BuildWebHost<AuthConnectionHandler>("/path", options =>
{
authCount += options.AuthorizationData.Count;
})))
}))
{
host.Start();

Expand All @@ -179,11 +179,11 @@ public void MapConnectionHandlerEndPointRoutingFindsAttributesOnHub()
public void MapConnectionHandlerEndPointRoutingFindsAttributesFromOptions()
{
var authCount = 0;
using (var host = BuildWebHostWithEndPointRouting(routes => routes.MapConnectionHandler<AuthConnectionHandler>("/path", options =>
using (var host = BuildWebHost<AuthConnectionHandler>("/path", options =>
{
authCount += options.AuthorizationData.Count;
options.AuthorizationData.Add(new AuthorizeAttribute());
})))
}))
{
host.Start();

Expand Down Expand Up @@ -215,7 +215,7 @@ void ConfigureRoutes(IEndpointRouteBuilder endpoints)
.RequireAuthorization(new AuthorizeAttribute("Foo"));
}

using (var host = BuildWebHostWithEndPointRouting(ConfigureRoutes))
using (var host = BuildWebHost(ConfigureRoutes))
{
host.Start();

Expand Down Expand Up @@ -253,7 +253,7 @@ void ConfigureRoutes(IEndpointRouteBuilder endpoints)
endpoints.MapConnectionHandler<AuthConnectionHandler>("/path");
}

using (var host = BuildWebHostWithEndPointRouting(ConfigureRoutes))
using (var host = BuildWebHost(ConfigureRoutes))
{
host.Start();

Expand Down Expand Up @@ -281,7 +281,7 @@ void ConfigureRoutes(IEndpointRouteBuilder endpoints)
endpoints.MapConnectionHandler<CorsConnectionHandler>("/path");
}

using (var host = BuildWebHostWithEndPointRouting(ConfigureRoutes))
using (var host = BuildWebHost(ConfigureRoutes))
{
host.Start();

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

Expand Down Expand Up @@ -377,7 +377,7 @@ public override Task OnConnectedAsync(ConnectionContext connection)
}
}

private IWebHost BuildWebHostWithEndPointRouting(Action<IEndpointRouteBuilder> configure)
private IWebHost BuildWebHost(Action<IEndpointRouteBuilder> configure)
{
return new WebHostBuilder()
.UseKestrel()
Expand Down Expand Up @@ -405,12 +405,11 @@ private IWebHost BuildWebHost<TConnectionHandler>(string path, Action<HttpConnec
})
.Configure(app =>
{
#pragma warning disable CS0618 // Type or member is obsolete
app.UseConnections(routes =>
app.UseRouting();
app.UseEndpoints(routes =>
{
routes.MapConnectionHandler<TConnectionHandler>(path, configureOptions);
});
#pragma warning restore CS0618 // Type or member is obsolete
})
.ConfigureLogging(factory =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ public static partial class HubEndpointRouteBuilderExtensions
public partial interface IHubEndpointConventionBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder
{
}
public static partial class SignalRAppBuilderExtensions
{
[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(...).")]
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseSignalR(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action<Microsoft.AspNetCore.SignalR.HubRouteBuilder> configure) { throw null; }
}
}
namespace Microsoft.AspNetCore.SignalR
{
Expand All @@ -29,13 +24,6 @@ public static partial class GetHttpContextExtensions
public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext(this Microsoft.AspNetCore.SignalR.HubCallerContext connection) { throw null; }
public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext(this Microsoft.AspNetCore.SignalR.HubConnectionContext connection) { throw null; }
}
[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(...).")]
public partial class HubRouteBuilder
{
public HubRouteBuilder(Microsoft.AspNetCore.Http.Connections.ConnectionsRouteBuilder routes) { }
public void MapHub<THub>(Microsoft.AspNetCore.Http.PathString path) where THub : Microsoft.AspNetCore.SignalR.Hub { }
public void MapHub<THub>(Microsoft.AspNetCore.Http.PathString path, System.Action<Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions> configureOptions) where THub : Microsoft.AspNetCore.SignalR.Hub { }
}
}
namespace Microsoft.Extensions.DependencyInjection
{
Expand Down
82 changes: 0 additions & 82 deletions src/SignalR/server/SignalR/src/HubRouteBuilder.cs

This file was deleted.

Loading