mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-05-23 03:06:30 +00:00
Don't rewrite cast expressions
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Projectables.Repro;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class Projectables_Repro_SomeExtensions_AsSomeResult
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<global::Projectables.Repro.SomeEntity, string>> Expression()
|
||||
{
|
||||
return (global::Projectables.Repro.SomeEntity e) =>
|
||||
((global::Projectables.Repro.SuperEntity)e).Superpower;
|
||||
}
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
using EntityFrameworkCore.Projectables;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class _SomeExtensions_Test
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<global::SomeFlag, bool>> Expression()
|
||||
{
|
||||
return (global::SomeFlag f) =>
|
||||
f == global::SomeFlag.Foo;
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -1045,6 +1045,39 @@ public static class SomeExtensions
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task Cast()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using EntityFrameworkCore.Projectables;
|
||||
|
||||
namespace Projectables.Repro;
|
||||
|
||||
public class SuperEntity : SomeEntity
|
||||
{
|
||||
public string Superpower { get; set; }
|
||||
}
|
||||
|
||||
public class SomeEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public static class SomeExtensions
|
||||
{
|
||||
[Projectable]
|
||||
public static string AsSomeResult(this SomeEntity e) => ((SuperEntity)e).Superpower;
|
||||
}
|
||||
");
|
||||
|
||||
var result = RunGenerator(compilation);
|
||||
|
||||
Assert.Empty(result.Diagnostics);
|
||||
Assert.Single(result.GeneratedTrees);
|
||||
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
|
||||
Compilation CreateCompilation(string source, bool expectedToCompile = true)
|
||||
|
||||
Reference in New Issue
Block a user