diff --git a/build/sources.props b/build/sources.props
index 32de0e191a..51b729797d 100644
--- a/build/sources.props
+++ b/build/sources.props
@@ -14,6 +14,7 @@
https://dotnetfeed.blob.core.windows.net/aspnet-entityframeworkcore/index.json;
https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore-tooling/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
+ https://grpc.jfrog.io/grpc/api/nuget/v3/grpc-nuget-dev;
https://api.nuget.org/v3/index.json;
diff --git a/eng/Versions.props b/eng/Versions.props
index 5fa546f41c..8c81acc1b9 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -175,7 +175,7 @@
4.2.1
4.2.1
3.7.0
- 0.1.20-pre1
+ 0.1.21-dev201905010701
1.20.0-pre3
3.0.0-preview3.4
3.0.0-preview3.4
diff --git a/src/Components/Server/ref/Microsoft.AspNetCore.Components.Server.netcoreapp3.0.cs b/src/Components/Server/ref/Microsoft.AspNetCore.Components.Server.netcoreapp3.0.cs
index ae723ee3cc..17c98463a6 100644
--- a/src/Components/Server/ref/Microsoft.AspNetCore.Components.Server.netcoreapp3.0.cs
+++ b/src/Components/Server/ref/Microsoft.AspNetCore.Components.Server.netcoreapp3.0.cs
@@ -5,15 +5,14 @@ namespace Microsoft.AspNetCore.Builder
{
public static partial class ComponentEndpointConventionBuilderExtensions
{
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder AddComponent(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, System.Type componentType, string selector) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder AddComponent(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, string selector) { throw null; }
+ public static TBuilder AddComponent(this TBuilder builder, System.Type componentType, string selector) where TBuilder : Microsoft.AspNetCore.SignalR.IHubEndpointConventionBuilder { throw null; }
}
public static partial class ComponentEndpointRouteBuilderExtensions
{
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, System.Type componentType, string selector, string path) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string selector) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string selector, string path) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
+ public static Microsoft.AspNetCore.Components.Server.ComponentEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints) { throw null; }
+ public static Microsoft.AspNetCore.Components.Server.ComponentEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, System.Type componentType, string selector, string path) { throw null; }
+ public static Microsoft.AspNetCore.Components.Server.ComponentEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string selector) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
+ public static Microsoft.AspNetCore.Components.Server.ComponentEndpointConventionBuilder MapBlazorHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string selector, string path) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
}
}
namespace Microsoft.AspNetCore.Components.Browser.Rendering
@@ -31,6 +30,11 @@ namespace Microsoft.AspNetCore.Components.Server
public System.TimeSpan DisconnectedCircuitRetentionPeriod { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public int MaxRetainedDisconnectedCircuits { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
+ public sealed partial class ComponentEndpointConventionBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder, Microsoft.AspNetCore.SignalR.IHubEndpointConventionBuilder
+ {
+ internal ComponentEndpointConventionBuilder() { }
+ public void Add(System.Action convention) { }
+ }
public sealed partial class ComponentHub : Microsoft.AspNetCore.SignalR.Hub
{
public ComponentHub(System.IServiceProvider services, Microsoft.Extensions.Logging.ILogger logger) { }
diff --git a/src/Components/Server/src/Builder/ComponentEndpointConventionBuilder.cs b/src/Components/Server/src/Builder/ComponentEndpointConventionBuilder.cs
new file mode 100644
index 0000000000..284d9fd004
--- /dev/null
+++ b/src/Components/Server/src/Builder/ComponentEndpointConventionBuilder.cs
@@ -0,0 +1,31 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.SignalR;
+
+namespace Microsoft.AspNetCore.Components.Server
+{
+ ///
+ /// Builds conventions that will be used for customization of ComponentHub instances.
+ ///
+ public sealed class ComponentEndpointConventionBuilder : IHubEndpointConventionBuilder
+ {
+ private readonly IEndpointConventionBuilder _endpointConventionBuilder;
+
+ internal ComponentEndpointConventionBuilder(IEndpointConventionBuilder endpointConventionBuilder)
+ {
+ _endpointConventionBuilder = endpointConventionBuilder;
+ }
+
+ ///
+ /// Adds the specified convention to the builder. Conventions are used to customize instances.
+ ///
+ /// The convention to add to the builder.
+ public void Add(Action convention)
+ {
+ _endpointConventionBuilder.Add(convention);
+ }
+ }
+}
diff --git a/src/Components/Server/src/Builder/ComponentEndpointConventionBuilderExtensions.cs b/src/Components/Server/src/Builder/ComponentEndpointConventionBuilderExtensions.cs
index 058a6ea945..f44577bb2c 100644
--- a/src/Components/Server/src/Builder/ComponentEndpointConventionBuilderExtensions.cs
+++ b/src/Components/Server/src/Builder/ComponentEndpointConventionBuilderExtensions.cs
@@ -4,45 +4,24 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Components.Server;
+using Microsoft.AspNetCore.SignalR;
namespace Microsoft.AspNetCore.Builder
{
///
- /// Extensions for .
+ /// Extensions for .
///
public static class ComponentEndpointConventionBuilderExtensions
{
- ///
- /// Adds to the list of components registered with this instance.
- ///
- /// The component type.
- /// The .
- /// A CSS selector that identifies the DOM element into which the will be placed.
- /// The .
- public static IEndpointConventionBuilder AddComponent(this IEndpointConventionBuilder builder, string selector)
- {
- if (builder == null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
-
- if (selector == null)
- {
- throw new ArgumentNullException(nameof(selector));
- }
-
- return AddComponent(builder, typeof(TComponent), selector);
- }
-
///
/// Adds to the list of components registered with this instance.
/// The selector will default to the component name in lowercase.
///
- /// The .
+ /// The .
/// The component type.
/// The component selector in the DOM for the .
/// The .
- public static IEndpointConventionBuilder AddComponent(this IEndpointConventionBuilder builder, Type componentType, string selector)
+ public static TBuilder AddComponent(this TBuilder builder, Type componentType, string selector) where TBuilder : IHubEndpointConventionBuilder
{
if (builder == null)
{
diff --git a/src/Components/Server/src/Builder/ComponentEndpointRouteBuilderExtensions.cs b/src/Components/Server/src/Builder/ComponentEndpointRouteBuilderExtensions.cs
index dc893a1c3b..f2674d8bcf 100644
--- a/src/Components/Server/src/Builder/ComponentEndpointRouteBuilderExtensions.cs
+++ b/src/Components/Server/src/Builder/ComponentEndpointRouteBuilderExtensions.cs
@@ -5,6 +5,7 @@ using System;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Routing;
+using Microsoft.AspNetCore.SignalR;
namespace Microsoft.AspNetCore.Builder
{
@@ -17,15 +18,15 @@ namespace Microsoft.AspNetCore.Builder
/// Maps the SignalR to the path .
///
/// The .
- /// The .
- public static IEndpointConventionBuilder MapBlazorHub(this IEndpointRouteBuilder endpoints)
+ /// The .
+ public static ComponentEndpointConventionBuilder MapBlazorHub(this IEndpointRouteBuilder endpoints)
{
if (endpoints == null)
{
throw new ArgumentNullException(nameof(endpoints));
}
- return endpoints.MapHub(ComponentHub.DefaultPath);
+ return new ComponentEndpointConventionBuilder(endpoints.MapHub(ComponentHub.DefaultPath));
}
///
@@ -35,8 +36,8 @@ namespace Microsoft.AspNetCore.Builder
/// The first associated with this .
/// The .
/// The selector for the .
- /// The .
- public static IEndpointConventionBuilder MapBlazorHub(
+ /// The .
+ public static ComponentEndpointConventionBuilder MapBlazorHub(
this IEndpointRouteBuilder endpoints,
string selector) where TComponent: IComponent
{
@@ -61,8 +62,8 @@ namespace Microsoft.AspNetCore.Builder
/// The .
/// The selector for the .
/// The path to map to which the will be mapped.
- /// The .
- public static IEndpointConventionBuilder MapBlazorHub(
+ /// The .
+ public static ComponentEndpointConventionBuilder MapBlazorHub(
this IEndpointRouteBuilder endpoints,
string selector,
string path) where TComponent : IComponent
@@ -93,8 +94,8 @@ namespace Microsoft.AspNetCore.Builder
/// The first associated with this .
/// The selector for the .
/// The path to map to which the will be mapped.
- /// The .
- public static IEndpointConventionBuilder MapBlazorHub(
+ /// The .
+ public static ComponentEndpointConventionBuilder MapBlazorHub(
this IEndpointRouteBuilder endpoints,
Type componentType,
string selector,
@@ -120,7 +121,7 @@ namespace Microsoft.AspNetCore.Builder
throw new ArgumentNullException(nameof(selector));
}
- return endpoints.MapHub(path).AddComponent(componentType, selector);
+ return new ComponentEndpointConventionBuilder(endpoints.MapHub(path)).AddComponent(componentType, selector);
}
}
}
diff --git a/src/Components/test/testassets/TestServer/Startup.cs b/src/Components/test/testassets/TestServer/Startup.cs
index 7d6d635d69..1e06fad17e 100644
--- a/src/Components/test/testassets/TestServer/Startup.cs
+++ b/src/Components/test/testassets/TestServer/Startup.cs
@@ -65,7 +65,7 @@ namespace TestServer
subdirApp.UseEndpoints(endpoints =>
{
- endpoints.MapHub(ComponentHub.DefaultPath).AddComponent(selector: "root");
+ endpoints.MapHub(ComponentHub.DefaultPath).AddComponent(typeof(Index), selector: "root");
});
subdirApp.MapWhen(
diff --git a/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.netcoreapp3.0.cs b/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.netcoreapp3.0.cs
index 0b1214a615..6dfc8a79c8 100644
--- a/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.netcoreapp3.0.cs
+++ b/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.netcoreapp3.0.cs
@@ -44,10 +44,10 @@ namespace Microsoft.AspNetCore.Builder
}
public static partial class RoutingEndpointConventionBuilderExtensions
{
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireHost(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params string[] hosts) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder WithDisplayName(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, System.Func func) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder WithDisplayName(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, string displayName) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder WithMetadata(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params object[] items) { throw null; }
+ public static TBuilder RequireHost(this TBuilder builder, params string[] hosts) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
+ public static TBuilder WithDisplayName(this TBuilder builder, System.Func func) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
+ public static TBuilder WithDisplayName(this TBuilder builder, string displayName) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
+ public static TBuilder WithMetadata(this TBuilder builder, params object[] items) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
}
}
namespace Microsoft.AspNetCore.Routing
diff --git a/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs b/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs
index fbc9589bd8..409c83c832 100644
--- a/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs
+++ b/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs
@@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Builder
/// An empty collection means any host will be accepted.
///
/// A reference to this instance after the operation has completed.
- public static IEndpointConventionBuilder RequireHost(this IEndpointConventionBuilder builder, params string[] hosts)
+ public static TBuilder RequireHost(this TBuilder builder, params string[] hosts) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
@@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Builder
/// The .
/// The display name.
/// The .
- public static IEndpointConventionBuilder WithDisplayName(this IEndpointConventionBuilder builder, string displayName)
+ public static TBuilder WithDisplayName(this TBuilder builder, string displayName) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
@@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Builder
/// The .
/// A delegate that produces the display name for each .
/// The .
- public static IEndpointConventionBuilder WithDisplayName(this IEndpointConventionBuilder builder, Func func)
+ public static TBuilder WithDisplayName(this TBuilder builder, Func func) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
@@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Builder
/// The .
/// A collection of metadata items.
/// The .
- public static IEndpointConventionBuilder WithMetadata(this IEndpointConventionBuilder builder, params object[] items)
+ public static TBuilder WithMetadata(this TBuilder builder, params object[] items) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
diff --git a/src/Http/Routing/test/UnitTests/Builder/RoutingEndpointConventionBuilderExtensionsTest.cs b/src/Http/Routing/test/UnitTests/Builder/RoutingEndpointConventionBuilderExtensionsTest.cs
index ce7f9d2b3e..e2957e5470 100644
--- a/src/Http/Routing/test/UnitTests/Builder/RoutingEndpointConventionBuilderExtensionsTest.cs
+++ b/src/Http/Routing/test/UnitTests/Builder/RoutingEndpointConventionBuilderExtensionsTest.cs
@@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Patterns;
using Xunit;
@@ -26,6 +28,19 @@ namespace Microsoft.AspNetCore.Builder
Assert.Equal(new[] { "www.example.com", "example.com" }, metadata.Hosts);
}
+ [Fact]
+ public void RequireHost_ChainedCall_ReturnedBuilderIsDerivedType()
+ {
+ // Arrange
+ var builder = CreateBuilder();
+
+ // Act
+ var chainedBuilder = builder.RequireHost("test");
+
+ // Assert
+ Assert.True(chainedBuilder.TestProperty);
+ }
+
[Fact]
public void WithDisplayName_String_SetsDisplayName()
{
@@ -40,6 +55,19 @@ namespace Microsoft.AspNetCore.Builder
Assert.Equal("test", endpoint.DisplayName);
}
+ [Fact]
+ public void WithDisplayName_ChainedCall_ReturnedBuilderIsDerivedType()
+ {
+ // Arrange
+ var builder = CreateBuilder();
+
+ // Act
+ var chainedBuilder = builder.WithDisplayName("test");
+
+ // Assert
+ Assert.True(chainedBuilder.TestProperty);
+ }
+
[Fact]
public void WithDisplayName_Func_SetsDisplayName()
{
@@ -74,12 +102,48 @@ namespace Microsoft.AspNetCore.Builder
Assert.Equal("test", @string);
}
- private DefaultEndpointConventionBuilder CreateBuilder()
+ [Fact]
+ public void WithMetadata_ChainedCall_ReturnedBuilderIsDerivedType()
{
- return new DefaultEndpointConventionBuilder(new RouteEndpointBuilder(
+ // Arrange
+ var builder = CreateBuilder();
+
+ // Act
+ var chainedBuilder = builder.WithMetadata("test");
+
+ // Assert
+ Assert.True(chainedBuilder.TestProperty);
+ }
+
+ private TestEndpointConventionBuilder CreateBuilder()
+ {
+ var conventionBuilder = new DefaultEndpointConventionBuilder(new RouteEndpointBuilder(
TestConstants.EmptyRequestDelegate,
RoutePatternFactory.Parse("/test"),
order: 0));
+
+ return new TestEndpointConventionBuilder(conventionBuilder);
+ }
+
+ private class TestEndpointConventionBuilder : IEndpointConventionBuilder
+ {
+ private DefaultEndpointConventionBuilder _endpointConventionBuilder;
+ public bool TestProperty { get; } = true;
+
+ public TestEndpointConventionBuilder(DefaultEndpointConventionBuilder endpointConventionBuilder)
+ {
+ _endpointConventionBuilder = endpointConventionBuilder;
+ }
+
+ public void Add(Action convention)
+ {
+ _endpointConventionBuilder.Add(convention);
+ }
+
+ public Endpoint Build()
+ {
+ return _endpointConventionBuilder.Build();
+ }
}
}
}
diff --git a/src/Middleware/CORS/ref/Microsoft.AspNetCore.Cors.netcoreapp3.0.cs b/src/Middleware/CORS/ref/Microsoft.AspNetCore.Cors.netcoreapp3.0.cs
index 4072d5f068..f000293212 100644
--- a/src/Middleware/CORS/ref/Microsoft.AspNetCore.Cors.netcoreapp3.0.cs
+++ b/src/Middleware/CORS/ref/Microsoft.AspNetCore.Cors.netcoreapp3.0.cs
@@ -5,8 +5,8 @@ namespace Microsoft.AspNetCore.Builder
{
public static partial class CorsEndpointConventionBuilderExtensions
{
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder WithCorsPolicy(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, System.Action configurePolicy) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder WithCorsPolicy(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, string policyName) { throw null; }
+ public static TBuilder WithCorsPolicy(this TBuilder builder, System.Action configurePolicy) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
+ public static TBuilder WithCorsPolicy(this TBuilder builder, string policyName) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
}
public static partial class CorsMiddlewareExtensions
{
diff --git a/src/Middleware/CORS/src/Infrastructure/CorsEndpointConventionBuilderExtensions.cs b/src/Middleware/CORS/src/Infrastructure/CorsEndpointConventionBuilderExtensions.cs
index 84c4021956..1b82f90dfa 100644
--- a/src/Middleware/CORS/src/Infrastructure/CorsEndpointConventionBuilderExtensions.cs
+++ b/src/Middleware/CORS/src/Infrastructure/CorsEndpointConventionBuilderExtensions.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Builder
/// The endpoint convention builder.
/// The CORS policy name.
/// The original convention builder parameter.
- public static IEndpointConventionBuilder WithCorsPolicy(this IEndpointConventionBuilder builder, string policyName)
+ public static TBuilder WithCorsPolicy(this TBuilder builder, string policyName) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
@@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Builder
/// The endpoint convention builder.
/// A delegate which can use a policy builder to build a policy.
/// The original convention builder parameter.
- public static IEndpointConventionBuilder WithCorsPolicy(this IEndpointConventionBuilder builder, Action configurePolicy)
+ public static TBuilder WithCorsPolicy(this TBuilder builder, Action configurePolicy) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
diff --git a/src/Middleware/CORS/test/UnitTests/CorsEndpointConventionBuilderExtensionsTests.cs b/src/Middleware/CORS/test/UnitTests/CorsEndpointConventionBuilderExtensionsTests.cs
index 490a1d3644..6b1ce451d0 100644
--- a/src/Middleware/CORS/test/UnitTests/CorsEndpointConventionBuilderExtensionsTests.cs
+++ b/src/Middleware/CORS/test/UnitTests/CorsEndpointConventionBuilderExtensionsTests.cs
@@ -55,6 +55,19 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
Assert.True(metadata.Policy.AllowAnyOrigin);
}
+ [Fact]
+ public void WithCorsPolicy_ChainedCall_ReturnedBuilderIsDerivedType()
+ {
+ // Arrange
+ var testConventionBuilder = new TestEndpointConventionBuilder();
+
+ // Act
+ var builder = testConventionBuilder.WithCorsPolicy("TestPolicyName");
+
+ // Assert
+ Assert.True(builder.TestProperty);
+ }
+
private class TestEndpointBuilder : EndpointBuilder
{
public override Endpoint Build()
@@ -66,6 +79,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
private class TestEndpointConventionBuilder : IEndpointConventionBuilder
{
public IList> Conventions { get; } = new List>();
+ public bool TestProperty { get; } = true;
public void Add(Action convention)
{
diff --git a/src/Security/Authorization/Core/ref/Microsoft.AspNetCore.Authorization.netcoreapp3.0.cs b/src/Security/Authorization/Core/ref/Microsoft.AspNetCore.Authorization.netcoreapp3.0.cs
index c80ea08c14..30c87d87b8 100644
--- a/src/Security/Authorization/Core/ref/Microsoft.AspNetCore.Authorization.netcoreapp3.0.cs
+++ b/src/Security/Authorization/Core/ref/Microsoft.AspNetCore.Authorization.netcoreapp3.0.cs
@@ -250,9 +250,9 @@ namespace Microsoft.AspNetCore.Builder
}
public static partial class AuthorizationEndpointConventionBuilderExtensions
{
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params Microsoft.AspNetCore.Authorization.IAuthorizeData[] authorizeData) { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder RequireAuthorization(this Microsoft.AspNetCore.Builder.IEndpointConventionBuilder builder, params string[] policyNames) { throw null; }
+ public static TBuilder RequireAuthorization(this TBuilder builder) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
+ public static TBuilder RequireAuthorization(this TBuilder builder, params Microsoft.AspNetCore.Authorization.IAuthorizeData[] authorizeData) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
+ public static TBuilder RequireAuthorization(this TBuilder builder, params string[] policyNames) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder { throw null; }
}
}
namespace Microsoft.Extensions.DependencyInjection
diff --git a/src/Security/Authorization/Core/src/Policy/AuthorizationEndpointConventionBuilderExtensions.cs b/src/Security/Authorization/Core/src/Policy/AuthorizationEndpointConventionBuilderExtensions.cs
index 316c45012b..cefb534c55 100644
--- a/src/Security/Authorization/Core/src/Policy/AuthorizationEndpointConventionBuilderExtensions.cs
+++ b/src/Security/Authorization/Core/src/Policy/AuthorizationEndpointConventionBuilderExtensions.cs
@@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Builder
/// The endpoint convention builder.
/// A collection of .
/// The original convention builder parameter.
- public static IEndpointConventionBuilder RequireAuthorization(this IEndpointConventionBuilder builder, params IAuthorizeData[] authorizeData)
+ public static TBuilder RequireAuthorization(this TBuilder builder, params IAuthorizeData[] authorizeData) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
@@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Builder
/// The endpoint convention builder.
/// A collection of policy names.
/// The original convention builder parameter.
- public static IEndpointConventionBuilder RequireAuthorization(this IEndpointConventionBuilder builder, params string[] policyNames)
+ public static TBuilder RequireAuthorization(this TBuilder builder, params string[] policyNames) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
@@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Builder
///
/// The endpoint convention builder.
/// The original convention builder parameter.
- public static IEndpointConventionBuilder RequireAuthorization(this IEndpointConventionBuilder builder)
+ public static TBuilder RequireAuthorization(this TBuilder builder) where TBuilder : IEndpointConventionBuilder
{
if (builder == null)
{
diff --git a/src/Security/Authorization/test/AuthorizationEndpointConventionBuilderExtensionsTests.cs b/src/Security/Authorization/test/AuthorizationEndpointConventionBuilderExtensionsTests.cs
index 7a01f88ae6..f535bf7e69 100644
--- a/src/Security/Authorization/test/AuthorizationEndpointConventionBuilderExtensionsTests.cs
+++ b/src/Security/Authorization/test/AuthorizationEndpointConventionBuilderExtensionsTests.cs
@@ -70,9 +70,23 @@ namespace Microsoft.AspNetCore.Authorization.Test
Assert.Null(authMetadata.Policy);
}
+ [Fact]
+ public void RequireAuthorization_ChainedCall()
+ {
+ // Arrange
+ var builder = new TestEndpointConventionBuilder();
+
+ // Act
+ var chainedBuilder = builder.RequireAuthorization();
+
+ // Assert
+ Assert.True(chainedBuilder.TestProperty);
+ }
+
private class TestEndpointConventionBuilder : IEndpointConventionBuilder
{
public IList> Conventions { get; } = new List>();
+ public bool TestProperty { get; } = true;
public void Add(Action convention)
{
diff --git a/src/SignalR/server/SignalR/ref/Microsoft.AspNetCore.SignalR.netcoreapp3.0.cs b/src/SignalR/server/SignalR/ref/Microsoft.AspNetCore.SignalR.netcoreapp3.0.cs
index f2504a0e22..27663babcc 100644
--- a/src/SignalR/server/SignalR/ref/Microsoft.AspNetCore.SignalR.netcoreapp3.0.cs
+++ b/src/SignalR/server/SignalR/ref/Microsoft.AspNetCore.SignalR.netcoreapp3.0.cs
@@ -5,8 +5,8 @@ namespace Microsoft.AspNetCore.Builder
{
public static partial class HubEndpointRouteBuilderExtensions
{
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern) where THub : Microsoft.AspNetCore.SignalR.Hub { throw null; }
- public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern, System.Action configureOptions) where THub : Microsoft.AspNetCore.SignalR.Hub { throw null; }
+ public static Microsoft.AspNetCore.SignalR.HubEndpointConventionBuilder MapHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern) where THub : Microsoft.AspNetCore.SignalR.Hub { throw null; }
+ public static Microsoft.AspNetCore.SignalR.HubEndpointConventionBuilder MapHub(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern, System.Action configureOptions) where THub : Microsoft.AspNetCore.SignalR.Hub { throw null; }
}
public static partial class SignalRAppBuilderExtensions
{
@@ -20,12 +20,20 @@ namespace Microsoft.AspNetCore.SignalR
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; }
}
+ public sealed partial class HubEndpointConventionBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder, Microsoft.AspNetCore.SignalR.IHubEndpointConventionBuilder
+ {
+ internal HubEndpointConventionBuilder() { }
+ public void Add(System.Action convention) { }
+ }
public partial class HubRouteBuilder
{
public HubRouteBuilder(Microsoft.AspNetCore.Http.Connections.ConnectionsRouteBuilder routes) { }
public void MapHub(Microsoft.AspNetCore.Http.PathString path) where THub : Microsoft.AspNetCore.SignalR.Hub { }
public void MapHub(Microsoft.AspNetCore.Http.PathString path, System.Action configureOptions) where THub : Microsoft.AspNetCore.SignalR.Hub { }
}
+ public partial interface IHubEndpointConventionBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder
+ {
+ }
}
namespace Microsoft.Extensions.DependencyInjection
{
diff --git a/src/SignalR/server/SignalR/src/HubEndpointConventionBuilder.cs b/src/SignalR/server/SignalR/src/HubEndpointConventionBuilder.cs
new file mode 100644
index 0000000000..fc2cd2cca0
--- /dev/null
+++ b/src/SignalR/server/SignalR/src/HubEndpointConventionBuilder.cs
@@ -0,0 +1,30 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.AspNetCore.Builder;
+
+namespace Microsoft.AspNetCore.SignalR
+{
+ ///
+ /// Builds conventions that will be used for customization of Hub instances.
+ ///
+ public sealed class HubEndpointConventionBuilder : IHubEndpointConventionBuilder
+ {
+ private readonly IEndpointConventionBuilder _endpointConventionBuilder;
+
+ internal HubEndpointConventionBuilder(IEndpointConventionBuilder endpointConventionBuilder)
+ {
+ _endpointConventionBuilder = endpointConventionBuilder;
+ }
+
+ ///
+ /// Adds the specified convention to the builder. Conventions are used to customize instances.
+ ///
+ /// The convention to add to the builder.
+ public void Add(Action convention)
+ {
+ _endpointConventionBuilder.Add(convention);
+ }
+ }
+}
diff --git a/src/SignalR/server/SignalR/src/HubEndpointRouteBuilderExtensions.cs b/src/SignalR/server/SignalR/src/HubEndpointRouteBuilderExtensions.cs
index 42414b791a..f53632d00f 100644
--- a/src/SignalR/server/SignalR/src/HubEndpointRouteBuilderExtensions.cs
+++ b/src/SignalR/server/SignalR/src/HubEndpointRouteBuilderExtensions.cs
@@ -19,8 +19,8 @@ namespace Microsoft.AspNetCore.Builder
/// The type to map requests to.
/// The to add the route to.
/// The route pattern.
- /// An for endpoints associated with the connections.
- public static IEndpointConventionBuilder MapHub(this IEndpointRouteBuilder endpoints, string pattern) where THub : Hub
+ /// An for endpoints associated with the connections.
+ public static HubEndpointConventionBuilder MapHub(this IEndpointRouteBuilder endpoints, string pattern) where THub : Hub
{
return endpoints.MapHub(pattern, configureOptions: null);
}
@@ -32,8 +32,8 @@ namespace Microsoft.AspNetCore.Builder
/// The to add the route to.
/// The route pattern.
/// A callback to configure dispatcher options.
- /// An for endpoints associated with the connections.
- public static IEndpointConventionBuilder MapHub(this IEndpointRouteBuilder endpoints, string pattern, Action configureOptions) where THub : Hub
+ /// An for endpoints associated with the connections.
+ public static HubEndpointConventionBuilder MapHub(this IEndpointRouteBuilder endpoints, string pattern, Action configureOptions) where THub : Hub
{
var marker = endpoints.ServiceProvider.GetService();
@@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Builder
e.Metadata.Add(new HubMetadata(typeof(THub)));
});
- return conventionBuilder;
+ return new HubEndpointConventionBuilder(conventionBuilder);
}
}
}
diff --git a/src/SignalR/server/SignalR/src/IHubEndpointConventionBuilder.cs b/src/SignalR/server/SignalR/src/IHubEndpointConventionBuilder.cs
new file mode 100644
index 0000000000..141311ccd2
--- /dev/null
+++ b/src/SignalR/server/SignalR/src/IHubEndpointConventionBuilder.cs
@@ -0,0 +1,15 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Microsoft.AspNetCore.Builder;
+
+namespace Microsoft.AspNetCore.SignalR
+{
+ ///
+ /// Abstraction that builds conventions that will be used for customization of Hub instances.
+ ///
+ public interface IHubEndpointConventionBuilder : IEndpointConventionBuilder
+ {
+
+ }
+}
diff --git a/src/SignalR/server/SignalR/src/Microsoft.AspNetCore.SignalR.csproj b/src/SignalR/server/SignalR/src/Microsoft.AspNetCore.SignalR.csproj
index cb71376f89..7614e387f4 100644
--- a/src/SignalR/server/SignalR/src/Microsoft.AspNetCore.SignalR.csproj
+++ b/src/SignalR/server/SignalR/src/Microsoft.AspNetCore.SignalR.csproj
@@ -1,4 +1,4 @@
-
+
Components for providing real-time bi-directional communication across the Web.
netcoreapp3.0