Skip to content

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

Merged
merged 2 commits into from
Jul 25, 2020
Merged

Turn on nullability for Routing #24238

merged 2 commits into from
Jul 25, 2020

Conversation

pranavkm
Copy link
Contributor

We previously only had annotations enabled which resulted in incorrect nullability. This change enables
nullability.

Fixes #24042

@ghost ghost added the area-servers label Jul 23, 2020
@pranavkm pranavkm requested a review from JamesNK July 23, 2020 15:54
@pranavkm pranavkm force-pushed the prkrishn/fix-nullability branch 2 times, most recently from ca88610 to 072ddaa Compare July 23, 2020 18:15
@pranavkm pranavkm added this to the 5.0.0-preview8 milestone Jul 23, 2020
@@ -14,7 +14,7 @@ public class BoolRouteConstraint : IRouteConstraint
{
/// <inheritdoc />
public bool Match(
HttpContext httpContext,
HttpContext? httpContext,
IRouter route,
Copy link
Member

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)

Copy link
Contributor Author

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;
Copy link
Member

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

{
// 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);
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated CandidateSet

@pranavkm pranavkm changed the base branch from release/5.0-preview8 to master July 24, 2020 16:08
@pranavkm pranavkm force-pushed the prkrishn/fix-nullability branch 2 times, most recently from f2f0c59 to d10a6ee Compare July 24, 2020 16:19
@pranavkm pranavkm force-pushed the prkrishn/fix-nullability branch from d10a6ee to fab7ed7 Compare July 24, 2020 22:53
pranavkm added 2 commits July 24, 2020 16:17
We previously only had annotations enabled which resulted in incorrect nullability. This change enables
nullability.

Fixes #24042
@pranavkm pranavkm force-pushed the prkrishn/fix-nullability branch from fab7ed7 to cf03192 Compare July 24, 2020 23:18
@pranavkm pranavkm merged commit f269428 into master Jul 25, 2020
@pranavkm pranavkm deleted the prkrishn/fix-nullability branch July 25, 2020 14:34
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Routing public API nullability issue
3 participants