Follow ups for nullable (#23736)

* Follow ups for nullable

* Update src/Http/Routing/src/Matching/DfaMatcherBuilder.cs

Co-authored-by: James Newton-King <james@newtonking.com>

Co-authored-by: James Newton-King <james@newtonking.com>
This commit is contained in:
Pranav K 2020-07-07 14:46:50 -07:00 committed by GitHub
parent 380a5679bb
commit 93634cd772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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<DfaNode> nextWork;
if (previousWork == null)
{

View File

@ -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();
}