Generator perf improvement

This commit is contained in:
Koen Bekkenutte
2021-06-10 02:20:21 +08:00
parent ce9ed10f8a
commit dde9bd3339
2 changed files with 7 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ namespace EntityFrameworkCore.Projectables.Generator
return;
}
if (receiver.Candidates.Count > 0)
if (receiver.Candidates?.Count > 0)
{
var projectables = receiver.Candidates
.Select(x => ProjectableInterpreter.GetDescriptor(x, context))

View File

@@ -10,7 +10,7 @@ namespace EntityFrameworkCore.Projectables.Generator
{
public class SyntaxReceiver : ISyntaxReceiver
{
public List<MemberDeclarationSyntax> Candidates { get; } = new List<MemberDeclarationSyntax>();
public List<MemberDeclarationSyntax>? Candidates { get; private set; }
public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
{
@@ -22,6 +22,11 @@ namespace EntityFrameworkCore.Projectables.Generator
if (hasProjectableAttribute)
{
if (Candidates == null)
{
Candidates = new();
}
Candidates.Add(memberDeclarationSyntax);
}
}