-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Turn on nullability for Routing #24238
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
Conversation
ca88610
to
072ddaa
Compare
@@ -14,7 +14,7 @@ public class BoolRouteConstraint : IRouteConstraint | |||
{ | |||
/// <inheritdoc /> | |||
public bool Match( | |||
HttpContext httpContext, | |||
HttpContext? httpContext, | |||
IRouter route, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can route and routeKey be null? I would have thought endpoint routing would pass a null route (or maybe it is a dummy one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IRouter could be null, but routeKey is required by all of the built-in constraints.
@@ -90,11 +90,11 @@ public LengthRouteConstraint(int minLength, int maxLength) | |||
if (values.TryGetValue(routeKey, out var value) && value != null) | |||
{ | |||
var valueString = Convert.ToString(value, CultureInfo.InvariantCulture); | |||
var length = valueString.Length; | |||
var length = valueString!.Length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: put the ! on Convert.ToString
src/Http/Routing/src/LinkGeneratorRouteValuesAddressExtensions.cs
Outdated
Show resolved
Hide resolved
{ | ||
// Friendliness for inlining | ||
if ((uint)index >= Count) | ||
{ | ||
ThrowIndexArgumentOutOfRangeException(); | ||
} | ||
|
||
Candidates[index] = new CandidateState(endpoint, values, Candidates[index].Score); | ||
Candidates[index] = new CandidateState(endpoint!, values, Candidates[index].Score); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReplaceEndpoint has Endpoint? endpoint
then CandidateState requires it not be null. Which is true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated CandidateSet
f2f0c59
to
d10a6ee
Compare
d10a6ee
to
fab7ed7
Compare
We previously only had annotations enabled which resulted in incorrect nullability. This change enables nullability. Fixes #24042
fab7ed7
to
cf03192
Compare
We previously only had annotations enabled which resulted in incorrect nullability. This change enables
nullability.
Fixes #24042