|
1 | | -using System.Text; |
| 1 | +using System.Collections.Immutable; |
| 2 | +using System.Text; |
2 | 3 | using AttributeSourceGenerator.Common; |
3 | 4 | using AttributeSourceGenerator.Models; |
4 | 5 | using Microsoft.CodeAnalysis; |
@@ -36,8 +37,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) |
36 | 37 | { |
37 | 38 | context.RegisterPostInitializationOutput(AddMarkerAttributeSource); |
38 | 39 |
|
39 | | - var syntaxProvider = context.SyntaxProvider.ForAttributeWithMetadataName(_configuration.MarkerAttributeName, Filter, Transform); |
40 | | - context.RegisterSourceOutput(syntaxProvider, GenerateSourceForSymbol); |
| 40 | + var syntaxProvider = context.SyntaxProvider.ForAttributeWithMetadataName(_configuration.MarkerAttributeName, Filter, Transform).Collect(); |
| 41 | + context.RegisterSourceOutput(syntaxProvider, GenerateSourceForSymbols); |
41 | 42 | } |
42 | 43 |
|
43 | 44 | /// <summary>Adds the marker attribute source to the output.</summary> |
@@ -129,12 +130,12 @@ private static Symbol Transform(GeneratorAttributeSyntaxContext context, Cancell |
129 | 130 | return symbol; |
130 | 131 | } |
131 | 132 |
|
132 | | - /// <summary>Generates source code for a given symbol.</summary> |
| 133 | + /// <summary>Generates source for the given symbols.</summary> |
133 | 134 | /// <param name="context">The source production context.</param> |
134 | | - /// <param name="symbol">The symbol to generate source for.</param> |
135 | | - private void GenerateSourceForSymbol(SourceProductionContext context, Symbol symbol) |
| 135 | + /// <param name="symbols">The symbols to generate source for.</param> |
| 136 | + private void GenerateSourceForSymbols(SourceProductionContext context, ImmutableArray<Symbol> symbols) |
136 | 137 | { |
137 | | - var sources = _configuration.SourceGenerator(symbol); |
| 138 | + var sources = _configuration.SourceGenerator(symbols); |
138 | 139 | foreach (var source in sources) |
139 | 140 | context.AddSource($"{source.Name}.g.cs", source.Text); |
140 | 141 | } |
|
0 commit comments