mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-05-23 03:06:30 +00:00
Fixed code gen issue for Projectable extension methods using other projectable extension methods
This commit is contained in:
+3
@@ -11,6 +11,9 @@ namespace EntityFrameworkCore.Projectables.FunctionalTests.ExtensionMethods
|
||||
[Projectable]
|
||||
public static int Foo(this Entity entity) => entity.Id + 1;
|
||||
|
||||
[Projectable]
|
||||
public static int Foo2(this Entity entity) => entity.Foo() + 1;
|
||||
|
||||
[Projectable]
|
||||
public static Entity? LeadingEntity(this Entity entity, DbContext dbContext)
|
||||
=> dbContext.Set<Entity>().Where(y => y.Id > entity.Id).FirstOrDefault();
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
SELECT ([e].[Id] + 1) + 1
|
||||
FROM [Entity] AS [e]
|
||||
+11
@@ -38,6 +38,17 @@ namespace EntityFrameworkCore.Projectables.FunctionalTests.ExtensionMethods
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task SelectProjectableExtensionMethod2()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<Entity>();
|
||||
|
||||
var query = dbContext.Set<Entity>()
|
||||
.Select(x => x.Foo2());
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ExtensionMethodAcceptingDbContext()
|
||||
{
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Foo;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class Foo_C_Foo1
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<int, int>> Expression =>
|
||||
(int i) => i;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Foo;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class Foo_C_Foo1
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<object, object>> Expression =>
|
||||
(object i) => i.Foo1();
|
||||
}
|
||||
}
|
||||
+50
@@ -367,6 +367,56 @@ namespace Foo {
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public Task ProjectableExtensionMethod3()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using System;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
namespace Foo {
|
||||
static class C {
|
||||
[Projectable]
|
||||
public static int Foo1(this int i) => i;
|
||||
|
||||
[Projectable]
|
||||
public static int Foo2(this int i) => i.Foo1();
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
var result = RunGenerator(compilation);
|
||||
|
||||
Assert.Empty(result.Diagnostics);
|
||||
Assert.Equal(2, result.GeneratedTrees.Length);
|
||||
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ProjectableExtensionMethod4()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using System;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
namespace Foo {
|
||||
static class C {
|
||||
[Projectable]
|
||||
public static object Foo1(this object i) => i.Foo1();
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
var result = RunGenerator(compilation);
|
||||
|
||||
Assert.Empty(result.Diagnostics);
|
||||
Assert.Single(result.GeneratedTrees);
|
||||
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlockBodiedMember_RaisesDiagnostics()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user