Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public ExpressionSyntaxRewriter(INamedTypeSymbol targetTypeSymbol, NullCondition
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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,32 @@ public class Bar {
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)
Expand Down