mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-05-25 03:53:18 +00:00
Merge pull request #17 from koenbeuk/issue-16
Ensure that NamedTypeSymbols are not being rewritten
This commit is contained in:
@@ -136,7 +136,7 @@ namespace EntityFrameworkCore.Projectables.Generator
|
||||
if (node.Parent is MemberAccessExpressionSyntax parentMemberAccessNode)
|
||||
{
|
||||
var targetSymbolInfo = _semanticModel.GetSymbolInfo(parentMemberAccessNode.Expression);
|
||||
if (targetSymbolInfo.Symbol is { Kind: SymbolKind.Parameter })
|
||||
if (targetSymbolInfo.Symbol is { Kind: SymbolKind.Parameter or SymbolKind.NamedType })
|
||||
{
|
||||
rewrite = false;
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -1019,6 +1019,32 @@ namespace Foos {
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task EnumAccessor()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using EntityFrameworkCore.Projectables;
|
||||
|
||||
public enum SomeFlag
|
||||
{
|
||||
Foo
|
||||
}
|
||||
|
||||
public static class SomeExtensions
|
||||
{
|
||||
[Projectable]
|
||||
public static bool Test(this SomeFlag f) => f == SomeFlag.Foo;
|
||||
}
|
||||
");
|
||||
|
||||
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