-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Try to embrace the future early #23296
Conversation
@@ -2,7 +2,7 @@ | |||
|
|||
<PropertyGroup> | |||
<Description>In-memory database provider for Entity Framework Core (to be used for testing purposes).</Description> | |||
<TargetFramework>netstandard2.1</TargetFramework> | |||
<TargetFramework>net5.0</TargetFramework> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we extract this to the common Directory.Build.props or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I like to keep the csproj files relativly "vanilla" even if it's not as DRY. I hate hunting through msbuild files to find basic properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbConfiguredConditionAttribute.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments below
src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs
Show resolved
Hide resolved
src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs
Show resolved
Hide resolved
src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs
Show resolved
Hide resolved
[NotNull] string fieldName, | ||
[NotNull] TypeBase type, | ||
[CanBeNull] string propertyName, | ||
[NotNull] string propertyName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the annotation for this method should actually be... Usage in our codebase doesn't seem to need nullable propertyName
, and we do have checks on the return value being nullable.
return result != 0 ? result : EntityTypeFullNameComparer.Instance.Compare(x.DeclaringEntityType, y.DeclaringEntityType); | ||
} | ||
public int Compare(SkipNavigation? x, SkipNavigation? y) | ||
=> (x, y) switch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference: https://twitter.com/smitpatel/status/1328545513549905920
LGTM |
Failing for linux/mac 😨 |
The error is coming from the file which is not in this PR (since AzDo will rebase on top of main to run PR). I am taking this PR over to make it review ready and merge. I will be rewriting history so please hold off pushing any changes for a day. |
fc72110
to
cd77d47
Compare
@AndriySvyryd - Ping! |
src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs
Show resolved
Hide resolved
src/EFCore.Relational/Query/SqlExpressions/SqlParameterExpression.cs
Outdated
Show resolved
Hide resolved
@@ -188,7 +188,7 @@ static int GetEngineEdition(DbConnection connection) | |||
using var command = connection.CreateCommand(); | |||
command.CommandText = @" | |||
SELECT SERVERPROPERTY('EngineEdition');"; | |||
return (int)command.ExecuteScalar(); | |||
return (int)command.ExecuteScalar()!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is !
needed here? Isn't the cast enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting something which returns nullable to non-null with hard cast is still null error. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roji Is this by-design or a nullable bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's by design.
The language decision was indeed to require an explicit bang in any conversion from nullable to non-nullable - a cast is not enough. One good argument for that is that if casts were enough, then in legacy (unannotated) code they would automatically become nullable->non-nullable conversions, introducing many bugs.
Re ExecuteScalar, that is particularly painful. The problem is that ExecuteScalar does return null (as opposed to DBNull.Value) when there is no resultset, i.e. if you execute DELETE/UPDATE/INSERT. It's an awful API, and I hope to have enough time to make a better one in dotnet/runtime#26511, which would be both generic (non-boxing) and better around nullability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could argue that a cast to non-nullable value type would still retain its meaning, but I see why they wouldn't want complex rules like this
src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs
Show resolved
Hide resolved
src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it 👍
cd77d47
to
2a11111
Compare
@smitpatel @roji feel free to start tackling the 775 new NRT warnings