Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c5c72d57
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,发现更多精彩内容 >>
提交
c5c72d57
编写于
11月 20, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Inline variable declarations.
上级
aadf3884
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
89 addition
and
223 deletion
+89
-223
src/Workspaces/CSharp/Portable/Classification/Classifiers/NameSyntaxClassifier.cs
...rtable/Classification/Classifiers/NameSyntaxClassifier.cs
+3
-7
src/Workspaces/CSharp/Portable/Classification/Classifiers/SyntaxTokenClassifier.cs
...table/Classification/Classifiers/SyntaxTokenClassifier.cs
+1
-3
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationHelpers.cs
...rp/Portable/CodeGeneration/CSharpCodeGenerationHelpers.cs
+1
-2
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
...rp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
+1
-2
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpDeclarationComparer.cs
...harp/Portable/CodeGeneration/CSharpDeclarationComparer.cs
+15
-29
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
...s/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
+6
-16
src/Workspaces/CSharp/Portable/CodeGeneration/NamespaceGenerator.cs
...aces/CSharp/Portable/CodeGeneration/NamespaceGenerator.cs
+1
-4
src/Workspaces/CSharp/Portable/CodeGeneration/UsingDirectivesAdder.Rewriter.cs
.../Portable/CodeGeneration/UsingDirectivesAdder.Rewriter.cs
+2
-6
src/Workspaces/CSharp/Portable/Execution/CSharpOptionsSerializationService.cs
...p/Portable/Execution/CSharpOptionsSerializationService.cs
+6
-33
src/Workspaces/CSharp/Portable/Extensions/CastExpressionSyntaxExtensions.cs
...arp/Portable/Extensions/CastExpressionSyntaxExtensions.cs
+4
-10
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
.../Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
+1
-2
src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.cs
...s/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.cs
+2
-6
src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
.../CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
+8
-17
src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs
...ns/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs
+1
-2
src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs
.../MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs
+1
-2
src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs
...ces/CSharp/Portable/Extensions/SemanticModelExtensions.cs
+1
-5
src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs
...spaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs
+4
-8
src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs
...spaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs
+2
-5
src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs
...rp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs
+2
-4
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
...ortable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
+2
-4
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs
...p/Portable/LanguageServices/CSharpSemanticFactsService.cs
+1
-2
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
...arp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
+8
-16
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs
...s/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs
+2
-4
src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
...rp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
+1
-2
src/Workspaces/CSharp/Portable/Simplification/CSharpNameReducer.cs
...paces/CSharp/Portable/Simplification/CSharpNameReducer.cs
+2
-5
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs
...le/Simplification/CSharpSimplificationService.Expander.cs
+5
-12
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.cs
...rp/Portable/Simplification/CSharpSimplificationService.cs
+2
-5
src/Workspaces/CSharp/Portable/Utilities/CompilationOptionsConversion.cs
...CSharp/Portable/Utilities/CompilationOptionsConversion.cs
+1
-2
src/Workspaces/CSharp/Portable/Utilities/FormattingRangeHelper.cs
...spaces/CSharp/Portable/Utilities/FormattingRangeHelper.cs
+1
-2
src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs
...rkspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs
+1
-4
src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs
...arp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs
+1
-2
未找到文件。
src/Workspaces/CSharp/Portable/Classification/Classifiers/NameSyntaxClassifier.cs
浏览文件 @
c5c72d57
...
...
@@ -46,8 +46,7 @@ public override IEnumerable<Type> SyntaxNodeTypes
{
var
symbolInfo
=
semanticModel
.
GetSymbolInfo
(
name
,
cancellationToken
);
IEnumerable
<
ClassifiedSpan
>
result
;
if
(
TryClassifySymbol
(
name
,
symbolInfo
,
semanticModel
,
cancellationToken
,
out
result
)
||
if
(
TryClassifySymbol
(
name
,
symbolInfo
,
semanticModel
,
cancellationToken
,
out
var
result
)
||
TryClassifyFromIdentifier
(
name
,
symbolInfo
,
out
result
)
||
TryClassifyValueIdentifier
(
name
,
symbolInfo
,
out
result
)
||
TryClassifyNameOfIdentifier
(
name
,
symbolInfo
,
out
result
))
...
...
@@ -84,9 +83,7 @@ private static bool IsNamespaceName(NameSyntax name)
// Only classify if we get one good symbol back, or if it bound to a constructor symbol with
// overload resolution/accessibility errors, or bound to type/constructor and type wasn't creatable.
var
symbol
=
TryGetSymbol
(
name
,
symbolInfo
,
semanticModel
);
ClassifiedSpan
classifiedSpan
;
if
(
TryClassifySymbol
(
name
,
symbol
,
semanticModel
,
cancellationToken
,
out
classifiedSpan
))
if
(
TryClassifySymbol
(
name
,
symbol
,
semanticModel
,
cancellationToken
,
out
var
classifiedSpan
))
{
result
=
SpecializedCollections
.
SingletonEnumerable
(
classifiedSpan
);
return
true
;
...
...
@@ -107,8 +104,7 @@ private static bool IsNamespaceName(NameSyntax name)
var
set
=
new
HashSet
<
ClassifiedSpan
>();
foreach
(
var
symbol
in
symbolInfo
.
CandidateSymbols
)
{
ClassifiedSpan
classifiedSpan
;
if
(
TryClassifySymbol
(
name
,
symbol
,
semanticModel
,
cancellationToken
,
out
classifiedSpan
))
if
(
TryClassifySymbol
(
name
,
symbol
,
semanticModel
,
cancellationToken
,
out
var
classifiedSpan
))
{
set
.
Add
(
classifiedSpan
);
}
...
...
src/Workspaces/CSharp/Portable/Classification/Classifiers/SyntaxTokenClassifier.cs
浏览文件 @
c5c72d57
...
...
@@ -30,9 +30,7 @@ public override IEnumerable<int> SyntaxTokenKinds
CancellationToken
cancellationToken
)
{
var
syntaxTree
=
semanticModel
.
SyntaxTree
;
SyntaxToken
identifier
;
if
(
syntaxTree
.
IsInPartiallyWrittenGeneric
(
lessThanToken
.
Span
.
End
,
cancellationToken
,
out
identifier
))
if
(
syntaxTree
.
IsInPartiallyWrittenGeneric
(
lessThanToken
.
Span
.
End
,
cancellationToken
,
out
var
identifier
))
{
// IsInPartiallyWrittenGeneric will return true for things that could be
// partially generic method calls (as opposed to partially written types).
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationHelpers.cs
浏览文件 @
c5c72d57
...
...
@@ -263,8 +263,7 @@ public static CodeGenerationDestination GetDestination(SyntaxNode destination)
return
node
;
}
string
comment
;
var
result
=
TryGetDocumentationComment
(
symbol
,
"///"
,
out
comment
,
cancellationToken
)
var
result
=
TryGetDocumentationComment
(
symbol
,
"///"
,
out
var
comment
,
cancellationToken
)
?
node
.
WithPrependedLeadingTrivia
(
SyntaxFactory
.
ParseLeadingTrivia
(
comment
))
.
WithPrependedLeadingTrivia
(
SyntaxFactory
.
ElasticMarker
)
:
node
;
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
浏览文件 @
c5c72d57
...
...
@@ -548,8 +548,7 @@ protected override TDeclarationNode AddMembers<TDeclarationNode>(TDeclarationNod
BlockSyntax
newBlock
;
if
(
options
.
BeforeThisLocation
!=
null
)
{
IEnumerable
<
SyntaxTrivia
>
strippedTrivia
;
var
newContainingStatement
=
containingStatement
.
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
strippedTrivia
);
var
newContainingStatement
=
containingStatement
.
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
var
strippedTrivia
);
newStatements
[
0
]
=
newStatements
[
0
].
WithLeadingTrivia
(
strippedTrivia
);
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpDeclarationComparer.cs
浏览文件 @
c5c72d57
...
...
@@ -65,9 +65,8 @@ public int Compare(SyntaxNode x, SyntaxNode y)
{
if
(
x
.
Kind
()
!=
y
.
Kind
())
{
int
xPrecedence
,
yPrecedence
;
if
(!
s_kindPrecedenceMap
.
TryGetValue
(
x
.
Kind
(),
out
xPrecedence
)
||
!
s_kindPrecedenceMap
.
TryGetValue
(
y
.
Kind
(),
out
yPrecedence
))
if
(!
s_kindPrecedenceMap
.
TryGetValue
(
x
.
Kind
(),
out
var
xPrecedence
)
||
!
s_kindPrecedenceMap
.
TryGetValue
(
y
.
Kind
(),
out
var
yPrecedence
))
{
// The containing declaration is malformed and contains a node kind we did not expect.
// Ignore comparisons with those unexpected nodes and sort them to the end of the declaration.
...
...
@@ -133,8 +132,7 @@ public int Compare(SyntaxNode x, SyntaxNode y)
private
static
int
Compare
(
DelegateDeclarationSyntax
x
,
DelegateDeclarationSyntax
y
)
{
int
result
;
if
(
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
var
result
)
&&
EqualIdentifierName
(
x
.
Identifier
,
y
.
Identifier
,
out
result
))
{
EqualTypeParameterCount
(
x
.
TypeParameterList
,
y
.
TypeParameterList
,
out
result
);
...
...
@@ -145,8 +143,7 @@ private static int Compare(DelegateDeclarationSyntax x, DelegateDeclarationSynta
private
static
int
Compare
(
BaseFieldDeclarationSyntax
x
,
BaseFieldDeclarationSyntax
y
)
{
int
result
;
if
(
EqualConstness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualConstness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
var
result
)
&&
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
))
{
...
...
@@ -161,8 +158,7 @@ private static int Compare(BaseFieldDeclarationSyntax x, BaseFieldDeclarationSyn
private
static
int
Compare
(
ConstructorDeclarationSyntax
x
,
ConstructorDeclarationSyntax
y
)
{
int
result
;
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
var
result
)
&&
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
))
{
EqualParameterCount
(
x
.
ParameterList
,
y
.
ParameterList
,
out
result
);
...
...
@@ -173,8 +169,7 @@ private static int Compare(ConstructorDeclarationSyntax x, ConstructorDeclaratio
private
static
int
Compare
(
MethodDeclarationSyntax
x
,
MethodDeclarationSyntax
y
)
{
int
result
;
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
var
result
)
&&
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
)
&&
EqualIdentifierName
(
x
.
Identifier
,
y
.
Identifier
,
out
result
)
&&
EqualTypeParameterCount
(
x
.
TypeParameterList
,
y
.
TypeParameterList
,
out
result
))
...
...
@@ -187,21 +182,19 @@ private static int Compare(MethodDeclarationSyntax x, MethodDeclarationSyntax y)
private
static
int
Compare
(
ConversionOperatorDeclarationSyntax
x
,
ConversionOperatorDeclarationSyntax
y
)
{
int
result
;
if
(
x
.
ImplicitOrExplicitKeyword
.
Kind
()
!=
y
.
ImplicitOrExplicitKeyword
.
Kind
())
{
return
x
.
ImplicitOrExplicitKeyword
.
Kind
()
==
SyntaxKind
.
ImplicitKeyword
?
-
1
:
1
;
}
EqualParameterCount
(
x
.
ParameterList
,
y
.
ParameterList
,
out
result
);
EqualParameterCount
(
x
.
ParameterList
,
y
.
ParameterList
,
out
var
result
);
return
result
;
}
private
static
int
Compare
(
OperatorDeclarationSyntax
x
,
OperatorDeclarationSyntax
y
)
{
int
result
;
if
(
EqualOperatorPrecedence
(
x
.
OperatorToken
,
y
.
OperatorToken
,
out
result
))
if
(
EqualOperatorPrecedence
(
x
.
OperatorToken
,
y
.
OperatorToken
,
out
var
result
))
{
EqualParameterCount
(
x
.
ParameterList
,
y
.
ParameterList
,
out
result
);
}
...
...
@@ -211,8 +204,7 @@ private static int Compare(OperatorDeclarationSyntax x, OperatorDeclarationSynta
private
static
int
Compare
(
EventDeclarationSyntax
x
,
EventDeclarationSyntax
y
)
{
int
result
;
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
var
result
)
&&
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
))
{
EqualIdentifierName
(
x
.
Identifier
,
y
.
Identifier
,
out
result
);
...
...
@@ -223,8 +215,7 @@ private static int Compare(EventDeclarationSyntax x, EventDeclarationSyntax y)
private
static
int
Compare
(
IndexerDeclarationSyntax
x
,
IndexerDeclarationSyntax
y
)
{
int
result
;
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
var
result
)
&&
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
))
{
EqualParameterCount
(
x
.
ParameterList
,
y
.
ParameterList
,
out
result
);
...
...
@@ -235,8 +226,7 @@ private static int Compare(IndexerDeclarationSyntax x, IndexerDeclarationSyntax
private
static
int
Compare
(
PropertyDeclarationSyntax
x
,
PropertyDeclarationSyntax
y
)
{
int
result
;
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
var
result
)
&&
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
))
{
EqualIdentifierName
(
x
.
Identifier
,
y
.
Identifier
,
out
result
);
...
...
@@ -247,8 +237,7 @@ private static int Compare(PropertyDeclarationSyntax x, PropertyDeclarationSynta
private
static
int
Compare
(
EnumDeclarationSyntax
x
,
EnumDeclarationSyntax
y
)
{
int
result
;
if
(
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
))
if
(
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
var
result
))
{
EqualIdentifierName
(
x
.
Identifier
,
y
.
Identifier
,
out
result
);
}
...
...
@@ -258,8 +247,7 @@ private static int Compare(EnumDeclarationSyntax x, EnumDeclarationSyntax y)
private
static
int
Compare
(
BaseTypeDeclarationSyntax
x
,
BaseTypeDeclarationSyntax
y
)
{
int
result
;
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
result
)
&&
if
(
EqualStaticness
(
x
.
Modifiers
,
y
.
Modifiers
,
out
var
result
)
&&
EqualAccessibility
(
x
,
x
.
Modifiers
,
y
,
y
.
Modifiers
,
out
result
)
&&
EqualIdentifierName
(
x
.
Identifier
,
y
.
Identifier
,
out
result
))
{
...
...
@@ -421,10 +409,8 @@ private static bool EqualOperatorPrecedence(SyntaxToken x, SyntaxToken y, out in
{
if
(
NeitherNull
(
x
,
y
,
out
comparisonResult
))
{
int
xPrecedence
=
0
;
int
yPrecedence
=
0
;
s_operatorPrecedenceMap
.
TryGetValue
(
x
.
Kind
(),
out
xPrecedence
);
s_operatorPrecedenceMap
.
TryGetValue
(
y
.
Kind
(),
out
yPrecedence
);
s_operatorPrecedenceMap
.
TryGetValue
(
x
.
Kind
(),
out
var
xPrecedence
);
s_operatorPrecedenceMap
.
TryGetValue
(
y
.
Kind
(),
out
var
yPrecedence
);
comparisonResult
=
xPrecedence
-
yPrecedence
;
}
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
浏览文件 @
c5c72d57
...
...
@@ -907,8 +907,7 @@ private AttributeListSyntax AsAttributeList(SyntaxNode node)
public
override
IReadOnlyList
<
SyntaxNode
>
GetAttributes
(
SyntaxNode
declaration
)
{
IReadOnlyList
<
SyntaxNode
>
attrs
;
if
(!
s_declAttributes
.
TryGetValue
(
declaration
,
out
attrs
))
if
(!
s_declAttributes
.
TryGetValue
(
declaration
,
out
var
attrs
))
{
var
tmp
=
this
.
Flatten
(
GetAttributeLists
(
declaration
).
Where
(
al
=>
!
IsReturnAttribute
(
al
)).
ToImmutableReadOnlyListOrEmpty
());
attrs
=
s_declAttributes
.
GetValue
(
declaration
,
_d
=>
tmp
);
...
...
@@ -922,8 +921,7 @@ public override IReadOnlyList<SyntaxNode> GetAttributes(SyntaxNode declaration)
public
override
IReadOnlyList
<
SyntaxNode
>
GetReturnAttributes
(
SyntaxNode
declaration
)
{
IReadOnlyList
<
SyntaxNode
>
attrs
;
if
(!
s_declReturnAttributes
.
TryGetValue
(
declaration
,
out
attrs
))
if
(!
s_declReturnAttributes
.
TryGetValue
(
declaration
,
out
var
attrs
))
{
var
tmp
=
this
.
Flatten
(
GetAttributeLists
(
declaration
).
Where
(
al
=>
IsReturnAttribute
(
al
)).
ToImmutableReadOnlyListOrEmpty
());
attrs
=
s_declReturnAttributes
.
GetValue
(
declaration
,
_d
=>
tmp
);
...
...
@@ -1443,9 +1441,7 @@ public override Accessibility GetAccessibility(SyntaxNode declaration)
}
var
modifierTokens
=
GetModifierTokens
(
declaration
);
Accessibility
accessibility
;
DeclarationModifiers
modifiers
;
GetAccessibilityAndModifiers
(
modifierTokens
,
out
accessibility
,
out
modifiers
);
GetAccessibilityAndModifiers
(
modifierTokens
,
out
var
accessibility
,
out
var
modifiers
);
return
accessibility
;
}
...
...
@@ -1459,9 +1455,7 @@ public override SyntaxNode WithAccessibility(SyntaxNode declaration, Accessibili
return
Isolate
(
declaration
,
d
=>
{
var
tokens
=
GetModifierTokens
(
d
);
Accessibility
tmp
;
DeclarationModifiers
modifiers
;
this
.
GetAccessibilityAndModifiers
(
tokens
,
out
tmp
,
out
modifiers
);
this
.
GetAccessibilityAndModifiers
(
tokens
,
out
var
tmp
,
out
var
modifiers
);
var
newTokens
=
this
.
Merge
(
tokens
,
AsModifierList
(
accessibility
,
modifiers
));
return
SetModifierTokens
(
d
,
newTokens
);
});
...
...
@@ -1539,9 +1533,7 @@ private DeclarationModifiers GetAllowedModifiers(SyntaxKind kind)
public
override
DeclarationModifiers
GetModifiers
(
SyntaxNode
declaration
)
{
var
modifierTokens
=
GetModifierTokens
(
declaration
);
Accessibility
accessibility
;
DeclarationModifiers
modifiers
;
GetAccessibilityAndModifiers
(
modifierTokens
,
out
accessibility
,
out
modifiers
);
GetAccessibilityAndModifiers
(
modifierTokens
,
out
var
accessibility
,
out
var
modifiers
);
return
modifiers
;
}
...
...
@@ -1560,9 +1552,7 @@ private SyntaxNode WithModifiersInternal(SyntaxNode declaration, DeclarationModi
return
Isolate
(
declaration
,
d
=>
{
var
tokens
=
GetModifierTokens
(
d
);
Accessibility
accessibility
;
DeclarationModifiers
tmp
;
this
.
GetAccessibilityAndModifiers
(
tokens
,
out
accessibility
,
out
tmp
);
this
.
GetAccessibilityAndModifiers
(
tokens
,
out
var
accessibility
,
out
var
tmp
);
var
newTokens
=
this
.
Merge
(
tokens
,
AsModifierList
(
accessibility
,
modifiers
));
return
SetModifierTokens
(
d
,
newTokens
);
});
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/NamespaceGenerator.cs
浏览文件 @
c5c72d57
...
...
@@ -59,10 +59,7 @@ internal static class NamespaceGenerator
CancellationToken
cancellationToken
)
{
options
=
options
??
CodeGenerationOptions
.
Default
;
string
name
;
INamespaceSymbol
innermostNamespace
;
GetNameAndInnermostNamespace
(
@namespace
,
options
,
out
name
,
out
innermostNamespace
);
GetNameAndInnermostNamespace
(
@namespace
,
options
,
out
var
name
,
out
var
innermostNamespace
);
var
declaration
=
GetDeclarationSyntaxWithoutMembers
(
@namespace
,
innermostNamespace
,
name
,
options
);
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/UsingDirectivesAdder.Rewriter.cs
浏览文件 @
c5c72d57
...
...
@@ -46,9 +46,7 @@ private IList<UsingDirectiveSyntax> CreateDirectives(IList<INamespaceSymbol> nam
public
override
SyntaxNode
VisitNamespaceDeclaration
(
NamespaceDeclarationSyntax
node
)
{
var
result
=
(
NamespaceDeclarationSyntax
)
base
.
VisitNamespaceDeclaration
(
node
);
IList
<
INamespaceSymbol
>
namespaces
;
if
(!
_namespacesToImport
.
TryGetValue
(
node
,
out
namespaces
))
if
(!
_namespacesToImport
.
TryGetValue
(
node
,
out
var
namespaces
))
{
return
result
;
}
...
...
@@ -65,9 +63,7 @@ public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax
public
override
SyntaxNode
VisitCompilationUnit
(
CompilationUnitSyntax
node
)
{
var
result
=
(
CompilationUnitSyntax
)
base
.
VisitCompilationUnit
(
node
);
IList
<
INamespaceSymbol
>
namespaces
;
if
(!
_namespacesToImport
.
TryGetValue
(
node
,
out
namespaces
))
if
(!
_namespacesToImport
.
TryGetValue
(
node
,
out
var
namespaces
))
{
return
result
;
}
...
...
src/Workspaces/CSharp/Portable/Execution/CSharpOptionsSerializationService.cs
浏览文件 @
c5c72d57
...
...
@@ -60,37 +60,13 @@ public override OptionSet ReadOptionSetFrom(ObjectReader reader, CancellationTok
public
override
CompilationOptions
ReadCompilationOptionsFrom
(
ObjectReader
reader
,
CancellationToken
cancellationToken
)
{
OutputKind
outputKind
;
bool
reportSuppressedDiagnostics
;
string
moduleName
;
string
mainTypeName
;
string
scriptClassName
;
OptimizationLevel
optimizationLevel
;
bool
checkOverflow
;
string
cryptoKeyContainer
;
string
cryptoKeyFile
;
ImmutableArray
<
byte
>
cryptoPublicKey
;
bool
?
delaySign
;
Platform
platform
;
ReportDiagnostic
generalDiagnosticOption
;
int
warningLevel
;
IEnumerable
<
KeyValuePair
<
string
,
ReportDiagnostic
>>
specificDiagnosticOptions
;
bool
concurrentBuild
;
bool
deterministic
;
bool
publicSign
;
XmlReferenceResolver
xmlReferenceResolver
;
SourceReferenceResolver
sourceReferenceResolver
;
MetadataReferenceResolver
metadataReferenceResolver
;
AssemblyIdentityComparer
assemblyIdentityComparer
;
StrongNameProvider
strongNameProvider
;
ReadCompilationOptionsFrom
(
reader
,
out
outputKind
,
out
reportSuppressedDiagnostics
,
out
moduleName
,
out
mainTypeName
,
out
scriptClassName
,
out
optimizationLevel
,
out
checkOverflow
,
out
cryptoKeyContainer
,
out
cryptoKeyFile
,
out
cryptoPublicKey
,
out
delaySign
,
out
platform
,
out
generalDiagnosticOption
,
out
warningLevel
,
out
specificDiagnosticOptions
,
out
concurrentBuild
,
out
deterministic
,
out
publicSign
,
out
xmlReferenceResolver
,
out
sourceReferenceResolver
,
out
metadataReferenceResolver
,
out
assemblyIdentityComparer
,
out
strongNameProvider
,
cancellationToken
);
out
var
outputKind
,
out
var
reportSuppressedDiagnostics
,
out
var
moduleName
,
out
var
mainTypeName
,
out
var
scriptClassName
,
out
var
optimizationLevel
,
out
var
checkOverflow
,
out
var
cryptoKeyContainer
,
out
var
cryptoKeyFile
,
out
var
cryptoPublicKey
,
out
var
delaySign
,
out
var
platform
,
out
var
generalDiagnosticOption
,
out
var
warningLevel
,
out
var
specificDiagnosticOptions
,
out
var
concurrentBuild
,
out
var
deterministic
,
out
var
publicSign
,
out
var
xmlReferenceResolver
,
out
var
sourceReferenceResolver
,
out
var
metadataReferenceResolver
,
out
var
assemblyIdentityComparer
,
out
var
strongNameProvider
,
cancellationToken
);
var
usings
=
reader
.
ReadArray
<
string
>();
var
allowUnsafe
=
reader
.
ReadBoolean
();
...
...
@@ -103,10 +79,7 @@ public override CompilationOptions ReadCompilationOptionsFrom(ObjectReader reade
public
override
ParseOptions
ReadParseOptionsFrom
(
ObjectReader
reader
,
CancellationToken
cancellationToken
)
{
SourceCodeKind
kind
;
DocumentationMode
documentationMode
;
IEnumerable
<
KeyValuePair
<
string
,
string
>>
features
;
ReadParseOptionsFrom
(
reader
,
out
kind
,
out
documentationMode
,
out
features
,
cancellationToken
);
ReadParseOptionsFrom
(
reader
,
out
var
kind
,
out
var
documentationMode
,
out
var
features
,
cancellationToken
);
var
languageVersion
=
(
LanguageVersion
)
reader
.
ReadInt32
();
var
preprocessorSymbolNames
=
reader
.
ReadArray
<
string
>();
...
...
src/Workspaces/CSharp/Portable/Extensions/CastExpressionSyntaxExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -111,8 +111,7 @@ private static Conversion GetSpeculatedExpressionToOuterTypeConversion(Expressio
return
conversion
;
}
bool
discarded
;
var
speculatedExpressionOuterType
=
GetOuterCastType
(
speculatedExpression
,
speculationAnalyzer
.
SpeculativeSemanticModel
,
out
discarded
)
??
typeInfo
.
ConvertedType
;
var
speculatedExpressionOuterType
=
GetOuterCastType
(
speculatedExpression
,
speculationAnalyzer
.
SpeculativeSemanticModel
,
out
var
discarded
)
??
typeInfo
.
ConvertedType
;
if
(
speculatedExpressionOuterType
==
null
)
{
return
default
(
Conversion
);
...
...
@@ -354,9 +353,7 @@ public static bool IsUnnecessaryCast(this CastExpressionSyntax cast, SemanticMod
}
var
expressionToCastType
=
semanticModel
.
ClassifyConversion
(
cast
.
SpanStart
,
cast
.
Expression
,
castType
,
isExplicitInSource
:
true
);
bool
parentIsOrAsExpression
;
var
outerType
=
GetOuterCastType
(
cast
,
semanticModel
,
out
parentIsOrAsExpression
)
??
castTypeInfo
.
ConvertedType
;
var
outerType
=
GetOuterCastType
(
cast
,
semanticModel
,
out
var
parentIsOrAsExpression
)
??
castTypeInfo
.
ConvertedType
;
// Simple case: If the conversion from the inner expression to the cast type is identity,
// the cast can be removed.
...
...
@@ -366,8 +363,7 @@ public static bool IsUnnecessaryCast(this CastExpressionSyntax cast, SemanticMod
// Cast removal causes warning CS0252 (Possible unintended reference comparison).
// object x = string.Intern("Hi!");
// (object)x == "Hi!"
ExpressionSyntax
other
;
if
(
IsRequiredCastForReferenceEqualityComparison
(
outerType
,
cast
,
semanticModel
,
out
other
))
if
(
IsRequiredCastForReferenceEqualityComparison
(
outerType
,
cast
,
semanticModel
,
out
var
other
))
{
var
otherToOuterType
=
semanticModel
.
ClassifyConversion
(
other
,
outerType
);
if
(
otherToOuterType
.
IsImplicit
&&
otherToOuterType
.
IsReference
)
...
...
@@ -440,15 +436,13 @@ public static bool IsUnnecessaryCast(this CastExpressionSyntax cast, SemanticMod
{
return
false
;
}
// Required explicit cast for reference comparison.
// Cast removal causes warning CS0252 (Possible unintended reference comparison).
// object x = string.Intern("Hi!");
// x == (object)"Hi!"
ExpressionSyntax
other
;
if
(
expressionToCastType
.
IsImplicit
&&
expressionToCastType
.
IsReference
&&
castToOuterType
.
IsIdentity
&&
IsRequiredCastForReferenceEqualityComparison
(
outerType
,
cast
,
semanticModel
,
out
other
))
IsRequiredCastForReferenceEqualityComparison
(
outerType
,
cast
,
semanticModel
,
out
var
other
))
{
return
false
;
}
...
...
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -922,8 +922,7 @@ public static bool IsDefaultExpressionContext(this SyntaxTree syntaxTree, int po
return
true
;
}
SyntaxToken
nameToken
;
if
(!
syntaxTree
.
IsInPartiallyWrittenGeneric
(
position
,
cancellationToken
,
out
nameToken
))
if
(!
syntaxTree
.
IsInPartiallyWrittenGeneric
(
position
,
cancellationToken
,
out
var
nameToken
))
{
return
false
;
}
...
...
src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -61,9 +61,7 @@ internal static DirectiveTriviaSyntax GetMatchingDirective(this DirectiveTriviaS
}
var
directiveSyntaxMap
=
GetDirectiveInfo
(
directive
,
cancellationToken
).
DirectiveMap
;
DirectiveTriviaSyntax
result
;
directiveSyntaxMap
.
TryGetValue
(
directive
,
out
result
);
directiveSyntaxMap
.
TryGetValue
(
directive
,
out
var
result
);
return
result
;
}
...
...
@@ -76,9 +74,7 @@ internal static IReadOnlyList<DirectiveTriviaSyntax> GetMatchingConditionalDirec
}
var
directiveConditionalMap
=
GetDirectiveInfo
(
directive
,
cancellationToken
).
ConditionalMap
;
IReadOnlyList
<
DirectiveTriviaSyntax
>
result
;
directiveConditionalMap
.
TryGetValue
(
directive
,
out
result
);
directiveConditionalMap
.
TryGetValue
(
directive
,
out
var
result
);
return
result
;
}
...
...
src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -661,8 +661,7 @@ private static bool CanReplace(ISymbol symbol)
OptionSet
optionSet
,
CancellationToken
cancellationToken
)
{
TypeSyntax
replacementTypeNode
;
if
(
expression
.
TryReduceExplicitName
(
semanticModel
,
out
replacementTypeNode
,
out
issueSpan
,
optionSet
,
cancellationToken
))
if
(
expression
.
TryReduceExplicitName
(
semanticModel
,
out
var
replacementTypeNode
,
out
issueSpan
,
optionSet
,
cancellationToken
))
{
replacementNode
=
replacementTypeNode
;
return
true
;
...
...
@@ -746,8 +745,7 @@ private static bool CanReplace(ISymbol symbol)
if
(!
memberAccess
.
IsRightSideOfDot
())
{
// Check if we need to replace this syntax with an alias identifier
IAliasSymbol
aliasReplacement
;
if
(
memberAccess
.
TryReplaceWithAlias
(
semanticModel
,
optionSet
.
GetOption
(
SimplificationOptions
.
PreferAliasToQualification
),
cancellationToken
,
out
aliasReplacement
))
if
(
memberAccess
.
TryReplaceWithAlias
(
semanticModel
,
optionSet
.
GetOption
(
SimplificationOptions
.
PreferAliasToQualification
),
cancellationToken
,
out
var
aliasReplacement
))
{
// get the token text as it appears in source code to preserve e.g. unicode character escaping
var
text
=
aliasReplacement
.
Name
;
...
...
@@ -1033,14 +1031,13 @@ public static IAliasSymbol GetAliasForSymbol(INamespaceOrTypeSymbol symbol, Synt
return
null
;
}
IAliasSymbol
aliasSymbol
;
var
namespaceId
=
GetNamespaceIdForAliasSearch
(
semanticModel
,
token
,
cancellationToken
);
if
(
namespaceId
<
0
)
{
return
null
;
}
if
(!
AliasSymbolCache
.
TryGetAliasSymbol
(
originalSemanticModel
,
namespaceId
,
symbol
,
out
aliasSymbol
))
if
(!
AliasSymbolCache
.
TryGetAliasSymbol
(
originalSemanticModel
,
namespaceId
,
symbol
,
out
var
aliasSymbol
))
{
// add cache
AliasSymbolCache
.
AddAliasSymbols
(
originalSemanticModel
,
namespaceId
,
semanticModel
.
LookupNamespacesAndTypes
(
token
.
SpanStart
).
OfType
<
IAliasSymbol
>());
...
...
@@ -1235,8 +1232,7 @@ private static int GetNamespaceId(SyntaxList<MemberDeclarationSyntax> members, N
{
if
(!
name
.
IsRightSideOfDotOrColonColon
())
{
IAliasSymbol
aliasReplacement
;
if
(
name
.
TryReplaceWithAlias
(
semanticModel
,
optionSet
.
GetOption
(
SimplificationOptions
.
PreferAliasToQualification
),
cancellationToken
,
out
aliasReplacement
))
if
(
name
.
TryReplaceWithAlias
(
semanticModel
,
optionSet
.
GetOption
(
SimplificationOptions
.
PreferAliasToQualification
),
cancellationToken
,
out
var
aliasReplacement
))
{
// get the token text as it appears in source code to preserve e.g. unicode character escaping
var
text
=
aliasReplacement
.
Name
;
...
...
@@ -1305,14 +1301,12 @@ private static int GetNamespaceId(SyntaxList<MemberDeclarationSyntax> members, N
{
// in case this alias name ends with "Attribute", we're going to see if we can also
// remove that suffix.
TypeSyntax
replacementNodeWithoutAttributeSuffix
;
TextSpan
issueSpanWithoutAttributeSuffix
;
if
(
TryReduceAttributeSuffix
(
name
,
identifierToken
,
semanticModel
,
out
replacementNodeWithoutAttributeSuffix
,
out
issueSpanWithoutAttributeSuffix
,
out
var
replacementNodeWithoutAttributeSuffix
,
out
var
issueSpanWithoutAttributeSuffix
,
cancellationToken
))
{
if
(
name
.
CanReplaceWithReducedName
(
replacementNodeWithoutAttributeSuffix
,
semanticModel
,
cancellationToken
))
...
...
@@ -1666,14 +1660,12 @@ public static bool IsPartOfNamespaceDeclarationName(SyntaxNode node)
case
SyntaxKind
.
SimpleMemberAccessExpression
:
{
var
memberAccess
=
(
MemberAccessExpressionSyntax
)
expression
;
ExpressionSyntax
newLeft
;
if
(
IsMemberAccessADynamicInvocation
(
memberAccess
,
semanticModel
))
{
return
false
;
}
if
(
TrySimplifyMemberAccessOrQualifiedName
(
memberAccess
.
Expression
,
memberAccess
.
Name
,
semanticModel
,
optionSet
,
out
newLeft
,
out
issueSpan
))
if
(
TrySimplifyMemberAccessOrQualifiedName
(
memberAccess
.
Expression
,
memberAccess
.
Name
,
semanticModel
,
optionSet
,
out
var
newLeft
,
out
issueSpan
))
{
// replacement node might not be in it's simplest form, so add simplify annotation to it.
replacementNode
=
memberAccess
.
Update
(
newLeft
,
memberAccess
.
OperatorToken
,
memberAccess
.
Name
)
...
...
@@ -1689,8 +1681,7 @@ public static bool IsPartOfNamespaceDeclarationName(SyntaxNode node)
case
SyntaxKind
.
QualifiedName
:
{
var
qualifiedName
=
(
QualifiedNameSyntax
)
expression
;
ExpressionSyntax
newLeft
;
if
(
TrySimplifyMemberAccessOrQualifiedName
(
qualifiedName
.
Left
,
qualifiedName
.
Right
,
semanticModel
,
optionSet
,
out
newLeft
,
out
issueSpan
))
if
(
TrySimplifyMemberAccessOrQualifiedName
(
qualifiedName
.
Left
,
qualifiedName
.
Right
,
semanticModel
,
optionSet
,
out
var
newLeft
,
out
issueSpan
))
{
// replacement node might not be in it's simplest form, so add simplify annotation to it.
replacementNode
=
qualifiedName
.
Update
((
NameSyntax
)
newLeft
,
qualifiedName
.
DotToken
,
qualifiedName
.
Right
)
...
...
src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs
浏览文件 @
c5c72d57
...
...
@@ -31,8 +31,7 @@ private void Add(SyntaxToken syntaxToken)
if
(
syntaxToken
.
Kind
()
==
SyntaxKind
.
IdentifierToken
)
{
var
identifier
=
syntaxToken
.
ValueText
;
List
<
SyntaxToken
>
list
;
if
(!
_map
.
TryGetValue
(
identifier
,
out
list
))
if
(!
_map
.
TryGetValue
(
identifier
,
out
var
list
))
{
list
=
new
List
<
SyntaxToken
>();
_map
.
Add
(
identifier
,
list
);
...
...
src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs
浏览文件 @
c5c72d57
...
...
@@ -25,8 +25,7 @@ internal LocalDeclarationMap(Dictionary<string, ImmutableArray<SyntaxToken>> dic
{
get
{
ImmutableArray
<
SyntaxToken
>
result
;
return
_dictionary
.
TryGetValue
(
identifier
,
out
result
)
return
_dictionary
.
TryGetValue
(
identifier
,
out
var
result
)
?
result
:
ImmutableArray
.
Create
<
SyntaxToken
>();
}
...
...
src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -104,11 +104,7 @@ private static void DecomposeName(ExpressionSyntax expression, out ExpressionSyn
CancellationToken
cancellationToken
)
{
var
expr
=
SyntaxFactory
.
GetStandaloneExpression
(
expression
);
ExpressionSyntax
qualifier
;
string
name
;
int
arity
;
DecomposeName
(
expr
,
out
qualifier
,
out
name
,
out
arity
);
DecomposeName
(
expr
,
out
var
qualifier
,
out
var
name
,
out
var
arity
);
INamespaceOrTypeSymbol
symbol
=
null
;
if
(
qualifier
!=
null
)
...
...
src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -561,8 +561,7 @@ public static bool IsAnyLambdaOrAnonymousMethod(this SyntaxNode node)
this
TSyntaxNode
node
)
where
TSyntaxNode
:
SyntaxNode
{
IEnumerable
<
SyntaxTrivia
>
blankLines
;
node
.
GetNodeWithoutLeadingBlankLines
(
out
blankLines
);
node
.
GetNodeWithoutLeadingBlankLines
(
out
var
blankLines
);
return
blankLines
;
}
...
...
@@ -570,8 +569,7 @@ public static bool IsAnyLambdaOrAnonymousMethod(this SyntaxNode node)
this
TSyntaxNode
node
)
where
TSyntaxNode
:
SyntaxNode
{
IEnumerable
<
SyntaxTrivia
>
blankLines
;
return
node
.
GetNodeWithoutLeadingBlankLines
(
out
blankLines
);
return
node
.
GetNodeWithoutLeadingBlankLines
(
out
var
blankLines
);
}
public
static
TSyntaxNode
GetNodeWithoutLeadingBlankLines
<
TSyntaxNode
>(
...
...
@@ -592,8 +590,7 @@ public static bool IsAnyLambdaOrAnonymousMethod(this SyntaxNode node)
this
TSyntaxNode
node
)
where
TSyntaxNode
:
SyntaxNode
{
IEnumerable
<
SyntaxTrivia
>
leadingTrivia
;
node
.
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
leadingTrivia
);
node
.
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
var
leadingTrivia
);
return
leadingTrivia
;
}
...
...
@@ -601,8 +598,7 @@ public static bool IsAnyLambdaOrAnonymousMethod(this SyntaxNode node)
this
TSyntaxNode
node
)
where
TSyntaxNode
:
SyntaxNode
{
IEnumerable
<
SyntaxTrivia
>
strippedTrivia
;
return
node
.
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
strippedTrivia
);
return
node
.
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
var
strippedTrivia
);
}
public
static
TSyntaxNode
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
<
TSyntaxNode
>(
...
...
src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -560,9 +560,7 @@ private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int
public
static
bool
IsInPartiallyWrittenGeneric
(
this
SyntaxTree
syntaxTree
,
int
position
,
CancellationToken
cancellationToken
)
{
SyntaxToken
genericIdentifier
;
SyntaxToken
lessThanToken
;
return
syntaxTree
.
IsInPartiallyWrittenGeneric
(
position
,
cancellationToken
,
out
genericIdentifier
,
out
lessThanToken
);
return
syntaxTree
.
IsInPartiallyWrittenGeneric
(
position
,
cancellationToken
,
out
var
genericIdentifier
,
out
var
lessThanToken
);
}
public
static
bool
IsInPartiallyWrittenGeneric
(
...
...
@@ -571,8 +569,7 @@ private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int
CancellationToken
cancellationToken
,
out
SyntaxToken
genericIdentifier
)
{
SyntaxToken
lessThanToken
;
return
syntaxTree
.
IsInPartiallyWrittenGeneric
(
position
,
cancellationToken
,
out
genericIdentifier
,
out
lessThanToken
);
return
syntaxTree
.
IsInPartiallyWrittenGeneric
(
position
,
cancellationToken
,
out
genericIdentifier
,
out
var
lessThanToken
);
}
public
static
bool
IsInPartiallyWrittenGeneric
(
...
...
src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs
浏览文件 @
c5c72d57
...
...
@@ -304,16 +304,14 @@ private static SyntaxToken EnsureToken(SyntaxToken token, bool prependNewLineIfM
public
static
TypeDeclarationSyntax
EnsureOpenAndCloseBraceTokens
(
this
TypeDeclarationSyntax
typeDeclaration
)
{
SyntaxToken
openBrace
,
closeBrace
;
EnsureAndGetBraceTokens
(
typeDeclaration
,
typeDeclaration
.
Members
.
Count
>
0
,
out
openBrace
,
out
closeBrace
);
EnsureAndGetBraceTokens
(
typeDeclaration
,
typeDeclaration
.
Members
.
Count
>
0
,
out
var
openBrace
,
out
var
closeBrace
);
return
typeDeclaration
.
WithOpenBraceToken
(
openBrace
).
WithCloseBraceToken
(
closeBrace
);
}
public
static
EnumDeclarationSyntax
EnsureOpenAndCloseBraceTokens
(
this
EnumDeclarationSyntax
typeDeclaration
)
{
SyntaxToken
openBrace
,
closeBrace
;
EnsureAndGetBraceTokens
(
typeDeclaration
,
typeDeclaration
.
Members
.
Count
>
0
,
out
openBrace
,
out
closeBrace
);
EnsureAndGetBraceTokens
(
typeDeclaration
,
typeDeclaration
.
Members
.
Count
>
0
,
out
var
openBrace
,
out
var
closeBrace
);
return
typeDeclaration
.
WithOpenBraceToken
(
openBrace
).
WithCloseBraceToken
(
closeBrace
);
}
}
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
浏览文件 @
c5c72d57
...
...
@@ -218,8 +218,7 @@ private bool TryFormatMultiLineCommentTrivia(LineColumn lineColumn, SyntaxTrivia
return
FormatStructuredTrivia
(
lineColumn
,
trivia
,
changes
,
cancellationToken
);
}
var
newComment
=
default
(
SyntaxTrivia
);
if
(
TryFormatMultiLineCommentTrivia
(
lineColumn
,
trivia
,
out
newComment
))
if
(
TryFormatMultiLineCommentTrivia
(
lineColumn
,
trivia
,
out
var
newComment
))
{
changes
.
Add
(
newComment
);
return
GetLineColumnDelta
(
lineColumn
,
newComment
);
...
...
@@ -237,8 +236,7 @@ private bool TryFormatMultiLineCommentTrivia(LineColumn lineColumn, SyntaxTrivia
return
FormatStructuredTrivia
(
lineColumn
,
trivia
,
changes
,
cancellationToken
);
}
var
newComment
=
default
(
SyntaxTrivia
);
if
(
TryFormatMultiLineCommentTrivia
(
lineColumn
,
trivia
,
out
newComment
))
if
(
TryFormatMultiLineCommentTrivia
(
lineColumn
,
trivia
,
out
var
newComment
))
{
changes
.
Add
(
new
TextChange
(
trivia
.
FullSpan
,
newComment
.
ToFullString
()));
return
GetLineColumnDelta
(
lineColumn
,
newComment
);
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs
浏览文件 @
c5c72d57
...
...
@@ -177,8 +177,7 @@ public bool TryGetSpeculativeSemanticModel(SemanticModel oldSemanticModel, Synta
return
false
;
}
SemanticModel
csharpModel
;
bool
success
=
model
.
TryGetSpeculativeSemanticModelForMethodBody
(
oldMethod
.
Body
.
OpenBraceToken
.
Span
.
End
,
newMethod
,
out
csharpModel
);
bool
success
=
model
.
TryGetSpeculativeSemanticModelForMethodBody
(
oldMethod
.
Body
.
OpenBraceToken
.
Span
.
End
,
newMethod
,
out
var
csharpModel
);
speculativeModel
=
csharpModel
;
return
success
;
}
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
浏览文件 @
c5c72d57
...
...
@@ -254,14 +254,12 @@ public bool IsQueryExpression(SyntaxNode node)
public
bool
IsPredefinedType
(
SyntaxToken
token
)
{
PredefinedType
actualType
;
return
TryGetPredefinedType
(
token
,
out
actualType
)
&&
actualType
!=
PredefinedType
.
None
;
return
TryGetPredefinedType
(
token
,
out
var
actualType
)
&&
actualType
!=
PredefinedType
.
None
;
}
public
bool
IsPredefinedType
(
SyntaxToken
token
,
PredefinedType
type
)
{
PredefinedType
actualType
;
return
TryGetPredefinedType
(
token
,
out
actualType
)
&&
actualType
==
type
;
return
TryGetPredefinedType
(
token
,
out
var
actualType
)
&&
actualType
==
type
;
}
public
bool
TryGetPredefinedType
(
SyntaxToken
token
,
out
PredefinedType
type
)
...
...
@@ -313,14 +311,12 @@ private PredefinedType GetPredefinedType(SyntaxToken token)
public
bool
IsPredefinedOperator
(
SyntaxToken
token
)
{
PredefinedOperator
actualOperator
;
return
TryGetPredefinedOperator
(
token
,
out
actualOperator
)
&&
actualOperator
!=
PredefinedOperator
.
None
;
return
TryGetPredefinedOperator
(
token
,
out
var
actualOperator
)
&&
actualOperator
!=
PredefinedOperator
.
None
;
}
public
bool
IsPredefinedOperator
(
SyntaxToken
token
,
PredefinedOperator
op
)
{
PredefinedOperator
actualOperator
;
return
TryGetPredefinedOperator
(
token
,
out
actualOperator
)
&&
actualOperator
==
op
;
return
TryGetPredefinedOperator
(
token
,
out
var
actualOperator
)
&&
actualOperator
==
op
;
}
public
bool
TryGetPredefinedOperator
(
SyntaxToken
token
,
out
PredefinedOperator
op
)
...
...
@@ -670,8 +666,7 @@ public bool IsObjectCreationExpression(SyntaxNode node)
public
bool
IsObjectInitializerNamedAssignmentIdentifier
(
SyntaxNode
node
)
{
SyntaxNode
unused
;
return
IsObjectInitializerNamedAssignmentIdentifier
(
node
,
out
unused
);
return
IsObjectInitializerNamedAssignmentIdentifier
(
node
,
out
var
unused
);
}
public
bool
IsObjectInitializerNamedAssignmentIdentifier
(
...
...
@@ -996,8 +991,7 @@ private void ProcessUsings(List<Dictionary<string, string>> aliasMaps, SyntaxLis
var
currentName
=
name
;
foreach
(
var
aliasMap
in
aliasMaps
)
{
string
mappedName
;
if
(
aliasMap
.
TryGetValue
(
currentName
,
out
mappedName
))
if
(
aliasMap
.
TryGetValue
(
currentName
,
out
var
mappedName
))
{
// Looks like this could be an alias. Also include the name the alias points to
builder
.
Add
(
mappedName
);
...
...
@@ -1383,8 +1377,7 @@ public int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node)
Contract
.
Requires
(
root
.
SyntaxTree
==
node
.
SyntaxTree
);
int
currentId
=
0
;
SyntaxNode
currentNode
;
Contract
.
ThrowIfFalse
(
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
n
==
node
,
ref
currentId
,
out
currentNode
));
Contract
.
ThrowIfFalse
(
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
n
==
node
,
ref
currentId
,
out
var
currentNode
));
Contract
.
ThrowIfFalse
(
currentId
>=
0
);
CheckMemberId
(
root
,
node
,
currentId
);
...
...
@@ -1394,8 +1387,7 @@ public int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node)
public
SyntaxNode
GetMethodLevelMember
(
SyntaxNode
root
,
int
memberId
)
{
int
currentId
=
0
;
SyntaxNode
currentNode
;
if
(!
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
i
==
memberId
,
ref
currentId
,
out
currentNode
))
if
(!
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
i
==
memberId
,
ref
currentId
,
out
var
currentNode
))
{
return
null
;
}
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs
浏览文件 @
c5c72d57
...
...
@@ -95,8 +95,7 @@ private CompilationUnitSyntax CacheRootNode(CompilationUnitSyntax node)
public
override
bool
TryGetRoot
(
out
CSharpSyntaxNode
root
)
{
CompilationUnitSyntax
node
;
bool
status
=
_recoverableRoot
.
TryGetValue
(
out
node
);
bool
status
=
_recoverableRoot
.
TryGetValue
(
out
var
node
);
root
=
node
;
CacheRootNode
(
node
);
return
status
;
...
...
@@ -145,8 +144,7 @@ CompilationUnitSyntax IRecoverableSyntaxTree<CompilationUnitSyntax>.CloneNodeAsR
public
override
SyntaxTree
WithRootAndOptions
(
SyntaxNode
root
,
ParseOptions
options
)
{
CSharpSyntaxNode
oldRoot
;
if
(
ReferenceEquals
(
_info
.
Options
,
options
)
&&
this
.
TryGetRoot
(
out
oldRoot
)
&&
ReferenceEquals
(
root
,
oldRoot
))
if
(
ReferenceEquals
(
_info
.
Options
,
options
)
&&
this
.
TryGetRoot
(
out
var
oldRoot
)
&&
ReferenceEquals
(
root
,
oldRoot
))
{
return
this
;
}
...
...
src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
浏览文件 @
c5c72d57
...
...
@@ -562,8 +562,7 @@ private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, stri
{
if
(
oldIdentifier
!=
_renamedSymbol
.
Name
)
{
string
withoutSuffix
;
if
(
currentNewIdentifier
.
TryGetWithoutAttributeSuffix
(
out
withoutSuffix
))
if
(
currentNewIdentifier
.
TryGetWithoutAttributeSuffix
(
out
var
withoutSuffix
))
{
currentNewIdentifier
=
withoutSuffix
;
}
...
...
src/Workspaces/CSharp/Portable/Simplification/CSharpNameReducer.cs
浏览文件 @
c5c72d57
...
...
@@ -29,9 +29,7 @@ public override IExpressionRewriter CreateExpressionRewriter(OptionSet optionSet
if
(
node
.
Kind
()
==
SyntaxKind
.
QualifiedCref
)
{
var
crefSyntax
=
(
QualifiedCrefSyntax
)
node
;
CrefSyntax
crefReplacement
;
if
(!
crefSyntax
.
TryReduceOrSimplifyExplicitName
(
semanticModel
,
out
crefReplacement
,
out
issueSpan
,
optionSet
,
cancellationToken
))
if
(!
crefSyntax
.
TryReduceOrSimplifyExplicitName
(
semanticModel
,
out
var
crefReplacement
,
out
issueSpan
,
optionSet
,
cancellationToken
))
{
return
node
;
}
...
...
@@ -41,8 +39,7 @@ public override IExpressionRewriter CreateExpressionRewriter(OptionSet optionSet
else
{
var
expressionSyntax
=
(
ExpressionSyntax
)
node
;
ExpressionSyntax
expressionReplacement
;
if
(!
expressionSyntax
.
TryReduceOrSimplifyExplicitName
(
semanticModel
,
out
expressionReplacement
,
out
issueSpan
,
optionSet
,
cancellationToken
))
if
(!
expressionSyntax
.
TryReduceOrSimplifyExplicitName
(
semanticModel
,
out
var
expressionReplacement
,
out
issueSpan
,
optionSet
,
cancellationToken
))
{
return
node
;
}
...
...
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs
浏览文件 @
c5c72d57
...
...
@@ -150,8 +150,7 @@ public override SyntaxNode VisitReturnStatement(ReturnStatementSyntax node)
var
returnType
=
(
_semanticModel
.
GetSymbolInfo
(
parentLambda
).
Symbol
as
IMethodSymbol
)?.
ReturnType
;
if
(
returnType
!=
null
)
{
ExpressionSyntax
newExpressionWithCast
;
if
(
TryCastTo
(
returnType
,
node
.
Expression
,
newReturnStatement
.
Expression
,
out
newExpressionWithCast
))
if
(
TryCastTo
(
returnType
,
node
.
Expression
,
newReturnStatement
.
Expression
,
out
var
newExpressionWithCast
))
{
newNode
=
newReturnStatement
.
WithExpression
(
newExpressionWithCast
);
}
...
...
@@ -170,10 +169,8 @@ public override SyntaxNode VisitParenthesizedLambdaExpression(ParenthesizedLambd
if
(
newNode
is
ParenthesizedLambdaExpressionSyntax
)
{
var
parenthesizedLambda
=
(
ParenthesizedLambdaExpressionSyntax
)
newNode
;
// First, try to add a cast to the lambda.
ExpressionSyntax
newLambdaExpressionBodyWithCast
;
if
(
TryGetLambdaExpressionBodyWithCast
(
node
,
parenthesizedLambda
,
out
newLambdaExpressionBodyWithCast
))
if
(
TryGetLambdaExpressionBodyWithCast
(
node
,
parenthesizedLambda
,
out
var
newLambdaExpressionBodyWithCast
))
{
parenthesizedLambda
=
parenthesizedLambda
.
WithBody
(
newLambdaExpressionBodyWithCast
);
}
...
...
@@ -224,10 +221,8 @@ public override SyntaxNode VisitSimpleLambdaExpression(SimpleLambdaExpressionSyn
if
(
newNode
is
SimpleLambdaExpressionSyntax
)
{
var
simpleLambda
=
(
SimpleLambdaExpressionSyntax
)
newNode
;
// First, try to add a cast to the lambda.
ExpressionSyntax
newLambdaExpressionBodyWithCast
;
if
(
TryGetLambdaExpressionBodyWithCast
(
node
,
simpleLambda
,
out
newLambdaExpressionBodyWithCast
))
if
(
TryGetLambdaExpressionBodyWithCast
(
node
,
simpleLambda
,
out
var
newLambdaExpressionBodyWithCast
))
{
simpleLambda
=
simpleLambda
.
WithBody
(
newLambdaExpressionBodyWithCast
);
}
...
...
@@ -270,8 +265,7 @@ public override SyntaxNode VisitArgument(ArgumentSyntax node)
!
IsPassedToDelegateCreationExpression
(
node
,
argumentType
)
&&
node
.
Expression
.
Kind
()
!=
SyntaxKind
.
DeclarationExpression
)
{
ExpressionSyntax
newArgumentExpressionWithCast
;
if
(
TryCastTo
(
argumentType
,
node
.
Expression
,
newArgument
.
Expression
,
out
newArgumentExpressionWithCast
))
if
(
TryCastTo
(
argumentType
,
node
.
Expression
,
newArgument
.
Expression
,
out
var
newArgumentExpressionWithCast
))
{
return
newArgument
.
WithExpression
(
newArgumentExpressionWithCast
);
}
...
...
@@ -449,8 +443,7 @@ private ExpressionSyntax VisitSimpleName(SimpleNameSyntax rewrittenSimpleName, S
var
firstReplacementToken
=
replacement
.
GetFirstToken
(
true
,
false
,
true
,
true
);
var
firstOriginalToken
=
originalSimpleName
.
GetFirstToken
(
true
,
false
,
true
,
true
);
SyntaxToken
tokenWithLeadingWhitespace
;
if
(
TryAddLeadingElasticTriviaIfNecessary
(
firstReplacementToken
,
firstOriginalToken
,
out
tokenWithLeadingWhitespace
))
if
(
TryAddLeadingElasticTriviaIfNecessary
(
firstReplacementToken
,
firstOriginalToken
,
out
var
tokenWithLeadingWhitespace
))
{
replacement
=
replacement
.
ReplaceToken
(
firstOriginalToken
,
tokenWithLeadingWhitespace
);
}
...
...
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.cs
浏览文件 @
c5c72d57
...
...
@@ -63,8 +63,7 @@ public override SyntaxToken Expand(SyntaxToken token, SemanticModel semanticMode
var
rewriter
=
new
Expander
(
semanticModel
,
expandInsideNode
,
false
,
cancellationToken
);
var
rewrittenToken
=
TryEscapeIdentifierToken
(
rewriter
.
VisitToken
(
token
),
token
.
Parent
,
semanticModel
).
WithAdditionalAnnotations
(
Simplifier
.
Annotation
);
SyntaxToken
rewrittenTokenWithElasticTrivia
;
if
(
TryAddLeadingElasticTriviaIfNecessary
(
rewrittenToken
,
token
,
out
rewrittenTokenWithElasticTrivia
))
if
(
TryAddLeadingElasticTriviaIfNecessary
(
rewrittenToken
,
token
,
out
var
rewrittenTokenWithElasticTrivia
))
{
return
rewrittenTokenWithElasticTrivia
;
}
...
...
@@ -114,9 +113,7 @@ public static SyntaxToken TryEscapeIdentifierToken(SyntaxToken syntaxToken, Synt
{
var
firstRewrittenToken
=
rewrittenNode
.
GetFirstToken
(
true
,
false
,
true
,
true
);
var
firstOriginalToken
=
originalNode
.
GetFirstToken
(
true
,
false
,
true
,
true
);
SyntaxToken
rewrittenTokenWithLeadingElasticTrivia
;
if
(
TryAddLeadingElasticTriviaIfNecessary
(
firstRewrittenToken
,
firstOriginalToken
,
out
rewrittenTokenWithLeadingElasticTrivia
))
if
(
TryAddLeadingElasticTriviaIfNecessary
(
firstRewrittenToken
,
firstOriginalToken
,
out
var
rewrittenTokenWithLeadingElasticTrivia
))
{
return
rewrittenNode
.
ReplaceToken
(
firstRewrittenToken
,
rewrittenTokenWithLeadingElasticTrivia
);
}
...
...
src/Workspaces/CSharp/Portable/Utilities/CompilationOptionsConversion.cs
浏览文件 @
c5c72d57
...
...
@@ -21,8 +21,7 @@ internal static class CompilationOptionsConversion
default
:
if
(!
string
.
IsNullOrEmpty
(
projectLanguageVersion
))
{
int
version
;
if
(
int
.
TryParse
(
projectLanguageVersion
,
out
version
))
if
(
int
.
TryParse
(
projectLanguageVersion
,
out
var
version
))
{
return
(
LanguageVersion
)
version
;
}
...
...
src/Workspaces/CSharp/Portable/Utilities/FormattingRangeHelper.cs
浏览文件 @
c5c72d57
...
...
@@ -291,8 +291,7 @@ private static SyntaxToken GetPreviousTokenIfNotFirstTokenInTree(SyntaxToken tok
public
static
bool
AreTwoTokensOnSameLine
(
SyntaxToken
token1
,
SyntaxToken
token2
)
{
var
tree
=
token1
.
SyntaxTree
;
var
text
=
default
(
SourceText
);
if
(
tree
!=
null
&&
tree
.
TryGetText
(
out
text
))
if
(
tree
!=
null
&&
tree
.
TryGetText
(
out
var
text
))
{
return
text
.
AreOnSameLine
(
token1
,
token2
);
}
...
...
src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs
浏览文件 @
c5c72d57
...
...
@@ -667,10 +667,7 @@ protected override bool ConversionsAreCompatible(SemanticModel originalModel, Ex
protected
override
bool
ConversionsAreCompatible
(
ExpressionSyntax
originalExpression
,
ITypeSymbol
originalTargetType
,
ExpressionSyntax
newExpression
,
ITypeSymbol
newTargetType
)
{
Conversion
?
originalConversion
=
null
;
Conversion
?
newConversion
=
null
;
this
.
GetConversions
(
originalExpression
,
originalTargetType
,
newExpression
,
newTargetType
,
out
originalConversion
,
out
newConversion
);
this
.
GetConversions
(
originalExpression
,
originalTargetType
,
newExpression
,
newTargetType
,
out
var
originalConversion
,
out
var
newConversion
);
if
(
originalConversion
==
null
||
newConversion
==
null
)
{
...
...
src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs
浏览文件 @
c5c72d57
...
...
@@ -34,8 +34,7 @@ internal static partial class UsingsAndExternAliasesOrganizer
{
// If there is a banner comment that precedes the nodes,
// then remove it and store it for later.
IEnumerable
<
SyntaxTrivia
>
leadingTrivia
;
initialList
[
0
]
=
initialList
[
0
].
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
leadingTrivia
);
initialList
[
0
]
=
initialList
[
0
].
GetNodeWithoutLeadingBannerAndPreprocessorDirectives
(
out
var
leadingTrivia
);
var
comparer
=
placeSystemNamespaceFirst
?
UsingsAndExternAliasesDirectiveComparer
.
SystemFirstInstance
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录