From 93634cd7721ac675830157b6583bbc27d3d6ee50 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 7 Jul 2020 14:46:50 -0700 Subject: [PATCH] Follow ups for nullable (#23736) * Follow ups for nullable * Update src/Http/Routing/src/Matching/DfaMatcherBuilder.cs Co-authored-by: James Newton-King Co-authored-by: James Newton-King --- src/Http/Routing/src/Matching/DfaMatcherBuilder.cs | 8 +++++--- .../Core/src/AuthorizationServiceCollectionExtensions.cs | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs b/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs index 628adf4b74..2782f8a3ae 100644 --- a/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs +++ b/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs @@ -247,7 +247,9 @@ namespace Microsoft.AspNetCore.Routing.Matching } } - AddLiteralNode(includeLabel, nextParents, parent, requiredValue.ToString()); + var literalValue = requiredValue?.ToString() ?? throw new InvalidOperationException($"Required value for literal '{parameterPart.Name}' must evaluate to a non-null string."); + + AddLiteralNode(includeLabel, nextParents, parent, literalValue); } else if (segment.IsSimple && parameterPart != null) { @@ -353,7 +355,7 @@ namespace Microsoft.AspNetCore.Routing.Matching if (segment is null) { // Treat "no segment" as high priority. it won't effect the algorithm, but we need to define a sort-order. - return 0; + return 0; } return RoutePrecedence.ComputeInboundPrecedenceDigit(endpoint.RoutePattern, segment); @@ -741,7 +743,7 @@ namespace Microsoft.AspNetCore.Routing.Matching { var nodeBuilder = _nodeBuilders[i]; - // Build a list of each + // Build a list of each List nextWork; if (previousWork == null) { diff --git a/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs b/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs index 47c6b98ba6..12af1b0c8d 100644 --- a/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs +++ b/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs @@ -51,6 +51,11 @@ namespace Microsoft.Extensions.DependencyInjection throw new ArgumentNullException(nameof(services)); } + if (configure == null) + { + throw new ArgumentNullException(nameof(configure)); + } + services.Configure(configure); return services.AddAuthorizationCore(); }