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

Scaffolding: nullablility annotation issues #19496

Closed
smitpatel opened this issue Jan 6, 2020 · 3 comments · Fixed by #19507
Closed

Scaffolding: nullablility annotation issues #19496

smitpatel opened this issue Jan 6, 2020 · 3 comments · Fixed by #19507
Assignees
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@smitpatel
Copy link
Member

My VS build currently fails with this

4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(634,50,634,59): error CS8604: Possible null reference argument for parameter 'name' in 'string SqlServerDatabaseModelFactory.DisplayName(string? schema, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(854,96,854,105): error CS8604: Possible null reference argument for parameter 'name' in 'string SqlServerDatabaseModelFactory.DisplayName(string? schema, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(887,108,887,117): error CS8604: Possible null reference argument for parameter 'name' in 'string SqlServerDatabaseModelFactory.DisplayName(string? schema, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(889,80,889,110): error CS8604: Possible null reference argument for parameter 'name' in 'DatabaseUniqueConstraint.DatabaseUniqueConstraint(DatabaseTable table, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(925,86,925,95): error CS8604: Possible null reference argument for parameter 'name' in 'string SqlServerDatabaseModelFactory.DisplayName(string? schema, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(927,58,927,77): error CS8604: Possible null reference argument for parameter 'name' in 'DatabaseIndex.DatabaseIndex(DatabaseTable table, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(1005,59,1005,77): error CS8604: Possible null reference argument for parameter 'name' in 'string SqlServerDatabaseModelFactory.DisplayName(string? schema, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(1020,63,1020,81): error CS8604: Possible null reference argument for parameter 'name' in 'string SqlServerDatabaseModelFactory.DisplayName(string? schema, string name)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(1025,68,1025,74): error CS8604: Possible null reference argument for parameter 'name' in 'DatabaseForeignKey.DatabaseForeignKey(DatabaseTable table, string name, DatabaseTable principalTable)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(1027,63,1027,77): error CS8604: Possible null reference argument for parameter 'onDeleteAction' in 'ReferentialAction? SqlServerDatabaseModelFactory.ConvertToReferentialAction(string onDeleteAction)'.
4>D:\code\EntityFrameworkCore\src\EFCore.SqlServer\Scaffolding\Internal\SqlServerDatabaseModelFactory.cs(1051,67,1051,85): error CS8604: Possible null reference argument for parameter 'name' in 'string SqlServerDatabaseModelFactory.DisplayName(string? schema, string name)'.

Source of confusion is this
https://github.com/aspnet/EntityFrameworkCore/blob/e2ba1c8dab28db719f7a58cacba98dabc23390a7/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs#L41-L48

The file is marked as nullable enable so my understanding is T is non-null but then it does not match annotation on method. On the other hand if this method can return null then it is being used to pass argument to a method which does not accept null.

@smitpatel
Copy link
Member Author

cc: @roji

@roji
Copy link
Member

roji commented Jan 6, 2020

Thanks. You're right that there's an issue: GetValueOrDefault is indeed marked to return nullable (with the MaybeNull attribute), and so it's weird that on my machine and on the CI tableName could be passed to DisplayName without a warning. This is somehow related to the GroupBy being performed over the tableName, which somehow makes the compiler regard it as non-nullable.

Any chance you're using a different VS (or especially dotnet SDK) to build, explaining the behavior difference? Are other people on the team also seeing this with VS (or anything else)?

@smitpatel
Copy link
Member Author

VS Int Preview 16.5.0 Preview 2.0 29703.146.master
Whatever preview SDK startvs.cmd sets.

roji added a commit that referenced this issue Jan 7, 2020
That only surface in preview versions of VS.

Fixes #19496
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jan 7, 2020
roji added a commit that referenced this issue Jan 9, 2020
That only surface in preview versions of VS.

Fixes #19496
@ajcvickers ajcvickers added this to the 5.0.0 milestone Jan 10, 2020
roji added a commit that referenced this issue Jan 11, 2020
That only surface in preview versions of VS.

Fixes #19496
svengeance pushed a commit to svengeance/EntityFrameworkCore that referenced this issue Jan 15, 2020
That only surface in preview versions of VS.

Fixes dotnet#19496
@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-preview1 Mar 13, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-preview1, 5.0.0 Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants