Skip to content

Conversation

pranavkm
Copy link
Contributor

Contributes to #5680

@pranavkm pranavkm force-pushed the prkrishn/nullable-mvc branch from 30cfbc3 to 860cd1d Compare June 16, 2020 06:12
@ghost
Copy link

ghost commented Jun 16, 2020

Hello @pranavkm!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 60 minutes, a condition that will be fulfilled in about 54 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@pranavkm pranavkm marked this pull request as ready for review June 16, 2020 07:17
@pranavkm pranavkm requested review from javiercn and JamesNK June 16, 2020 07:17
@pranavkm pranavkm force-pushed the prkrishn/nullable-mvc branch from 860cd1d to 53357e9 Compare June 16, 2020 07:20
@Pilchie Pilchie added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jun 16, 2020

/// <summary>
/// The set of parameters associated with this action.
/// </summary>
public IList<ParameterDescriptor> Parameters { get; set; }
public IList<ParameterDescriptor> Parameters { get; set; } = Array.Empty<ParameterDescriptor>();
Copy link
Member

Choose a reason for hiding this comment

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

These are not read-only, if we do this we can cause issues to existing code when they call Add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These get initialized later on by the framework. It's not an issue in actual usage.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, I don't really understand why we prefer Array.Empty<T> to default! but I don't feel super strongly about it.

actionContext?.HttpContext!,
actionContext?.RouteData!,
actionContext?.ActionDescriptor!,
actionContext?.ModelState!)
{
Copy link
Member

Choose a reason for hiding this comment

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

I'm missing something, how can actionContext be null here if you are requiring it not to be null? Why do we need the ? operators and the !?

Copy link
Member

Choose a reason for hiding this comment

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

could we do actionContext! instead here?

Copy link
Member

Choose a reason for hiding this comment

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

for the other constructor we should remove the nullchecks and use the ! in the parameter instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, i'll change the paramater to be nullable. There are unit test code paths this gets used in where the context is null

@@ -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.

#nullable enable
Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of the usages of this class in favor of the one in the framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably in mvc.

@@ -89,7 +89,7 @@ public class CompositeBindingSource : BindingSource
/// <inheritdoc />
public override bool CanAcceptDataFrom(BindingSource bindingSource)
{
if (bindingSource == null)
if (bindingSource is null)
Copy link
Member

Choose a reason for hiding this comment

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

It would help if you keep focus on this already big PRs. Small changes like this distract and don't add value individually. (If we decided to convert the entire repo to use this style then so be it, but there's no agreement on this, and it would be more efficient done in a single pass).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiler was complaining because the type has an equality operator. LHS is a non-null type, and RHS is null, so it says the two can never be equal. It was weird, but I didn't want to spend too much time on this

Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

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

Looks good, I have some comments

@pranavkm pranavkm force-pushed the prkrishn/nullable-mvc branch from 53357e9 to 4f17721 Compare June 20, 2020 07:14
@pranavkm
Copy link
Contributor Author

🆙 📅

@pranavkm pranavkm force-pushed the prkrishn/nullable-mvc branch from 4f17721 to 4ec628a Compare June 23, 2020 21:50
@ghost ghost merged commit f5709b4 into master Jun 23, 2020
@ghost ghost deleted the prkrishn/nullable-mvc branch June 23, 2020 22:56
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants