Added a repro

This commit is contained in:
Koen Bekkenutte
2021-12-07 03:27:06 +08:00
parent 401b7d8043
commit ec2fb93140
3 changed files with 65 additions and 0 deletions
@@ -0,0 +1,18 @@
using System;
using System.Linq;
using System.Collections.Generic;
using EntityFrameworkCore.Projectables;
using Foo;
namespace EntityFrameworkCore.Projectables.Generated
#nullable disable
{
public static class Foo_Bar_ProjectedId
{
public static System.Linq.Expressions.Expression<System.Func<global::Foo.Bar, int>> Expression()
{
return (global::Foo.Bar @this) =>
Id;
}
}
}
@@ -0,0 +1,18 @@
using System;
using System.Linq;
using System.Collections.Generic;
using EntityFrameworkCore.Projectables;
using Foo;
namespace EntityFrameworkCore.Projectables.Generated
#nullable disable
{
public static class Foo_Bar_ProjectedId
{
public static System.Linq.Expressions.Expression<System.Func<global::Foo.Bar, int>> Expression()
{
return (global::Foo.Bar @this) =>
@this.Id;
}
}
}
@@ -959,6 +959,35 @@ namespace Foo {
return Verifier.Verify(result.GeneratedTrees[0].ToString());
}
[Fact]
public Task InheritedMembers()
{
var compilation = CreateCompilation(@"
using System;
using System.Linq;
using System.Collections.Generic;
using EntityFrameworkCore.Projectables;
namespace Foo {
public class Foo {
public int Id { get; set; }
}
public class Bar : Foo {
[Projectable]
public int ProjectedId => Id;
}
}
");
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)