File tree Expand file tree Collapse file tree 2 files changed +1
-15
lines changed Expand file tree Collapse file tree 2 files changed +1
-15
lines changed Original file line number Diff line number Diff line change 6
6
using System . Composition ;
7
7
using System . Threading ;
8
8
using System . Threading . Tasks ;
9
- using CommunityToolkit . Mvvm . SourceGenerators ;
10
9
using Microsoft . CodeAnalysis ;
11
10
using Microsoft . CodeAnalysis . CodeActions ;
12
11
using Microsoft . CodeAnalysis . CodeFixes ;
@@ -40,17 +39,10 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
40
39
Diagnostic diagnostic = context . Diagnostics [ 0 ] ;
41
40
TextSpan diagnosticSpan = context . Span ;
42
41
43
- // Retrieve the property passed by the analyzer
44
- if ( diagnostic . Properties [ AsyncVoidReturningRelayCommandMethodAnalyzer . MethodNameKey ] is not string methodName )
45
- {
46
- return ;
47
- }
48
-
49
42
SyntaxNode ? root = await context . Document . GetSyntaxRootAsync ( context . CancellationToken ) . ConfigureAwait ( false ) ;
50
43
51
44
// Get the method declaration from the target diagnostic
52
- if ( root ! . FindNode ( diagnosticSpan ) is MethodDeclarationSyntax { Identifier . Text : string identifierName } methodDeclaration &&
53
- identifierName == methodName )
45
+ if ( root ! . FindNode ( diagnosticSpan ) is MethodDeclarationSyntax methodDeclaration )
54
46
{
55
47
// Register the code fix to update the return type to be Task instead
56
48
context . RegisterCodeFix (
Original file line number Diff line number Diff line change @@ -17,11 +17,6 @@ namespace CommunityToolkit.Mvvm.SourceGenerators;
17
17
[ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
18
18
public sealed class AsyncVoidReturningRelayCommandMethodAnalyzer : DiagnosticAnalyzer
19
19
{
20
- /// <summary>
21
- /// The key for the name of the target method to update.
22
- /// </summary>
23
- internal const string MethodNameKey = "MethodName" ;
24
-
25
20
/// <inheritdoc/>
26
21
public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics { get ; } = ImmutableArray . Create ( AsyncVoidReturningRelayCommandMethod ) ;
27
22
@@ -57,7 +52,6 @@ public override void Initialize(AnalysisContext context)
57
52
context . ReportDiagnostic ( Diagnostic . Create (
58
53
AsyncVoidReturningRelayCommandMethod ,
59
54
context . Symbol . Locations . FirstOrDefault ( ) ,
60
- ImmutableDictionary . Create < string , string ? > ( ) . Add ( MethodNameKey , methodSymbol . Name ) ,
61
55
context . Symbol ) ) ;
62
56
} , SymbolKind . Method ) ;
63
57
} ) ;
You can’t perform that action at this time.
0 commit comments