Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0e507ce9
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0e507ce9
编写于
8月 12, 2018
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update 'use block body' to be better understand async methods.
上级
161765c2
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
201 addition
and
28 deletion
+201
-28
src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForMethodsAnalyzerTests.cs
...Body/Analyzer/UseExpressionBodyForMethodsAnalyzerTests.cs
+156
-0
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForAccessorsHelper.cs
...essionBody/Helpers/UseExpressionBodyForAccessorsHelper.cs
+1
-1
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForConstructorsHelper.cs
...ionBody/Helpers/UseExpressionBodyForConstructorsHelper.cs
+1
-1
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForConversionOperatorsHelper.cs
.../Helpers/UseExpressionBodyForConversionOperatorsHelper.cs
+1
-1
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForIndexersHelper.cs
...ressionBody/Helpers/UseExpressionBodyForIndexersHelper.cs
+3
-3
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForMethodsHelper.cs
...pressionBody/Helpers/UseExpressionBodyForMethodsHelper.cs
+13
-2
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForOperatorsHelper.cs
...essionBody/Helpers/UseExpressionBodyForOperatorsHelper.cs
+1
-1
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForPropertiesHelper.cs
...ssionBody/Helpers/UseExpressionBodyForPropertiesHelper.cs
+4
-3
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs
...able/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs
+1
-1
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs
...le/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs
+12
-9
src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeFixProvider.cs
...ble/UseExpressionBody/UseExpressionBodyCodeFixProvider.cs
+4
-3
src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeRefactoringProvider.cs
...xpressionBody/UseExpressionBodyCodeRefactoringProvider.cs
+4
-3
未找到文件。
src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForMethodsAnalyzerTests.cs
浏览文件 @
0e507ce9
...
...
@@ -504,5 +504,161 @@ void M(int i)
int M(bool b) => 0;
}"
,
options
:
UseExpressionBody
,
parseOptions
:
CSharpParseOptions
.
Default
.
WithLanguageVersion
(
LanguageVersion
.
CSharp6
));
}
[
WorkItem
(
25202
,
"https://github.com/dotnet/roslyn/issues/25202"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseExpressionBody
)]
public
async
Task
TestUseBlockBodyAsync1
()
{
await
TestInRegularAndScriptAsync
(
@"using System.Threading.Tasks;
class C
{
async Task Goo() [|=>|] await Bar();
Task Bar() { }
}"
,
@"using System.Threading.Tasks;
class C
{
async Task Goo()
{
await Bar();
}
Task Bar() { }
}"
,
options
:
UseBlockBody
);
}
[
WorkItem
(
25202
,
"https://github.com/dotnet/roslyn/issues/25202"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseExpressionBody
)]
public
async
Task
TestUseBlockBodyAsync2
()
{
await
TestInRegularAndScriptAsync
(
@"using System.Threading.Tasks;
class C
{
async void Goo() [|=>|] await Bar();
Task Bar() { }
}"
,
@"using System.Threading.Tasks;
class C
{
async void Goo()
{
await Bar();
}
Task Bar() { }
}"
,
options
:
UseBlockBody
);
}
[
WorkItem
(
25202
,
"https://github.com/dotnet/roslyn/issues/25202"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseExpressionBody
)]
public
async
Task
TestUseBlockBodyAsync3
()
{
await
TestInRegularAndScriptAsync
(
@"using System.Threading.Tasks;
class C
{
async void Goo() [|=>|] await Bar();
Task Bar() { }
}"
,
@"using System.Threading.Tasks;
class C
{
async void Goo()
{
await Bar();
}
Task Bar() { }
}"
,
options
:
UseBlockBody
);
}
[
WorkItem
(
25202
,
"https://github.com/dotnet/roslyn/issues/25202"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseExpressionBody
)]
public
async
Task
TestUseBlockBodyAsync4
()
{
await
TestInRegularAndScriptAsync
(
@"using System.Threading.Tasks;
class C
{
async ValueTask Goo() [|=>|] await Bar();
Task Bar() { }
}"
,
@"using System.Threading.Tasks;
class C
{
async ValueTask Goo()
{
await Bar();
}
Task Bar() { }
}"
,
options
:
UseBlockBody
);
}
[
WorkItem
(
25202
,
"https://github.com/dotnet/roslyn/issues/25202"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseExpressionBody
)]
public
async
Task
TestUseBlockBodyAsync5
()
{
await
TestInRegularAndScriptAsync
(
@"using System.Threading.Tasks;
class C
{
async Task<int> Goo() [|=>|] await Bar();
Task<int> Bar() { }
}"
,
@"using System.Threading.Tasks;
class C
{
async Task<int> Goo()
{
return await Bar();
}
Task<int> Bar() { }
}"
,
options
:
UseBlockBody
);
}
[
WorkItem
(
25202
,
"https://github.com/dotnet/roslyn/issues/25202"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseExpressionBody
)]
public
async
Task
TestUseBlockBodyAsync6
()
{
await
TestInRegularAndScriptAsync
(
@"using System.Threading.Tasks;
class C
{
Task Goo() [|=>|] Bar();
Task Bar() { }
}"
,
@"using System.Threading.Tasks;
class C
{
Task Goo()
{
return Bar();
}
Task Bar() { }
}"
,
options
:
UseBlockBody
);
}
}
}
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForAccessorsHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -39,7 +39,7 @@ protected override AccessorDeclarationSyntax WithExpressionBody(AccessorDeclarat
protected
override
AccessorDeclarationSyntax
WithBody
(
AccessorDeclarationSyntax
declaration
,
BlockSyntax
body
)
=>
declaration
.
WithBody
(
body
);
protected
override
bool
CreateReturnStatementForExpression
(
AccessorDeclarationSyntax
declaration
)
protected
override
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
AccessorDeclarationSyntax
declaration
)
=>
declaration
.
IsKind
(
SyntaxKind
.
GetAccessorDeclaration
);
}
}
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForConstructorsHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -39,6 +39,6 @@ protected override ConstructorDeclarationSyntax WithExpressionBody(ConstructorDe
protected
override
ConstructorDeclarationSyntax
WithBody
(
ConstructorDeclarationSyntax
declaration
,
BlockSyntax
body
)
=>
declaration
.
WithBody
(
body
);
protected
override
bool
CreateReturnStatementForExpression
(
ConstructorDeclarationSyntax
declaration
)
=>
false
;
protected
override
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
ConstructorDeclarationSyntax
declaration
)
=>
false
;
}
}
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForConversionOperatorsHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -39,7 +39,7 @@ protected override ConversionOperatorDeclarationSyntax WithExpressionBody(Conver
protected
override
ConversionOperatorDeclarationSyntax
WithBody
(
ConversionOperatorDeclarationSyntax
declaration
,
BlockSyntax
body
)
=>
declaration
.
WithBody
(
body
);
protected
override
bool
CreateReturnStatementForExpression
(
ConversionOperatorDeclarationSyntax
declaration
)
protected
override
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
ConversionOperatorDeclarationSyntax
declaration
)
=>
true
;
}
}
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForIndexersHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -54,12 +54,12 @@ protected override IndexerDeclarationSyntax WithBody(IndexerDeclarationSyntax de
}
protected
override
IndexerDeclarationSyntax
WithGenerateBody
(
IndexerDeclarationSyntax
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
SemanticModel
semanticModel
,
IndexerDeclarationSyntax
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
{
return
WithAccessorList
(
declaration
,
options
,
parseOptions
);
return
WithAccessorList
(
semanticModel
,
declaration
,
options
,
parseOptions
);
}
protected
override
bool
CreateReturnStatementForExpression
(
IndexerDeclarationSyntax
declaration
)
=>
true
;
protected
override
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
IndexerDeclarationSyntax
declaration
)
=>
true
;
protected
override
bool
TryConvertToExpressionBody
(
IndexerDeclarationSyntax
declaration
,
ParseOptions
options
,
...
...
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForMethodsHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -40,7 +40,18 @@ protected override MethodDeclarationSyntax WithExpressionBody(MethodDeclarationS
protected
override
MethodDeclarationSyntax
WithBody
(
MethodDeclarationSyntax
declaration
,
BlockSyntax
body
)
=>
declaration
.
WithBody
(
body
);
protected
override
bool
CreateReturnStatementForExpression
(
MethodDeclarationSyntax
declaration
)
=>
!
declaration
.
ReturnType
.
IsVoid
();
protected
override
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
MethodDeclarationSyntax
declaration
)
{
if
(
declaration
.
Modifiers
.
Any
(
SyntaxKind
.
AsyncKeyword
))
{
// if it's 'async TaskLike' (where TaskLike is non-generic) we do *not* want to
// create a return statement. This is just the 'async' version of a 'void' method.
var
method
=
semanticModel
.
GetDeclaredSymbol
(
declaration
);
return
method
.
ReturnType
is
INamedTypeSymbol
namedType
&&
namedType
.
Arity
!=
0
;
}
return
!
declaration
.
ReturnType
.
IsVoid
();
}
}
}
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForOperatorsHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -39,7 +39,7 @@ protected override OperatorDeclarationSyntax WithExpressionBody(OperatorDeclarat
protected
override
OperatorDeclarationSyntax
WithBody
(
OperatorDeclarationSyntax
declaration
,
BlockSyntax
body
)
=>
declaration
.
WithBody
(
body
);
protected
override
bool
CreateReturnStatementForExpression
(
OperatorDeclarationSyntax
declaration
)
protected
override
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
OperatorDeclarationSyntax
declaration
)
=>
true
;
}
}
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyForPropertiesHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -54,12 +54,13 @@ protected override PropertyDeclarationSyntax WithBody(PropertyDeclarationSyntax
}
protected
override
PropertyDeclarationSyntax
WithGenerateBody
(
PropertyDeclarationSyntax
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
SemanticModel
semanticModel
,
PropertyDeclarationSyntax
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
{
return
WithAccessorList
(
declaration
,
options
,
parseOptions
);
return
WithAccessorList
(
semanticModel
,
declaration
,
options
,
parseOptions
);
}
protected
override
bool
CreateReturnStatementForExpression
(
PropertyDeclarationSyntax
declaration
)
=>
true
;
protected
override
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
PropertyDeclarationSyntax
declaration
)
=>
true
;
protected
override
bool
TryConvertToExpressionBody
(
PropertyDeclarationSyntax
declaration
,
ParseOptions
options
,
...
...
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs
浏览文件 @
0e507ce9
...
...
@@ -21,7 +21,7 @@ internal abstract class UseExpressionBodyHelper
public
abstract
bool
CanOfferUseExpressionBody
(
OptionSet
optionSet
,
SyntaxNode
declaration
,
bool
forAnalyzer
);
public
abstract
(
bool
canOffer
,
bool
fixesError
)
CanOfferUseBlockBody
(
OptionSet
optionSet
,
SyntaxNode
declaration
,
bool
forAnalyzer
);
public
abstract
SyntaxNode
Update
(
SyntaxNode
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
,
bool
useExpressionBody
);
public
abstract
SyntaxNode
Update
(
S
emanticModel
semanticModel
,
S
yntaxNode
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
,
bool
useExpressionBody
);
public
abstract
Location
GetDiagnosticLocation
(
SyntaxNode
declaration
);
...
...
src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs
浏览文件 @
0e507ce9
...
...
@@ -69,8 +69,8 @@ public override bool CanOfferUseExpressionBody(OptionSet optionSet, SyntaxNode d
public
override
(
bool
canOffer
,
bool
fixesError
)
CanOfferUseBlockBody
(
OptionSet
optionSet
,
SyntaxNode
declaration
,
bool
forAnalyzer
)
=>
CanOfferUseBlockBody
(
optionSet
,
(
TDeclaration
)
declaration
,
forAnalyzer
);
public
override
SyntaxNode
Update
(
SyntaxNode
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
,
bool
useExpressionBody
)
=>
Update
((
TDeclaration
)
declaration
,
options
,
parseOptions
,
useExpressionBody
);
public
sealed
override
SyntaxNode
Update
(
SemanticModel
semanticModel
,
SyntaxNode
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
,
bool
useExpressionBody
)
=>
Update
(
semanticModel
,
(
TDeclaration
)
declaration
,
options
,
parseOptions
,
useExpressionBody
);
public
override
Location
GetDiagnosticLocation
(
SyntaxNode
declaration
)
=>
GetDiagnosticLocation
((
TDeclaration
)
declaration
);
...
...
@@ -207,7 +207,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
}
public
TDeclaration
Update
(
TDeclaration
declaration
,
OptionSet
options
,
SemanticModel
semanticModel
,
TDeclaration
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
,
bool
useExpressionBody
)
{
if
(
useExpressionBody
)
...
...
@@ -231,7 +231,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
{
return
WithSemicolonToken
(
WithExpressionBody
(
WithGenerateBody
(
declaration
,
options
,
parseOptions
),
WithGenerateBody
(
semanticModel
,
declaration
,
options
,
parseOptions
),
expressionBody
:
null
),
default
);
}
...
...
@@ -241,7 +241,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
protected
abstract
ArrowExpressionClauseSyntax
GetExpressionBody
(
TDeclaration
declaration
);
protected
abstract
bool
CreateReturnStatementForExpression
(
TDeclaration
declaration
);
protected
abstract
bool
CreateReturnStatementForExpression
(
SemanticModel
semanticModel
,
TDeclaration
declaration
);
protected
abstract
SyntaxToken
GetSemicolonToken
(
TDeclaration
declaration
);
...
...
@@ -250,14 +250,14 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
protected
abstract
TDeclaration
WithBody
(
TDeclaration
declaration
,
BlockSyntax
body
);
protected
virtual
TDeclaration
WithGenerateBody
(
TDeclaration
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
SemanticModel
semanticModel
,
TDeclaration
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
{
var
expressionBody
=
GetExpressionBody
(
declaration
);
var
semicolonToken
=
GetSemicolonToken
(
declaration
);
if
(
expressionBody
.
TryConvertToBlock
(
GetSemicolonToken
(
declaration
),
CreateReturnStatementForExpression
(
declaration
),
CreateReturnStatementForExpression
(
semanticModel
,
declaration
),
out
var
block
))
{
return
WithBody
(
declaration
,
block
);
...
...
@@ -267,7 +267,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
}
protected
TDeclaration
WithAccessorList
(
TDeclaration
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
SemanticModel
semanticModel
,
TDeclaration
declaration
,
OptionSet
options
,
ParseOptions
parseOptions
)
{
var
expressionBody
=
GetExpressionBody
(
declaration
);
var
semicolonToken
=
GetSemicolonToken
(
declaration
);
...
...
@@ -280,7 +280,10 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
// an expression bodied accessor they'll just have to convert that to a block as well
// and that means two steps to take instead of one.
expressionBody
.
TryConvertToBlock
(
GetSemicolonToken
(
declaration
),
CreateReturnStatementForExpression
(
declaration
),
out
var
block
);
expressionBody
.
TryConvertToBlock
(
GetSemicolonToken
(
declaration
),
CreateReturnStatementForExpression
(
semanticModel
,
declaration
),
out
var
block
);
var
accessor
=
SyntaxFactory
.
AccessorDeclaration
(
SyntaxKind
.
GetAccessorDeclaration
);
accessor
=
block
!=
null
...
...
src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeFixProvider.cs
浏览文件 @
0e507ce9
...
...
@@ -52,13 +52,14 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
Document
document
,
ImmutableArray
<
Diagnostic
>
diagnostics
,
SyntaxEditor
editor
,
CancellationToken
cancellationToken
)
{
var
semanticModel
=
await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
options
=
await
document
.
GetOptionsAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
accessorLists
=
new
HashSet
<
AccessorListSyntax
>();
foreach
(
var
diagnostic
in
diagnostics
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
AddEdits
(
editor
,
diagnostic
,
options
,
accessorLists
,
cancellationToken
);
AddEdits
(
semanticModel
,
editor
,
diagnostic
,
options
,
accessorLists
,
cancellationToken
);
}
// Ensure that if we changed any accessors that the accessor lists they're contained
...
...
@@ -71,7 +72,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
}
private
void
AddEdits
(
SyntaxEditor
editor
,
Diagnostic
diagnostic
,
S
emanticModel
semanticModel
,
S
yntaxEditor
editor
,
Diagnostic
diagnostic
,
OptionSet
options
,
HashSet
<
AccessorListSyntax
>
accessorLists
,
CancellationToken
cancellationToken
)
{
...
...
@@ -81,7 +82,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
var
useExpressionBody
=
diagnostic
.
Properties
.
ContainsKey
(
nameof
(
UseExpressionBody
));
var
parseOptions
=
declaration
.
SyntaxTree
.
Options
;
var
updatedDeclaration
=
helper
.
Update
(
declaration
,
options
,
parseOptions
,
useExpressionBody
)
var
updatedDeclaration
=
helper
.
Update
(
semanticModel
,
declaration
,
options
,
parseOptions
,
useExpressionBody
)
.
WithAdditionalAnnotations
(
Formatter
.
Annotation
);
editor
.
ReplaceNode
(
declaration
,
updatedDeclaration
);
...
...
src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeRefactoringProvider.cs
浏览文件 @
0e507ce9
...
...
@@ -116,13 +116,14 @@ private SyntaxNode GetDeclaration(SyntaxNode node, UseExpressionBodyHelper helpe
return
null
;
}
private
Task
<
Document
>
UpdateDocumentAsync
(
private
async
Task
<
Document
>
UpdateDocumentAsync
(
Document
document
,
SyntaxNode
root
,
SyntaxNode
declaration
,
OptionSet
options
,
UseExpressionBodyHelper
helper
,
bool
useExpressionBody
,
CancellationToken
cancellationToken
)
{
var
parseOptions
=
root
.
SyntaxTree
.
Options
;
var
updatedDeclaration
=
helper
.
Update
(
declaration
,
options
,
parseOptions
,
useExpressionBody
);
var
semanticModel
=
await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
updatedDeclaration
=
helper
.
Update
(
semanticModel
,
declaration
,
options
,
parseOptions
,
useExpressionBody
);
var
parent
=
declaration
is
AccessorDeclarationSyntax
?
declaration
.
Parent
...
...
@@ -131,7 +132,7 @@ private SyntaxNode GetDeclaration(SyntaxNode node, UseExpressionBodyHelper helpe
.
WithAdditionalAnnotations
(
Formatter
.
Annotation
);
var
newRoot
=
root
.
ReplaceNode
(
parent
,
updatedParent
);
return
Task
.
FromResult
(
document
.
WithSyntaxRoot
(
newRoot
)
);
return
document
.
WithSyntaxRoot
(
newRoot
);
}
private
class
MyCodeAction
:
CodeAction
.
DocumentChangeAction
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录