Skip to content

Annotate the remainder of metadata for nullability#23905

Merged
roji merged 8 commits intomainfrom
MetadataNullability4
Jan 21, 2021
Merged

Annotate the remainder of metadata for nullability#23905
roji merged 8 commits intomainfrom
MetadataNullability4

Conversation

@roji
Copy link
Copy Markdown
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
Comment thread src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs
Comment thread src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs Outdated
Comment thread src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs Outdated
Comment thread src/EFCore.Relational/Query/Internal/FromSqlQueryingEnumerable.cs
Comment thread src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs Outdated
Comment thread src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs
Comment thread src/EFCore/Metadata/Internal/InternalModelBuilder.cs Outdated
Comment thread src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs
Comment thread src/EFCore/Metadata/Internal/SkipNavigation.cs Outdated
@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
Comment thread src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs
Comment thread src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs Outdated
Comment thread src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs Outdated
Comment thread src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs Outdated
Comment thread src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs Outdated
public static IConventionDbFunctionBuilder HasDbFunction(
[NotNull] this IConventionModelBuilder modelBuilder,
[NotNull] string name,
[CanBeNull] string? name,
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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)

Comment thread src/EFCore.Relational/Metadata/IConventionSequence.cs Outdated
Comment thread src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs Outdated
Comment thread src/EFCore/Extensions/MutablePropertyExtensions.cs Outdated
Comment thread src/EFCore/Metadata/Internal/Property.cs Outdated
Comment thread src/EFCore/Metadata/Internal/Property.cs Outdated
Comment thread src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs
Comment thread src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs
Comment thread src/EFCore/Metadata/Conventions/NotMappedMemberAttributeConvention.cs Outdated
Comment thread src/EFCore/Metadata/IConventionSkipNavigation.cs Outdated
Comment thread src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs Outdated
Comment thread src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs Outdated
Comment thread src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs Outdated
Comment thread src/EFCore/Metadata/Internal/SkipNavigation.cs Outdated
Comment thread src/EFCore/Metadata/Internal/TypeBaseExtensions.cs Outdated
roji and others added 2 commits January 21, 2021 13:48
…MappingConvention.cs

Co-authored-by: Andriy Svyryd <AndriySvyryd@users.noreply.github.com>
@roji roji requested a review from AndriySvyryd January 21, 2021 13:22
Comment thread src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs Outdated
@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
Copy Markdown
Member

It merged without waiting for checks to complete 😮
@ajcvickers

@roji
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@roji
Copy link
Copy Markdown
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
Copy Markdown
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