Skip to content
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

Annotate the remainder of metadata for nullability #23905

Merged
merged 8 commits into from
Jan 21, 2021
Merged

Conversation

roji
Copy link
Member

@roji roji commented Jan 16, 2021

Sorry @AndriySvyryd :(

There's a lot of stuff here, I did my best - I know there are some bangs that could be investigated further. I suggest concentrating on the public APIs - anything on private/internal can be easily improved later.

Note that for the various Builders, the vast majority of accesses assume they aren't null (i.e. not removed from the model). So I made them non-nullable, and added a separate IsInModel property for checking that. Did similar with ConventionDispatcher and the recently-introduced IsReadonly.

Part of #19007

@roji roji requested a review from AndriySvyryd January 16, 2021 14:03
@roji roji force-pushed the MetadataNullability4 branch from 72263d3 to 5b64e1a Compare January 16, 2021 17:07
@roji roji marked this pull request as ready for review January 16, 2021 17:07
@@ -334,7 +336,7 @@ public static class RelationalModelBuilderExtensions
/// <returns> A builder to further configure the function. </returns>
public static IConventionDbFunctionBuilder HasDbFunction(
[NotNull] this IConventionModelBuilder modelBuilder,
[NotNull] string name,
[CanBeNull] string? name,
Copy link
Member

Choose a reason for hiding this comment

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

Should be NotNull

Copy link
Member Author

Choose a reason for hiding this comment

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

This is called from RelationalEntityTypeBuilderExtensions.ToFunction with a null name. Should we add another HasDbFunction on RelationalModelBuilderExtensions which doesn't accept a returnType, and accepts a nullable name? Or something else?

Copy link
Member

Choose a reason for hiding this comment

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

It just shouldn't be called if name is null, it will throw

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry if I'm misunderstanding, but I don't see where RelationalEntityTypeBuilderExtensions.ToFunction would throw before calling this... Did you want me to add a check and throw somewhere, or just skip the HasDbFunction call (and so just do SetFunctionName(null) on the entity type?

Copy link
Member

Choose a reason for hiding this comment

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

I mean if HasDbFunction is called with null name then Check.NotEmpty will throw, so the HasDbFunction call should be skipped

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, adding a condition in ToFunction around the HasDbFunction call to skip it when name is null (so it only performs SetFunctionName)

@roji roji requested a review from AndriySvyryd January 21, 2021 13:22
@roji roji enabled auto-merge (squash) January 21, 2021 20:23
@roji roji merged commit f54b9dc into main Jan 21, 2021
@roji roji deleted the MetadataNullability4 branch January 21, 2021 20:32
@AndriySvyryd
Copy link
Member

It merged without waiting for checks to complete 😮
@ajcvickers

@roji
Copy link
Member Author

roji commented Jan 21, 2021

Yeah... Just posted on the team channel. I guess we don't have a rule that requires CI checks to be green...

@ajcvickers
Copy link
Contributor

ajcvickers commented Jan 21, 2021

I guess we don't have a rule that requires CI checks to be green...

By design. Hopefully the auto-complete feature is not limited to the same rules for manual merges, otherwise I doubt we can use it.

@roji
Copy link
Member Author

roji commented Jan 21, 2021

😥 welp, at least the build happened to pass, looks like I'm a pretty lucky guy...

Yes, AFAIK the feature simply applies the rules that have been defined. If we want to be able to manually merge even though the CI isn't passing, I guess we'll have to disable this.

@AndriySvyryd
Copy link
Member

Then it doesn't replace the bot, just offers a different way of merging

@roji
Copy link
Member Author

roji commented Jan 21, 2021

If we can't use it before CI is done, I'd personally just use the bot...

@ajcvickers
Copy link
Contributor

We could require green again, but we know that there are times when C.I. flakiness makes that difficult. It's up to the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annotate EF Core for nullable reference types
4 participants