Raise diagnostics when not exposing expression bodies members

This commit is contained in:
Koen Bekkenutte
2021-05-31 02:05:57 +08:00
parent 999aca522c
commit c87509e07f
5 changed files with 86 additions and 0 deletions
@@ -340,6 +340,49 @@ namespace Foo {
return Verifier.Verify(result.GeneratedTrees[0].ToString());
}
[Fact]
public void BlockBodiedMember_RaisesDiagnostics()
{
var compilation = CreateCompilation(@"
using System;
using EntityFrameworkCore.Projections;
namespace Foo {
class C {
[Projectable]
public int Foo
{
get => 1;
}
}
}
");
var result = RunGenerator(compilation);
Assert.Single(result.Diagnostics);
}
[Fact]
public void BlockBodiedMethod_RaisesDiagnostics()
{
var compilation = CreateCompilation(@"
using System;
using EntityFrameworkCore.Projections;
namespace Foo {
class C {
[Projectable]
public int Foo()
{
return 1;
}
}
}
");
var result = RunGenerator(compilation);
Assert.Single(result.Diagnostics);
}
#region Helpers