You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Analyzer suggestion: mark DbSet's nullability suppression property initializer as unnecessary #29988
Prior to EF Core 7 this was a normal example of Db context declaration. However, since EF Core 7 introduced a nullability warning suppressor for DbSet properties, the = null!; is no longer needed and can be considered as unnecessary noise. It would be great to have an analyzer + codefix, that would suggest to remove the = null!; part.
Notes:
By playing with diagnostic tags you can actually make = null!; fade out the way VS fades out all unnecessary code parts (usings, parentheses etc.). This should also work in Rider, but I am not sure
The codefix should have proper fix-all support, so if a user updates his codebase from EF Core 6, he can just fix all such cases in several clicks
The diagnostic should only trigger for actual nullability suppressions like = null!; or = default!;. It should not be reported for things like = null;, because without nullability suppression operator it is no longer a EF-specific case
Really nice idea, I like it; added to #22086 for tracking along with other analyzer ideas.
Unfortunately there's a compiler bug which makes the suppressor fail when warnings-as-errors is enabled (#29582), so this wouldn't be a great idea until that's fixed...
After updating Visual Studio 2022 from v17.11.0 to v17.12.0 today, I'm now getting a long list of warnings from the analyzer for my EF Core DbContext definition:
I didn't get these warnings when using VS 2022 v17.11.0.
Is this by intention?
What's the suggested action to remedy these warnings without corrupting any non EF Core code? (Suppressing the warning is no option.)
Activity
roji commentedon Jan 5, 2023
Really nice idea, I like it; added to #22086 for tracking along with other analyzer ideas.
Unfortunately there's a compiler bug which makes the suppressor fail when warnings-as-errors is enabled (#29582), so this wouldn't be a great idea until that's fixed...
SetTrend commentedon Nov 17, 2024
After updating Visual Studio 2022 from v17.11.0 to v17.12.0 today, I'm now getting a long list of warnings from the analyzer for my EF Core DbContext definition:
I didn't get these warnings when using VS 2022 v17.11.0.
Is this by intention?
What's the suggested action to remedy these warnings without corrupting any non EF Core code? (Suppressing the warning is no option.)