mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-08-15 18:44:57 +00:00
Fixed nullability rewrites with parameters and return types
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Foo;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class Foo_C_NextFoo
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<List<object> ,List<int?>, List<object>>> Expression =>
|
||||
(List<object> input,List<int?> nullablePrimitiveArgument) => input;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ namespace EntityFrameworkCore.Projectables.Generated
|
||||
{
|
||||
public static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<Entity, global::Foo.EntityExtensions.Entity>> Expression =>
|
||||
public static System.Linq.Expressions.Expression<System.Func<Entity, Entity>> Expression =>
|
||||
(Entity entity) => entity.RelatedEntities[0];
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ namespace EntityFrameworkCore.Projectables.Generated
|
||||
{
|
||||
public static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<Entity, global::Foo.EntityExtensions.Entity>> Expression =>
|
||||
public static System.Linq.Expressions.Expression<System.Func<Entity, Entity>> Expression =>
|
||||
(Entity entity) => entity != null ? (entity.RelatedEntities != null ? (entity.RelatedEntities[0]) : null) : null;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Foo;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class Foo_C_NullableReferenceType
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<object, string>> Expression =>
|
||||
(object input) => (string)input;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -8,7 +8,7 @@ namespace EntityFrameworkCore.Projectables.Generated
|
||||
{
|
||||
public static class Foo_C_NextFoo
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<object? ,int?, object>> Expression =>
|
||||
(object? unusedArgument,int? nullablePrimitiveArgument) => null;
|
||||
public static System.Linq.Expressions.Expression<System.Func<object ,int?, object>> Expression =>
|
||||
(object unusedArgument,int? nullablePrimitiveArgument) => null;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Foo;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class Foo_C_NullableValueType
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<object, int?>> Expression =>
|
||||
(object input) => (int?)input;
|
||||
}
|
||||
}
|
||||
+82
@@ -487,6 +487,88 @@ namespace Foo {
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task GenericNullableReferenceTypesAreBeingEliminated()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Foo {
|
||||
static class C {
|
||||
[Projectable]
|
||||
public static List<object?> NextFoo(this List<object?> input, List<int?> nullablePrimitiveArgument) => input;
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
var result = RunGenerator(compilation);
|
||||
|
||||
Assert.Empty(result.Diagnostics);
|
||||
Assert.Single(result.GeneratedTrees);
|
||||
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task NullableReferenceTypeCastOperatorGetsEliminated()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Foo {
|
||||
static class C {
|
||||
[Projectable]
|
||||
public static string? NullableReferenceType(object? input) => (string?)input;
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
var result = RunGenerator(compilation);
|
||||
|
||||
Assert.Empty(result.Diagnostics);
|
||||
Assert.Single(result.GeneratedTrees);
|
||||
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task NullableValueCastOperatorsPersist()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Foo {
|
||||
static class C {
|
||||
[Projectable]
|
||||
public static int? NullableValueType(object? input) => (int?)input;
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
var result = RunGenerator(compilation);
|
||||
|
||||
Assert.Empty(result.Diagnostics);
|
||||
Assert.Single(result.GeneratedTrees);
|
||||
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void NullableMemberBinding_WithoutSupport_IsBeingReported()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user