Merge pull request #11 from koenbeuk/issue-10

Support Inherited properties
This commit is contained in:
Koen
2021-12-12 20:36:37 +08:00
committed by GitHub
6 changed files with 103 additions and 7 deletions
@@ -98,7 +98,7 @@ namespace EntityFrameworkCore.Projectables.Generator
{
var symbolInfo = _semanticModel.GetSymbolInfo(node);
if (symbolInfo.Symbol is not null && SymbolEqualityComparer.Default.Equals(symbolInfo.Symbol.ContainingType, _targetTypeSymbol))
if (symbolInfo.Symbol is not null)
{
var scopedNode = node.ChildNodes().FirstOrDefault();
if (scopedNode is ThisExpressionSyntax)
@@ -127,7 +127,7 @@ namespace EntityFrameworkCore.Projectables.Generator
if (symbolInfo.Symbol is IMethodSymbol methodSymbol && methodSymbol.IsExtensionMethod)
{
}
else if (symbolInfo.Symbol.Kind is SymbolKind.Property or SymbolKind.Method or SymbolKind.Field && SymbolEqualityComparer.Default.Equals(symbolInfo.Symbol.ContainingType, _targetTypeSymbol))
else if (symbolInfo.Symbol.Kind is SymbolKind.Property or SymbolKind.Method or SymbolKind.Field /*&& SymbolEqualityComparer.Default.Equals(symbolInfo.Symbol.ContainingType, _targetTypeSymbol)*/)
{
bool rewrite = true;
@@ -138,6 +138,10 @@ namespace EntityFrameworkCore.Projectables.Generator
{
rewrite = false;
}
if (targetSymbolInfo.Symbol?.ContainingType is not null && !_context.Compilation.HasImplicitConversion(targetSymbolInfo.Symbol.ContainingType, _targetTypeSymbol))
{
rewrite = false;
}
}
else if (node.Parent.IsKind(SyntaxKind.SimpleAssignmentExpression))
{