Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
38bf120e
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,发现更多精彩内容 >>
提交
38bf120e
编写于
8月 08, 2019
作者:
L
Lavanya
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Addressed syntax changes, extra new lines, and made appropriate naming changes
上级
0348f1d8
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
44 addition
and
53 deletion
+44
-53
src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticService.cs
...MakeLocalFunctionStatic/MakeLocalFunctionStaticService.cs
+11
-16
src/Features/CSharp/Portable/MakeLocalFunctionStatic/PassVariableExplicitlyInLocalStaticFunctionCodeFixProvider.cs
...VariableExplicitlyInLocalStaticFunctionCodeFixProvider.cs
+0
-4
src/Features/Core/Portable/FeaturesResources.Designer.cs
src/Features/Core/Portable/FeaturesResources.Designer.cs
+1
-1
src/Features/Core/Portable/FeaturesResources.resx
src/Features/Core/Portable/FeaturesResources.resx
+1
-1
src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf
src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.de.xlf
src/Features/Core/Portable/xlf/FeaturesResources.de.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.es.xlf
src/Features/Core/Portable/xlf/FeaturesResources.es.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf
src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.it.xlf
src/Features/Core/Portable/xlf/FeaturesResources.it.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf
src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf
src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf
src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf
src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf
src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf
src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf
+2
-2
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf
+2
-2
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
...rp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
+5
-5
未找到文件。
src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticService.cs
浏览文件 @
38bf120e
...
...
@@ -23,14 +23,13 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic
[
ExportLanguageService
(
typeof
(
MakeLocalFunctionStaticService
),
LanguageNames
.
CSharp
)]
internal
sealed
class
MakeLocalFunctionStaticService
:
ILanguageService
{
private
static
readonly
char
[]
s_underscore
=
{
'_'
};
private
readonly
SyntaxGenerator
s_generator
=
CSharpSyntaxGenerator
.
Instance
;
internal
async
Task
<
Document
>
CreateParameterSymbolAsync
(
Document
document
,
LocalFunctionStatementSyntax
local
f
unction
,
CancellationToken
cancellationToken
)
internal
async
Task
<
Document
>
CreateParameterSymbolAsync
(
Document
document
,
LocalFunctionStatementSyntax
local
F
unction
,
CancellationToken
cancellationToken
)
{
var
semanticModel
=
await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
true
);
var
localFunctionSymbol
=
semanticModel
.
GetDeclaredSymbol
(
local
f
unction
,
cancellationToken
);
var
dataFlow
=
semanticModel
.
AnalyzeDataFlow
(
local
f
unction
);
var
localFunctionSymbol
=
semanticModel
.
GetDeclaredSymbol
(
local
F
unction
,
cancellationToken
);
var
dataFlow
=
semanticModel
.
AnalyzeDataFlow
(
local
F
unction
);
var
captures
=
dataFlow
.
CapturedInside
;
var
parameters
=
CreateParameterSymbol
(
captures
);
...
...
@@ -42,7 +41,6 @@ internal async Task<Document> CreateParameterSymbolAsync(Document document, Loca
var
rootOne
=
await
document
.
GetSyntaxRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
editor
=
new
SyntaxEditor
(
rootOne
,
s_generator
);
foreach
(
var
referenceSymbol
in
arrayNode
)
{
foreach
(
var
location
in
referenceSymbol
.
Locations
)
...
...
@@ -50,7 +48,6 @@ internal async Task<Document> CreateParameterSymbolAsync(Document document, Loca
var
root
=
await
location
.
Document
.
GetSyntaxRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
syntaxNode
=
root
.
FindNode
(
location
.
Location
.
SourceSpan
);
//Node for the identifier syntax
var
invocation
=
(
syntaxNode
as
IdentifierNameSyntax
).
Parent
as
InvocationExpressionSyntax
;
if
(
invocation
==
null
)
{
...
...
@@ -58,31 +55,30 @@ internal async Task<Document> CreateParameterSymbolAsync(Document document, Loca
}
var
argList
=
invocation
.
ArgumentList
;
List
<
ArgumentSyntax
>
x
=
new
List
<
ArgumentSyntax
>();
List
<
ArgumentSyntax
>
paramList
=
new
List
<
ArgumentSyntax
>();
foreach
(
var
parameter
in
parameters
)
{
var
newArgument
=
GenerateArgument
(
parameter
,
parameter
.
Name
,
false
);
x
.
Add
(
newArgument
as
ArgumentSyntax
);
paramList
.
Add
(
newArgument
as
ArgumentSyntax
);
}
var
newArgList
=
argList
.
WithArguments
(
argList
.
Arguments
.
AddRange
(
x
));
var
newArgList
=
argList
.
WithArguments
(
argList
.
Arguments
.
AddRange
(
paramList
));
var
newInvocation
=
invocation
.
WithArgumentList
(
newArgList
);
editor
.
ReplaceNode
(
invocation
,
newInvocation
);
}
}
//Updates the declaration with the variables passed in
var
newLF
=
CodeGenerator
.
AddParameterDeclarations
(
localf
unction
,
parameters
,
workspace
);
var
updatedLocalFunction
=
CodeGenerator
.
AddParameterDeclarations
(
localF
unction
,
parameters
,
workspace
);
//Adds the modifier static
var
modifiers
=
DeclarationModifiers
.
From
(
localFunctionSymbol
).
WithIsStatic
(
true
);
var
LFWithStatic
=
s_generator
.
WithModifiers
(
newLF
,
modifiers
);
var
localFunctionWithStatic
=
s_generator
.
WithModifiers
(
updatedLocalFunction
,
modifiers
);
editor
.
ReplaceNode
(
local
function
,
LF
WithStatic
);
editor
.
ReplaceNode
(
local
Function
,
localFunction
WithStatic
);
var
newRoot
=
editor
.
GetChangedRoot
();
var
newDocument
=
document
.
WithSyntaxRoot
(
newRoot
);
...
...
@@ -102,12 +98,11 @@ static ImmutableArray<IParameterSymbol> CreateParameterSymbol(ImmutableArray<ISy
refKind
:
RefKind
.
None
,
isParams
:
false
,
type
:
type
,
name
:
symbol
.
Name
.
ToCamelCase
()
.
TrimStart
(
s_underscore
)
));
name
:
symbol
.
Name
.
ToCamelCase
()));
}
return
parameters
.
ToImmutableAndFree
();
}
}
internal
SyntaxNode
GenerateArgument
(
IParameterSymbol
p
,
string
name
,
bool
shouldUseNamedArguments
=
false
)
...
...
src/Features/CSharp/Portable/MakeLocalFunctionStatic/PassVariableExplicitlyInLocalStaticFunctionCodeFixProvider.cs
浏览文件 @
38bf120e
...
...
@@ -24,7 +24,6 @@ public PassVariableExplicitlyInLocalStaticFunctionCodeFixProvider()
public
override
ImmutableArray
<
string
>
FixableDiagnosticIds
=>
ImmutableArray
.
Create
(
"CS8421"
);
public
sealed
override
FixAllProvider
GetFixAllProvider
()
{
// See https://github.com/dotnet/roslyn/blob/master/docs/analyzers/FixAllProvider.md for more information on Fix All Providers
...
...
@@ -42,14 +41,11 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
var
document
=
context
.
Document
;
var
cancellationToken
=
context
.
CancellationToken
;
var
service
=
document
.
GetLanguageService
<
MakeLocalFunctionStaticService
>();
context
.
RegisterCodeFix
(
new
MyCodeAction
(
c
=>
service
.
CreateParameterSymbolAsync
(
context
.
Document
,
declaration
,
c
)),
diagnostic
);
}
private
class
MyCodeAction
:
CodeAction
.
DocumentChangeAction
...
...
src/Features/Core/Portable/FeaturesResources.Designer.cs
浏览文件 @
38bf120e
...
...
@@ -2975,7 +2975,7 @@ internal class FeaturesResources {
}
/// <summary>
///
Passe
s in local variables explicitly in a static local function.
///
Looks up a localized string similar to Pas
s in local variables explicitly in a static local function.
/// </summary>
internal
static
string
Pass_variable_explicitly_in_local_static_function
{
get
{
...
...
src/Features/Core/Portable/FeaturesResources.resx
浏览文件 @
38bf120e
...
...
@@ -1694,6 +1694,6 @@ This version used in: {2}</value>
<value>
Warning: Semantics may change when converting statement.
</value>
</data>
<data
name=
"Pass_variable_explicitly_in_local_static_function"
xml:space=
"preserve"
>
<value>
Pass
es
in local variables explicitly in a static local function
</value>
<value>
Pass in local variables explicitly in a static local function
</value>
</data>
</root>
\ No newline at end of file
src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.de.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.es.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.it.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf
浏览文件 @
38bf120e
...
...
@@ -318,8 +318,8 @@
<note
/>
</trans-unit>
<trans-unit
id=
"Pass_variable_explicitly_in_local_static_function"
>
<source>
Pass
_variable_explicitly_in_local_static_
function
</source>
<target
state=
"new"
>
Pass
_variable_explicitly_in_local_static_
function
</target>
<source>
Pass
in local variables explicitly in a static local
function
</source>
<target
state=
"new"
>
Pass
in local variables explicitly in a static local
function
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read"
>
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
浏览文件 @
38bf120e
...
...
@@ -272,17 +272,17 @@ protected override TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationN
}
public
override
TDeclarationNode
AddParameters
<
TDeclarationNode
>(
TDeclarationNode
destination
Member
,
TDeclarationNode
destination
,
IEnumerable
<
IParameterSymbol
>
parameters
,
CodeGenerationOptions
options
,
CancellationToken
cancellationToken
)
{
var
s
_g
enerator
=
CSharpSyntaxGenerator
.
Instance
;
var
currentParameterList
=
s
_generator
.
GetParameters
(
destinationMember
);
var
s
yntaxG
enerator
=
CSharpSyntaxGenerator
.
Instance
;
var
currentParameterList
=
s
yntaxGenerator
.
GetParameters
(
destination
);
if
(
currentParameterList
==
null
)
{
return
destination
Member
;
return
destination
;
}
var
currentParamsCount
=
currentParameterList
.
Count
;
...
...
@@ -300,7 +300,7 @@ protected override TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationN
}
var
finalMember
=
s
_generator
.
AddParameters
(
destinationMember
,
newParams
);
var
finalMember
=
s
yntaxGenerator
.
AddParameters
(
destination
,
newParams
.
ToImmutableAndFree
()
);
return
Cast
<
TDeclarationNode
>(
finalMember
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录