Skip to content

Fix null dereference build errors in the scaffolding tests - #38949

Merged
AndriySvyryd merged 1 commit into
dotnet:mainfrom
Aykuttonpc:fix-design-tests-null-deref
Sep 10, 2026
Merged

AndriySvyryd merged 1 commit into
dotnet:mainfrom
Aykuttonpc:fix-design-tests-null-deref

Conversation

@Aykuttonpc

Copy link
Copy Markdown
Contributor

EFCore.Design.Tests currently fails to build on main, which takes the Main leg of CI down on all three platforms:

test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs(412,36): error CS8602: Dereference of a possibly null reference.
test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs(435,36): error CS8602: Dereference of a possibly null reference.
test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs(1240,32): error CS8602: Dereference of a possibly null reference.

FindEntityType returns a nullable IEntityType, and the three call sites added in #38795 dereference the result directly. The test projects build with warnings as errors, so this fails the build rather than just warning.

Every other FindEntityType call in these two files already uses the null forgiving operator for exactly this pattern (for example lines 247, 299 and 390 of CSharpDbContextGeneratorTest.cs), so this change just makes the new call sites consistent with the ones around them.

Verified locally on Linux: EFCore.Design.Tests builds clean and the three affected tests pass.

FindEntityType returns a nullable IEntityType, and three call sites added in
dotnet#38795 dereference the result directly. The test projects build with warnings
as errors, so this fails the build instead of just warning, and it currently
takes down the Main leg of CI on all three platforms.

Every other FindEntityType call in these two files already uses the null
forgiving operator for this exact pattern, so match that.

@AndriySvyryd AndriySvyryd left a comment

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.

Thanks for your contribution!

@AndriySvyryd
AndriySvyryd merged commit a5aeccb into dotnet:main Sep 10, 2026
16 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants