Skip to content

Commit 192e3ee

Browse files
committed
Fixed concurrency issue in FlowsSourceGenerator.cs
1 parent 382cf91 commit 192e3ee

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

SourceGeneration/Cleipnir.Flows.SourceGenerator/FlowsSourceGenerator.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Linq;
1+
using System.Linq;
32
using Microsoft.CodeAnalysis;
43
using Microsoft.CodeAnalysis.CSharp.Syntax;
54
using static Cleipnir.Flows.SourceGenerator.Utils;
@@ -14,10 +13,10 @@ public class FlowsSourceGenerator : IIncrementalGenerator
1413
private const string ResultFlowType = "Cleipnir.Flows.Flow`2";
1514
private const string IgnoreAttribute = "Cleipnir.Flows.SourceGeneration.Ignore";
1615

17-
private INamedTypeSymbol? _paramlessFlowTypeSymbol;
18-
private INamedTypeSymbol? _unitFlowTypeSymbol;
19-
private INamedTypeSymbol? _resultFlowTypeSymbol;
20-
private INamedTypeSymbol? _ignoreAttribute;
16+
private volatile INamedTypeSymbol? _paramlessFlowTypeSymbol;
17+
private volatile INamedTypeSymbol? _unitFlowTypeSymbol;
18+
private volatile INamedTypeSymbol? _resultFlowTypeSymbol;
19+
private volatile INamedTypeSymbol? _ignoreAttribute;
2120

2221
public void Initialize(IncrementalGeneratorInitializationContext context)
2322
{
@@ -38,13 +37,13 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3837
public GeneratedFlowInformation? Transform(GeneratorAttributeSyntaxContext context)
3938
{
4039

41-
//if (_paramlessFlowTypeSymbol == null)
40+
if (_paramlessFlowTypeSymbol == null)
4241
{
4342
var complication = context.SemanticModel.Compilation;
44-
_paramlessFlowTypeSymbol = complication.GetTypeByMetadataName(ParamlessFlowType);
4543
_unitFlowTypeSymbol = complication.GetTypeByMetadataName(UnitFlowType);
4644
_resultFlowTypeSymbol = complication.GetTypeByMetadataName(ResultFlowType);
4745
_ignoreAttribute = complication.GetTypeByMetadataName(IgnoreAttribute);
46+
_paramlessFlowTypeSymbol = complication.GetTypeByMetadataName(ParamlessFlowType);
4847
}
4948

5049
if (_paramlessFlowTypeSymbol == null || _unitFlowTypeSymbol == null || _resultFlowTypeSymbol == null)

0 commit comments

Comments
 (0)