Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
CommunityToolkit.Dotnet
提交
c6eedeea
C
CommunityToolkit.Dotnet
项目概览
jobily
/
CommunityToolkit.Dotnet
9 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
CommunityToolkit.Dotnet
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c6eedeea
编写于
6月 08, 2023
作者:
S
Sergio Pedri
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid passing properties to async void [RelayCommand] fixer
上级
ce23265d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1 addition
and
15 deletion
+1
-15
src/CommunityToolkit.Mvvm.CodeFixers/AsyncVoidReturningRelayCommandMethodCodeFixer.cs
...deFixers/AsyncVoidReturningRelayCommandMethodCodeFixer.cs
+1
-9
src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/AsyncVoidReturningRelayCommandMethodAnalyzer.cs
...Analyzers/AsyncVoidReturningRelayCommandMethodAnalyzer.cs
+0
-6
未找到文件。
src/CommunityToolkit.Mvvm.CodeFixers/AsyncVoidReturningRelayCommandMethodCodeFixer.cs
浏览文件 @
c6eedeea
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
using
System.Composition
;
using
System.Composition
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
CommunityToolkit.Mvvm.SourceGenerators
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CodeActions
;
using
Microsoft.CodeAnalysis.CodeActions
;
using
Microsoft.CodeAnalysis.CodeFixes
;
using
Microsoft.CodeAnalysis.CodeFixes
;
...
@@ -40,17 +39,10 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
...
@@ -40,17 +39,10 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
Diagnostic
diagnostic
=
context
.
Diagnostics
[
0
];
Diagnostic
diagnostic
=
context
.
Diagnostics
[
0
];
TextSpan
diagnosticSpan
=
context
.
Span
;
TextSpan
diagnosticSpan
=
context
.
Span
;
// Retrieve the property passed by the analyzer
if
(
diagnostic
.
Properties
[
AsyncVoidReturningRelayCommandMethodAnalyzer
.
MethodNameKey
]
is
not
string
methodName
)
{
return
;
}
SyntaxNode
?
root
=
await
context
.
Document
.
GetSyntaxRootAsync
(
context
.
CancellationToken
).
ConfigureAwait
(
false
);
SyntaxNode
?
root
=
await
context
.
Document
.
GetSyntaxRootAsync
(
context
.
CancellationToken
).
ConfigureAwait
(
false
);
// Get the method declaration from the target diagnostic
// Get the method declaration from the target diagnostic
if
(
root
!.
FindNode
(
diagnosticSpan
)
is
MethodDeclarationSyntax
{
Identifier
.
Text
:
string
identifierName
}
methodDeclaration
&&
if
(
root
!.
FindNode
(
diagnosticSpan
)
is
MethodDeclarationSyntax
methodDeclaration
)
identifierName
==
methodName
)
{
{
// Register the code fix to update the return type to be Task instead
// Register the code fix to update the return type to be Task instead
context
.
RegisterCodeFix
(
context
.
RegisterCodeFix
(
...
...
src/CommunityToolkit.Mvvm.SourceGenerators/Diagnostics/Analyzers/AsyncVoidReturningRelayCommandMethodAnalyzer.cs
浏览文件 @
c6eedeea
...
@@ -17,11 +17,6 @@ namespace CommunityToolkit.Mvvm.SourceGenerators;
...
@@ -17,11 +17,6 @@ namespace CommunityToolkit.Mvvm.SourceGenerators;
[
DiagnosticAnalyzer
(
LanguageNames
.
CSharp
)]
[
DiagnosticAnalyzer
(
LanguageNames
.
CSharp
)]
public
sealed
class
AsyncVoidReturningRelayCommandMethodAnalyzer
:
DiagnosticAnalyzer
public
sealed
class
AsyncVoidReturningRelayCommandMethodAnalyzer
:
DiagnosticAnalyzer
{
{
/// <summary>
/// The key for the name of the target method to update.
/// </summary>
internal
const
string
MethodNameKey
=
"MethodName"
;
/// <inheritdoc/>
/// <inheritdoc/>
public
override
ImmutableArray
<
DiagnosticDescriptor
>
SupportedDiagnostics
{
get
;
}
=
ImmutableArray
.
Create
(
AsyncVoidReturningRelayCommandMethod
);
public
override
ImmutableArray
<
DiagnosticDescriptor
>
SupportedDiagnostics
{
get
;
}
=
ImmutableArray
.
Create
(
AsyncVoidReturningRelayCommandMethod
);
...
@@ -57,7 +52,6 @@ public override void Initialize(AnalysisContext context)
...
@@ -57,7 +52,6 @@ public override void Initialize(AnalysisContext context)
context
.
ReportDiagnostic
(
Diagnostic
.
Create
(
context
.
ReportDiagnostic
(
Diagnostic
.
Create
(
AsyncVoidReturningRelayCommandMethod
,
AsyncVoidReturningRelayCommandMethod
,
context
.
Symbol
.
Locations
.
FirstOrDefault
(),
context
.
Symbol
.
Locations
.
FirstOrDefault
(),
ImmutableDictionary
.
Create
<
string
,
string
?>().
Add
(
MethodNameKey
,
methodSymbol
.
Name
),
context
.
Symbol
));
context
.
Symbol
));
},
SymbolKind
.
Method
);
},
SymbolKind
.
Method
);
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录