Simplified type resolution

This commit is contained in:
Koen
2023-03-09 19:15:50 +00:00
parent 6de068b2c8
commit 220fe4f58b
3 changed files with 4 additions and 10 deletions

View File

@@ -214,14 +214,9 @@ namespace EntityFrameworkCore.Projectables.Generator
// if this node refers to a named type which is not yet fully qualified, we want to fully qualify it // if this node refers to a named type which is not yet fully qualified, we want to fully qualify it
if (symbol.Kind is SymbolKind.NamedType && node.Parent?.Kind() is not SyntaxKind.QualifiedName) if (symbol.Kind is SymbolKind.NamedType && node.Parent?.Kind() is not SyntaxKind.QualifiedName)
{ {
var typeInfo = _semanticModel.GetTypeInfo(node); return SyntaxFactory.ParseTypeName(
symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)
if (typeInfo.Type is not null) ).WithLeadingTrivia(node.GetLeadingTrivia());
{
return SyntaxFactory.ParseTypeName(
typeInfo.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)
).WithLeadingTrivia(node.GetLeadingTrivia());
}
} }
} }

View File

@@ -7,7 +7,7 @@ namespace EntityFrameworkCore.Projectables.Generated
{ {
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.EntityExtensions.Entity, global::Foo.EntityExtensions.Entity>> Expression() static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.EntityExtensions.Entity, global::Foo.EntityExtensions.Entity>> Expression()
{ {
return (global::Foo.EntityExtensions.Entity entity) => new Entity(entity.Id) return (global::Foo.EntityExtensions.Entity entity) => new global::Foo.EntityExtensions.Entity(entity.Id)
{FullName = entity.FullName}; {FullName = entity.FullName};
} }
} }

View File

@@ -1615,7 +1615,6 @@ class EntityBase<TId> where TId : ICloneable, new() {
return Verifier.Verify(result.GeneratedTrees[0].ToString()); return Verifier.Verify(result.GeneratedTrees[0].ToString());
} }
#region Helpers #region Helpers
Compilation CreateCompilation(string source, bool expectedToCompile = true) Compilation CreateCompilation(string source, bool expectedToCompile = true)