Repository navigation
Enable nullable annotations in precompiled query interceptors - #39224
Open
nurullahturkoglu wants to merge 1 commit into
Open
nurullahturkoglu wants to merge 1 commit into
nurullahturkoglu wants to merge 1 commit into
Conversation
- Emit #nullable enable annotations in the generated interceptors file, which has the nullable context disabled because it is marked auto-generated - Fail precompiled query tests when the generated code produces CS8669 Fixes dotnet#37996
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #37996
I posted the plan in #37996 (comment) but haven't heard back from the team yet, so the second box is unchecked.
Description
The generated interceptors file starts with
// <auto-generated />, so the compiler disables the nullable context for it, but the interceptor signatures keep the nullable annotations of the operators they intercept (e.g.TSource?forFirstOrDefault). This produces CS8669 in the user's project regardless of itsNullablesetting.The generator now emits
#nullable enable annotationsafter the#pragma warning disable EF9100line. This makes the annotations valid without enabling nullable warnings for the rest of the generated code.Testing
PrecompiledQueryTestHelpers.Testnow fails if the generated files produce CS8669, so every precompiled query test checks it.PrecompiledQuerySqliteTestandAdHocPrecompiledQuerySqliteTestfail, and 43 in the SQL Server precompiled test classes.EFCore.Design.Testsand the fullEFCore.Sqlite.FunctionalTests.I haven't run the tests on Windows.