55
66namespace Files . Core . SourceGenerator . Generators
77{
8+ /// <summary>
9+ /// Generates additional source code for classes based on their inheritance from specific types
10+ /// (e.g., IRealTimeWindow or IRealTimeControl).
11+ /// </summary>
812 [ Generator ]
913 public class RealTimeLayoutGenerator : IIncrementalGenerator
1014 {
15+ /// <summary>
16+ /// Initializes the incremental source generator with context-specific configuration.
17+ /// </summary>
18+ /// <param name="context">The incremental generator initialization context.</param>
1119 public void Initialize ( IncrementalGeneratorInitializationContext context )
1220 {
1321 var candidateClasses = context . SyntaxProvider
@@ -28,6 +36,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
2836 } ) ;
2937 }
3038
39+ /// <summary>
40+ /// Determines if the syntax node is a valid candidate for generation.
41+ /// </summary>
42+ /// <param name="syntaxNode">The syntax node to evaluate.</param>
43+ /// <returns>True if the node is a valid class candidate; otherwise, false.</returns>
3144 private static bool IsValidCandidate ( SyntaxNode syntaxNode )
3245 {
3346 if ( syntaxNode is ClassDeclarationSyntax classDeclaration )
@@ -38,6 +51,11 @@ private static bool IsValidCandidate(SyntaxNode syntaxNode)
3851 return false ;
3952 }
4053
54+ /// <summary>
55+ /// Retrieves a class declaration and its specification type if it matches the criteria.
56+ /// </summary>
57+ /// <param name="context">The syntax context for the generator.</param>
58+ /// <returns>A tuple containing the class declaration and its specification type, or null if no match.</returns>
4159 private static ( ClassDeclarationSyntax Class , SpecificationType Type ) ? GetCandidateClass ( GeneratorSyntaxContext context )
4260 {
4361 var classDeclaration = ( ClassDeclarationSyntax ) context . Node ;
@@ -60,6 +78,13 @@ private static (ClassDeclarationSyntax Class, SpecificationType Type)? GetCandid
6078 return null ;
6179 }
6280
81+ /// <summary>
82+ /// Generates the source code for a class based on the provided namespace, class name, and type.
83+ /// </summary>
84+ /// <param name="namespaceName">The namespace of the class.</param>
85+ /// <param name="className">The name of the class.</param>
86+ /// <param name="type">The type of the specification (Window or Control).</param>
87+ /// <returns>The generated source code as a string.</returns>
6388 private static string GenerateClass ( string namespaceName , string className , SpecificationType type )
6489 {
6590 // Namespace
@@ -111,6 +136,11 @@ private static string GenerateClass(string namespaceName, string className, Spec
111136 return compilationUnit . ToFullString ( ) ;
112137 }
113138
139+ /// <summary>
140+ /// Creates the body statements for the InitializeContentLayout method.
141+ /// </summary>
142+ /// <param name="type">The type of the specification (Window or Control).</param>
143+ /// <returns>A collection of statements for the method body.</returns>
114144 private static IEnumerable < StatementSyntax > CreateInitializeContentLayoutBody ( SpecificationType type )
115145 {
116146 var statements = new List < StatementSyntax >
@@ -128,6 +158,11 @@ private static IEnumerable<StatementSyntax> CreateInitializeContentLayoutBody(Sp
128158 return statements ;
129159 }
130160
161+ /// <summary>
162+ /// Creates the body statements for the UpdateContentLayout method.
163+ /// </summary>
164+ /// <param name="type">The type of the specification (Window or Control).</param>
165+ /// <returns>A collection of statements for the method body.</returns>
131166 private static IEnumerable < StatementSyntax > CreateUpdateContentLayoutBody ( SpecificationType type )
132167 {
133168 var statements = new List < StatementSyntax > ( ) ;
@@ -140,6 +175,11 @@ private static IEnumerable<StatementSyntax> CreateUpdateContentLayoutBody(Specif
140175 return statements ;
141176 }
142177
178+ /// <summary>
179+ /// Retrieves the namespace of a given syntax node.
180+ /// </summary>
181+ /// <param name="node">The syntax node to evaluate.</param>
182+ /// <returns>The namespace name as a string.</returns>
143183 private static string GetNamespace ( SyntaxNode node )
144184 {
145185 while ( node != null )
0 commit comments