4
4
5
5
using System . Collections . Immutable ;
6
6
using System . Linq ;
7
+ using CommunityToolkit . Mvvm . SourceGenerators . ComponentModel . Models ;
7
8
using CommunityToolkit . Mvvm . SourceGenerators . Extensions ;
8
9
using CommunityToolkit . Mvvm . SourceGenerators . Helpers ;
9
10
using CommunityToolkit . Mvvm . SourceGenerators . Messaging . Models ;
@@ -74,6 +75,9 @@ public static CompilationUnitSyntax GetSyntax(bool isDynamicallyAccessedMembersA
74
75
75
76
// Prepare the base attributes with are always present:
76
77
//
78
+ // /// <summary>
79
+ // /// A helper type with generated registration stubs for types implementing <see cref="global::CommunityToolkit.Mvvm.Messaging.IRecipient{T}"/>.
80
+ // /// </summary>
77
81
// [global::System.CodeDom.Compiler.GeneratedCode("...", "...")]
78
82
// [global::System.Diagnostics.DebuggerNonUserCode]
79
83
// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
@@ -83,7 +87,11 @@ public static CompilationUnitSyntax GetSyntax(bool isDynamicallyAccessedMembersA
83
87
AttributeList ( SingletonSeparatedList (
84
88
Attribute ( IdentifierName ( $ "global::System.CodeDom.Compiler.GeneratedCode") ) . AddArgumentListArguments (
85
89
AttributeArgument ( LiteralExpression ( SyntaxKind . StringLiteralExpression , Literal ( typeof ( IMessengerRegisterAllGenerator ) . FullName ) ) ) ,
86
- AttributeArgument ( LiteralExpression ( SyntaxKind . StringLiteralExpression , Literal ( typeof ( IMessengerRegisterAllGenerator ) . Assembly . GetName ( ) . Version . ToString ( ) ) ) ) ) ) ) ) ;
90
+ AttributeArgument ( LiteralExpression ( SyntaxKind . StringLiteralExpression , Literal ( typeof ( IMessengerRegisterAllGenerator ) . Assembly . GetName ( ) . Version . ToString ( ) ) ) ) ) ) )
91
+ . WithOpenBracketToken ( Token ( TriviaList (
92
+ Comment ( "/// <summary>" ) ,
93
+ Comment ( "/// A helper type with generated registration stubs for types implementing <see cref=\" global::CommunityToolkit.Mvvm.Messaging.IRecipient{T}\" />." ) ,
94
+ Comment ( "/// </summary>" ) ) , SyntaxKind . OpenBracketToken , TriviaList ( ) ) ) ) ;
87
95
attributes . Add ( AttributeList ( SingletonSeparatedList ( Attribute ( IdentifierName ( "global::System.Diagnostics.DebuggerNonUserCode" ) ) ) ) ) ;
88
96
attributes . Add ( AttributeList ( SingletonSeparatedList ( Attribute ( IdentifierName ( "global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage" ) ) ) ) ) ;
89
97
attributes . Add (
@@ -146,6 +154,11 @@ public static CompilationUnitSyntax GetSyntax(RecipientInfo recipientInfo)
146
154
// with no tokens, which is the most common scenario and will help particularly with AOT.
147
155
// This code will produce a syntax tree as follows:
148
156
//
157
+ // /// <summary>
158
+ // /// Creates a message registration stub for <see cref="<RECIPIENT_TYPE>"/> objects.
159
+ // /// </summary>
160
+ // /// <param name="_">Dummy parameter, only used to disambiguate the method signature.</param>
161
+ // /// <returns>A message registration stub for <see cref="<RECIPIENT_TYPE>"/> objects.</returns>
149
162
// [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
150
163
// [global::System.Obsolete("This method is not intended to be called directly by user code")]
151
164
// public static global::System.Action<global::CommunityToolkit.Mvvm.Messaging.IMessenger, object> CreateAllMessagesRegistrator(<RECIPIENT_TYPE> _)
@@ -166,7 +179,13 @@ public static CompilationUnitSyntax GetSyntax(RecipientInfo recipientInfo)
166
179
Identifier ( "CreateAllMessagesRegistrator" ) ) . AddAttributeLists (
167
180
AttributeList ( SingletonSeparatedList (
168
181
Attribute ( IdentifierName ( "global::System.ComponentModel.EditorBrowsable" ) ) . AddArgumentListArguments (
169
- AttributeArgument ( ParseExpression ( "global::System.ComponentModel.EditorBrowsableState.Never" ) ) ) ) ) ,
182
+ AttributeArgument ( ParseExpression ( "global::System.ComponentModel.EditorBrowsableState.Never" ) ) ) ) )
183
+ . WithOpenBracketToken ( Token ( TriviaList (
184
+ Comment ( "/// <summary>" ) ,
185
+ Comment ( $ "/// Creates a message registration stub for <see cref=\" { recipientInfo . TypeName } \" /> objects.") ,
186
+ Comment ( "/// </summary>" ) ,
187
+ Comment ( "/// <param name=\" _\" >Dummy parameter, only used to disambiguate the method signature.</param>" ) ,
188
+ Comment ( $ "/// <returns>A message registration stub for <see cref=\" { recipientInfo . TypeName } \" /> objects.</returns>") ) , SyntaxKind . OpenBracketToken , TriviaList ( ) ) ) ,
170
189
AttributeList ( SingletonSeparatedList (
171
190
Attribute ( IdentifierName ( "global::System.Obsolete" ) ) . AddArgumentListArguments (
172
191
AttributeArgument ( LiteralExpression (
@@ -199,6 +218,12 @@ public static CompilationUnitSyntax GetSyntax(RecipientInfo recipientInfo)
199
218
// Note: the generic overload has a different name to simplify the lookup with reflection.
200
219
// This code will produce a syntax tree as follows:
201
220
//
221
+ // /// <summary>
222
+ // /// Creates a message registration stub for <see cref="<RECIPIENT_TYPE>"/> objects, with an input token.
223
+ // /// </summary>
224
+ // /// <typeparam name="TToken">The type of tokens that will be used to register messages.
225
+ // /// <param name="_">Dummy parameter, only used to disambiguate the method signature.</param>
226
+ // /// <returns>A message registration stub for <see cref="<RECIPIENT_TYPE>"/> objects.</returns>
202
227
// [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
203
228
// [global::System.Obsolete("This method is not intended to be called directly by user code")]
204
229
// public static global::System.Action<global::CommunityToolkit.Mvvm.Messaging.IMessenger, object, TToken> CreateAllMessagesRegistratorWithToken<TToken>(<RECIPIENT_TYPE> _)
@@ -221,7 +246,14 @@ public static CompilationUnitSyntax GetSyntax(RecipientInfo recipientInfo)
221
246
Identifier ( "CreateAllMessagesRegistratorWithToken" ) ) . AddAttributeLists (
222
247
AttributeList ( SingletonSeparatedList (
223
248
Attribute ( IdentifierName ( "global::System.ComponentModel.EditorBrowsable" ) ) . AddArgumentListArguments (
224
- AttributeArgument ( ParseExpression ( "global::System.ComponentModel.EditorBrowsableState.Never" ) ) ) ) ) ,
249
+ AttributeArgument ( ParseExpression ( "global::System.ComponentModel.EditorBrowsableState.Never" ) ) ) ) )
250
+ . WithOpenBracketToken ( Token ( TriviaList (
251
+ Comment ( "/// <summary>" ) ,
252
+ Comment ( $ "/// Creates a message registration stub for <see cref=\" { recipientInfo . TypeName } \" /> objects.") ,
253
+ Comment ( "/// </summary>" ) ,
254
+ Comment ( "/// <typeparam name=\" TToken\" >The type of tokens that will be used to register messages.</typeparam>" ) ,
255
+ Comment ( "/// <param name=\" _\" >Dummy parameter, only used to disambiguate the method signature.</param>" ) ,
256
+ Comment ( $ "/// <returns>A message registration stub for <see cref=\" { recipientInfo . TypeName } \" /> objects.</returns>") ) , SyntaxKind . OpenBracketToken , TriviaList ( ) ) ) ,
225
257
AttributeList ( SingletonSeparatedList (
226
258
Attribute ( IdentifierName ( "global::System.Obsolete" ) ) . AddArgumentListArguments (
227
259
AttributeArgument ( LiteralExpression (
@@ -261,6 +293,7 @@ public static CompilationUnitSyntax GetSyntax(RecipientInfo recipientInfo)
261
293
// #pragma warning disable
262
294
// namespace CommunityToolkit.Mvvm.Messaging.__Internals
263
295
// {
296
+ // /// <inheritdoc/>
264
297
// partial class __IMessengerExtensions
265
298
// {
266
299
// <GENERATED_MEMBERS>
@@ -271,7 +304,8 @@ public static CompilationUnitSyntax GetSyntax(RecipientInfo recipientInfo)
271
304
NamespaceDeclaration ( IdentifierName ( "CommunityToolkit.Mvvm.Messaging.__Internals" ) ) . WithLeadingTrivia ( TriviaList (
272
305
Comment ( "// <auto-generated/>" ) ,
273
306
Trivia ( PragmaWarningDirectiveTrivia ( Token ( SyntaxKind . DisableKeyword ) , true ) ) ) ) . AddMembers (
274
- ClassDeclaration ( "__IMessengerExtensions" ) . AddModifiers ( Token ( SyntaxKind . PartialKeyword ) )
307
+ ClassDeclaration ( "__IMessengerExtensions" ) . AddModifiers (
308
+ Token ( TriviaList ( Comment ( "/// <inheritdoc/>" ) ) , SyntaxKind . PartialKeyword , TriviaList ( ) ) )
275
309
. AddMembers ( defaultChannelMethodDeclaration , customChannelMethodDeclaration ) ) )
276
310
. NormalizeWhitespace ( ) ;
277
311
}
0 commit comments