Skip to content

Commit

Permalink
Perf tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbeuk committed Jun 14, 2021
1 parent 9e2cf04 commit 389eec3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ScenarioTests.Generator/ScenarioTestGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Initialize(GeneratorInitializationContext context) =>
public void Execute(GeneratorExecutionContext context)
{
// retrieve the populated receiver
if (context.SyntaxReceiver is not SyntaxReceiver receiver)
if (context.SyntaxReceiver is not SyntaxReceiver receiver || receiver.ScenarioCandidates is null)
{
return;
}
Expand Down
7 changes: 6 additions & 1 deletion src/ScenarioTests.Generator/SyntaxReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ScenarioTests.Generator
{
public class SyntaxReceiver : ISyntaxReceiver
{
public List<MethodDeclarationSyntax> ScenarioCandidates { get; } = new List<MethodDeclarationSyntax>();
public List<MethodDeclarationSyntax> ScenarioCandidates { get; private set; }

public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
{
Expand All @@ -20,6 +20,11 @@ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)

if (hasScenarioAttribute)
{
if (ScenarioCandidates is null)
{
ScenarioCandidates = new();
}

ScenarioCandidates.Add(methodDeclarationSyntax);
}
}
Expand Down

0 comments on commit 389eec3

Please sign in to comment.