Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ffad2b58
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,发现更多精彩内容 >>
提交
ffad2b58
编写于
3月 22, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Working, with tests.
上级
eff5e315
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
255 addition
and
127 deletion
+255
-127
src/EditorFeatures/CSharpTest/InitializeParameter/InitializeMemberFromParameterTests.cs
...InitializeParameter/InitializeMemberFromParameterTests.cs
+121
-0
src/Features/CSharp/Portable/InitializeParameter/CSharpAddParameterCheckCodeRefactoringProvider.cs
...rameter/CSharpAddParameterCheckCodeRefactoringProvider.cs
+2
-2
src/Features/CSharp/Portable/InitializeParameter/CSharpInitializeMemberFromParameterCodeRefactoringProvider.cs
...rpInitializeMemberFromParameterCodeRefactoringProvider.cs
+3
-2
src/Features/CSharp/Portable/InitializeParameter/InitializeParameterHelpers.cs
...ortable/InitializeParameter/InitializeParameterHelpers.cs
+2
-2
src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs
...meter/AbstractAddParameterCheckCodeRefactoringProvider.cs
+1
-1
src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs
...mberFromParameterCodeRefactoringProviderMemberCreation.cs
+122
-117
src/Features/Core/Portable/InitializeParameter/AbstractInitializeParameterCodeRefactoringProvider.cs
...ter/AbstractInitializeParameterCodeRefactoringProvider.cs
+1
-1
src/Features/VisualBasic/Portable/InitializeParameter/VisualBasicAddParameterCheckCodeRefactoringProvider.vb
...er/VisualBasicAddParameterCheckCodeRefactoringProvider.vb
+1
-1
src/Features/VisualBasic/Portable/InitializeParameter/VisualBasicInitializeMemberFromParameterCodeRefactoringProvider.vb
...icInitializeMemberFromParameterCodeRefactoringProvider.vb
+2
-1
未找到文件。
src/EditorFeatures/CSharpTest/InitializeParameter/InitializeMemberFromParameterTests.cs
浏览文件 @
ffad2b58
...
...
@@ -1618,5 +1618,126 @@ public C(int i, string s)
}
}"
);
}
[
WorkItem
(
35665
,
"https://github.com/dotnet/roslyn/issues/35665"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsInitializeParameter
)]
public
async
Task
TestGenerateRemainingFields1
()
{
await
TestInRegularAndScript1Async
(
@"
class C
{
public C([||]int i, int j, int k)
{
}
}"
,
@"
class C
{
private readonly int i;
private readonly int j;
private readonly int k;
public C(int i, int j, int k)
{
this.i = i;
this.j = j;
this.k = k;
}
}"
,
index
:
3
);
}
[
WorkItem
(
35665
,
"https://github.com/dotnet/roslyn/issues/35665"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsInitializeParameter
)]
public
async
Task
TestGenerateRemainingFields2
()
{
await
TestInRegularAndScript1Async
(
@"
class C
{
private readonly int i;
public C(int i, [||]int j, int k)
{
this.i = i;
}
}"
,
@"
class C
{
private readonly int i;
private readonly int j;
private readonly int k;
public C(int i, int j, int k)
{
this.i = i;
this.j = j;
this.k = k;
}
}"
,
index
:
2
);
}
[
WorkItem
(
35665
,
"https://github.com/dotnet/roslyn/issues/35665"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsInitializeParameter
)]
public
async
Task
TestGenerateRemainingFields3
()
{
await
TestInRegularAndScript1Async
(
@"
class C
{
private readonly int j;
public C([||]int i, int j, int k)
{
this.j = j;
}
}"
,
@"
class C
{
private readonly int i;
private readonly int j;
private readonly int k;
public C(int i, int j, int k)
{
this.i = i;
this.j = j;
this.k = k;
}
}"
,
index
:
2
);
}
[
WorkItem
(
35665
,
"https://github.com/dotnet/roslyn/issues/35665"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsInitializeParameter
)]
public
async
Task
TestGenerateRemainingFields4
()
{
await
TestInRegularAndScript1Async
(
@"
class C
{
private readonly int k;
public C([||]int i, int j, int k)
{
this.k = k;
}
}"
,
@"
class C
{
private readonly int i;
private readonly int j;
private readonly int k;
public C(int i, int j, int k)
{
this.i = i;
this.j = j;
this.k = k;
}
}"
,
index
:
2
);
}
}
}
src/Features/CSharp/Portable/InitializeParameter/CSharpAddParameterCheckCodeRefactoringProvider.cs
浏览文件 @
ffad2b58
...
...
@@ -35,8 +35,8 @@ protected override SyntaxNode GetTypeBlock(SyntaxNode node)
protected
override
SyntaxNode
GetBody
(
SyntaxNode
functionDeclaration
)
=>
InitializeParameterHelpers
.
GetBody
(
functionDeclaration
);
protected
override
void
InsertStatement
(
SyntaxEditor
editor
,
SyntaxNode
functionDeclaration
,
IMethodSymbol
metho
d
,
SyntaxNode
statementToAddAfterOpt
,
StatementSyntax
statement
)
=>
InitializeParameterHelpers
.
InsertStatement
(
editor
,
functionDeclaration
,
metho
d
,
statementToAddAfterOpt
,
statement
);
protected
override
void
InsertStatement
(
SyntaxEditor
editor
,
SyntaxNode
functionDeclaration
,
bool
returnsVoi
d
,
SyntaxNode
statementToAddAfterOpt
,
StatementSyntax
statement
)
=>
InitializeParameterHelpers
.
InsertStatement
(
editor
,
functionDeclaration
,
returnsVoi
d
,
statementToAddAfterOpt
,
statement
);
protected
override
bool
IsImplicitConversion
(
Compilation
compilation
,
ITypeSymbol
source
,
ITypeSymbol
destination
)
=>
InitializeParameterHelpers
.
IsImplicitConversion
(
compilation
,
source
,
destination
);
...
...
src/Features/CSharp/Portable/InitializeParameter/CSharpInitializeMemberFromParameterCodeRefactoringProvider.cs
浏览文件 @
ffad2b58
...
...
@@ -16,6 +16,7 @@ namespace Microsoft.CodeAnalysis.CSharp.InitializeParameter
[
ExtensionOrder
(
Before
=
PredefinedCodeRefactoringProviderNames
.
Wrapping
)]
internal
class
CSharpInitializeMemberFromParameterCodeRefactoringProvider
:
AbstractInitializeMemberFromParameterCodeRefactoringProvider
<
BaseTypeDeclarationSyntax
,
ParameterSyntax
,
StatementSyntax
,
ExpressionSyntax
>
...
...
@@ -34,8 +35,8 @@ protected override SyntaxNode GetTypeBlock(SyntaxNode node)
protected
override
SyntaxNode
TryGetLastStatement
(
IBlockOperation
blockStatementOpt
)
=>
InitializeParameterHelpers
.
TryGetLastStatement
(
blockStatementOpt
);
protected
override
void
InsertStatement
(
SyntaxEditor
editor
,
SyntaxNode
functionDeclaration
,
IMethodSymbol
metho
d
,
SyntaxNode
statementToAddAfterOpt
,
StatementSyntax
statement
)
=>
InitializeParameterHelpers
.
InsertStatement
(
editor
,
functionDeclaration
,
metho
d
,
statementToAddAfterOpt
,
statement
);
protected
override
void
InsertStatement
(
SyntaxEditor
editor
,
SyntaxNode
functionDeclaration
,
bool
returnsVoi
d
,
SyntaxNode
statementToAddAfterOpt
,
StatementSyntax
statement
)
=>
InitializeParameterHelpers
.
InsertStatement
(
editor
,
functionDeclaration
,
returnsVoi
d
,
statementToAddAfterOpt
,
statement
);
protected
override
bool
IsImplicitConversion
(
Compilation
compilation
,
ITypeSymbol
source
,
ITypeSymbol
destination
)
=>
InitializeParameterHelpers
.
IsImplicitConversion
(
compilation
,
source
,
destination
);
...
...
src/Features/CSharp/Portable/InitializeParameter/InitializeParameterHelpers.cs
浏览文件 @
ffad2b58
...
...
@@ -62,7 +62,7 @@ public static SyntaxNode TryGetLastStatement(IBlockOperation blockStatementOpt)
public
static
void
InsertStatement
(
SyntaxEditor
editor
,
SyntaxNode
functionDeclaration
,
IMethodSymbol
metho
d
,
bool
returnsVoi
d
,
SyntaxNode
statementToAddAfterOpt
,
StatementSyntax
statement
)
{
...
...
@@ -72,7 +72,7 @@ public static SyntaxNode TryGetLastStatement(IBlockOperation blockStatementOpt)
{
var
semicolonToken
=
TryGetSemicolonToken
(
functionDeclaration
)
??
SyntaxFactory
.
Token
(
SyntaxKind
.
SemicolonToken
);
if
(!
TryConvertExpressionBodyToStatement
(
body
,
semicolonToken
,
!
method
.
R
eturnsVoid
,
out
var
convertedStatement
))
if
(!
TryConvertExpressionBodyToStatement
(
body
,
semicolonToken
,
!
r
eturnsVoid
,
out
var
convertedStatement
))
{
return
;
}
...
...
src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs
浏览文件 @
ffad2b58
...
...
@@ -345,7 +345,7 @@ private bool IsNullCheck(IOperation operand1, IOperation operand2, IParameterSym
// signature.
var
statementToAddAfter
=
GetStatementToAddNullCheckAfter
(
semanticModel
,
parameter
,
blockStatementOpt
,
cancellationToken
);
InsertStatement
(
editor
,
functionDeclaration
,
method
,
statementToAddAfter
,
nullCheckStatement
);
InsertStatement
(
editor
,
functionDeclaration
,
method
.
ReturnsVoid
,
statementToAddAfter
,
nullCheckStatement
);
var
newRoot
=
editor
.
GetChangedRoot
();
return
document
.
WithSyntaxRoot
(
newRoot
);
...
...
src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs
浏览文件 @
ffad2b58
此差异已折叠。
点击以展开。
src/Features/Core/Portable/InitializeParameter/AbstractInitializeParameterCodeRefactoringProvider.cs
浏览文件 @
ffad2b58
...
...
@@ -53,7 +53,7 @@ internal abstract partial class AbstractInitializeParameterCodeRefactoringProvid
CancellationToken
cancellationToken
);
protected
abstract
void
InsertStatement
(
SyntaxEditor
editor
,
SyntaxNode
functionDeclaration
,
IMethodSymbol
metho
d
,
SyntaxEditor
editor
,
SyntaxNode
functionDeclaration
,
bool
returnsVoi
d
,
SyntaxNode
?
statementToAddAfterOpt
,
TStatementSyntax
statement
);
public
override
async
Task
ComputeRefactoringsAsync
(
CodeRefactoringContext
context
)
...
...
src/Features/VisualBasic/Portable/InitializeParameter/VisualBasicAddParameterCheckCodeRefactoringProvider.vb
浏览文件 @
ffad2b58
...
...
@@ -35,7 +35,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.InitializeParameter
Return
InitializeParameterHelpers
.
GetBody
(
functionDeclaration
)
End
Function
Protected
Overrides
Sub
InsertStatement
(
editor
As
SyntaxEditor
,
functionDeclaration
As
SyntaxNode
,
method
As
IMethodSymbol
,
statementToAddAfterOpt
As
SyntaxNode
,
statement
As
StatementSyntax
)
Protected
Overrides
Sub
InsertStatement
(
editor
As
SyntaxEditor
,
functionDeclaration
As
SyntaxNode
,
returnsVoid
As
Boolean
,
statementToAddAfterOpt
As
SyntaxNode
,
statement
As
StatementSyntax
)
InitializeParameterHelpers
.
InsertStatement
(
editor
,
functionDeclaration
,
statementToAddAfterOpt
,
statement
)
End
Sub
...
...
src/Features/VisualBasic/Portable/InitializeParameter/VisualBasicInitializeMemberFromParameterCodeRefactoringProvider.vb
浏览文件 @
ffad2b58
...
...
@@ -15,6 +15,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.InitializeParameter
<
ExtensionOrder
(
Before
:
=
PredefinedCodeRefactoringProviderNames
.
Wrapping
)
>
Friend
Class
VisualBasicInitializeMemberFromParameterCodeRefactoringProvider
Inherits
AbstractInitializeMemberFromParameterCodeRefactoringProvider
(
Of
TypeBlockSyntax
,
ParameterSyntax
,
StatementSyntax
,
ExpressionSyntax
)
...
...
@@ -39,7 +40,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.InitializeParameter
Return
InitializeParameterHelpers
.
IsImplicitConversion
(
compilation
,
source
,
destination
)
End
Function
Protected
Overrides
Sub
InsertStatement
(
editor
As
SyntaxEditor
,
functionDeclaration
As
SyntaxNode
,
method
As
IMethodSymbol
,
statementToAddAfterOpt
As
SyntaxNode
,
statement
As
StatementSyntax
)
Protected
Overrides
Sub
InsertStatement
(
editor
As
SyntaxEditor
,
functionDeclaration
As
SyntaxNode
,
returnsVoid
As
Boolean
,
statementToAddAfterOpt
As
SyntaxNode
,
statement
As
StatementSyntax
)
InitializeParameterHelpers
.
InsertStatement
(
editor
,
functionDeclaration
,
statementToAddAfterOpt
,
statement
)
End
Sub
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录