@@ -85,9 +85,10 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
8585
8686 // Output
8787 context . RegisterSourceOutput ( idsWithDefaultsAndTemplates ,
88- static ( spc , source ) => Execute ( source . Left . Left , source . Left . Right , source . Right , spc ) ) ;
88+ static ( spc , source ) => GenerateIds ( source . Left . Left , source . Left . Right , source . Right , spc ) ) ;
8989 }
90- private static void Execute (
90+
91+ private static void GenerateIds (
9192 StructToGenerate idToGenerate ,
9293 ImmutableArray < ( string Path , string Name , string ? Content ) > templates ,
9394 ( EquatableArray < ( string Name , string Content ) > , bool IsValid , DiagnosticInfo ? Diagnostic ) defaults ,
@@ -99,7 +100,7 @@ private static void Execute(
99100 context . ReportDiagnostic ( diagnostic ) ;
100101 }
101102
102- if ( ! TryGetTemplateContent ( idToGenerate , templates , defaults , in context , out var templateContents ) )
103+ if ( ! TryGetTemplateContent ( idToGenerate . Template , idToGenerate . TemplateNames , idToGenerate . TemplateLocation , templates , defaults , in context , out var templateContents ) )
103104 {
104105 return ;
105106 }
@@ -111,6 +112,7 @@ private static void Execute(
111112 var result = SourceGenerationHelper . CreateId (
112113 idToGenerate . NameSpace ,
113114 idToGenerate . Name ,
115+ idToGenerate . Name , // same type
114116 idToGenerate . Parent ,
115117 content ,
116118 addDefaultAttributes : string . IsNullOrEmpty ( name ) ,
@@ -190,26 +192,28 @@ private static (EquatableArray<(string Name, string Content)>, bool, DiagnosticI
190192 }
191193
192194 private static bool TryGetTemplateContent (
193- in StructToGenerate idToGenerate ,
195+ Template ? selectedTemplate ,
196+ EquatableArray < string > selectedTemplateNames ,
197+ LocationInfo ? attributeLocation ,
194198 in ImmutableArray < ( string Path , string Name , string ? Content ) > templates ,
195199 ( EquatableArray < ( string Name , string Content ) > Contents , bool IsValid , DiagnosticInfo ? Diagnostics ) defaults ,
196200 in SourceProductionContext context ,
197201 [ NotNullWhen ( true ) ] out ( string Name , string Content ) [ ] ? templateContents )
198202 {
199203 ( string , string ) ? builtIn = null ;
200- if ( idToGenerate . Template is { } templateId )
204+ if ( selectedTemplate is { } templateId )
201205 {
202206 // built-in template specified
203207 var content = EmbeddedSources . GetTemplate ( templateId ) ;
204208 builtIn = ( string . Empty , content ) ;
205209 }
206210
207- if ( idToGenerate . TemplateNames . GetArray ( ) is { Length : > 0 } templateNames )
211+ if ( selectedTemplateNames . GetArray ( ) is { Length : > 0 } templateNames )
208212 {
209213 // custom template specified
210214 if ( GetContent (
211215 templateNames ,
212- idToGenerate . TemplateLocation ,
216+ attributeLocation ,
213217 builtIn . HasValue ,
214218 in templates ,
215219 out templateContents ,
0 commit comments