File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -203,11 +203,32 @@ propertySymbol is INamedTypeSymbol typeSymbol &&
203
203
}
204
204
else
205
205
{
206
- diagnostics . Add (
206
+ bool isTargetValid = false ;
207
+
208
+ // Check for generated commands too
209
+ foreach ( ISymbol member in fieldSymbol . ContainingType . GetMembers ( ) )
210
+ {
211
+ if ( member is IMethodSymbol methodSymbol &&
212
+ methodSymbol . HasAttributeWithFullyQualifiedName ( "global::CommunityToolkit.Mvvm.Input.ICommandAttribute" ) &&
213
+ commandName == ICommandGenerator . Execute . GetGeneratedFieldAndPropertyNames ( methodSymbol ) . PropertyName )
214
+ {
215
+ notifiedCommandNames . Add ( commandName ) ;
216
+
217
+ isTargetValid = true ;
218
+
219
+ break ;
220
+ }
221
+ }
222
+
223
+ // Add the diagnostic if the target is definitely invalid
224
+ if ( ! isTargetValid )
225
+ {
226
+ diagnostics . Add (
207
227
AlsoNotifyCanExecuteForInvalidTargetError ,
208
228
fieldSymbol ,
209
229
commandName ?? "" ,
210
230
fieldSymbol . ContainingType ) ;
231
+ }
211
232
}
212
233
}
213
234
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ partial class ICommandGenerator
23
23
/// <summary>
24
24
/// A container for all the logic for <see cref="ICommandGenerator"/>.
25
25
/// </summary>
26
- private static class Execute
26
+ internal static class Execute
27
27
{
28
28
/// <summary>
29
29
/// Processes a given target method.
@@ -305,7 +305,7 @@ public static ImmutableArray<MemberDeclarationSyntax> GetSyntax(CommandInfo comm
305
305
/// </summary>
306
306
/// <param name="methodSymbol">The input <see cref="IMethodSymbol"/> instance to process.</param>
307
307
/// <returns>The generated field and property names for <paramref name="methodSymbol"/>.</returns>
308
- private static ( string FieldName , string PropertyName ) GetGeneratedFieldAndPropertyNames ( IMethodSymbol methodSymbol )
308
+ public static ( string FieldName , string PropertyName ) GetGeneratedFieldAndPropertyNames ( IMethodSymbol methodSymbol )
309
309
{
310
310
string propertyName = methodSymbol . Name ;
311
311
You can’t perform that action at this time.
0 commit comments