Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e7080140
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,发现更多精彩内容 >>
提交
e7080140
编写于
6月 28, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use switch expressoin
上级
0d027cee
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
50 addition
and
96 deletion
+50
-96
src/EditorFeatures/Core/Wrapping/SeparatedSyntaxList/SeparatedSyntaxListCodeActionComputer.cs
...aratedSyntaxList/SeparatedSyntaxListCodeActionComputer.cs
+6
-9
src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs
...Interface/AbstractImplementInterfaceService.CodeAction.cs
+5
-8
src/VisualStudio/Core/Def/Telemetry/VSTelemetryLogger.cs
src/VisualStudio/Core/Def/Telemetry/VSTelemetryLogger.cs
+5
-8
src/VisualStudio/Core/Impl/CodeModel/MethodXml/AbstractMethodXmlBuilder.cs
...Core/Impl/CodeModel/MethodXml/AbstractMethodXmlBuilder.cs
+8
-16
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
...s/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
+12
-24
src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs
.../Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs
+6
-12
src/Workspaces/Core/Portable/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
...rtable/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
+8
-19
未找到文件。
src/EditorFeatures/Core/Wrapping/SeparatedSyntaxList/SeparatedSyntaxListCodeActionComputer.cs
浏览文件 @
e7080140
...
...
@@ -308,16 +308,13 @@ private async Task<WrappingGroup> GetWrapEveryGroupAsync()
}
private
string
GetNestedCodeActionTitle
(
WrappingStyle
wrappingStyle
)
{
switch
(
wrappingStyle
)
=>
wrappingStyle
switch
{
case
WrappingStyle
.
WrapFirst_IndentRest
:
return
Wrapper
.
Indent_all_items
;
case
WrappingStyle
.
UnwrapFirst_AlignRest
:
return
Wrapper
.
Align_wrapped_items
;
case
WrappingStyle
.
UnwrapFirst_IndentRest
:
return
Wrapper
.
Indent_wrapped_items
;
default
:
throw
ExceptionUtilities
.
UnexpectedValue
(
wrappingStyle
);
}
}
WrappingStyle
.
WrapFirst_IndentRest
=>
Wrapper
.
Indent_all_items
,
WrappingStyle
.
UnwrapFirst_AlignRest
=>
Wrapper
.
Align_wrapped_items
,
WrappingStyle
.
UnwrapFirst_IndentRest
=>
Wrapper
.
Indent_wrapped_items
,
_
=>
throw
ExceptionUtilities
.
UnexpectedValue
(
wrappingStyle
),
};
private
ImmutableArray
<
Edit
>
GetWrapEachEdits
(
WrappingStyle
wrappingStyle
,
SyntaxTrivia
indentationTrivia
)
...
...
src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs
浏览文件 @
e7080140
...
...
@@ -143,15 +143,12 @@ public override string Title
public
override
string
EquivalenceKey
=>
_equivalenceKey
;
private
static
string
GetDescription
(
ISymbol
throughMember
)
{
switch
(
throughMember
)
=>
throughMember
switch
{
case
IFieldSymbol
field
:
return
field
.
Name
;
case
IPropertySymbol
property
:
return
property
.
Name
;
default
:
throw
new
InvalidOperationException
();
}
}
IFieldSymbol
field
=>
field
.
Name
,
IPropertySymbol
property
=>
property
.
Name
,
_
=>
throw
new
InvalidOperationException
(),
};
protected
override
Task
<
Document
>
GetChangedDocumentAsync
(
CancellationToken
cancellationToken
)
{
...
...
src/VisualStudio/Core/Def/Telemetry/VSTelemetryLogger.cs
浏览文件 @
e7080140
...
...
@@ -121,15 +121,12 @@ private object CreateAndStartScope(LogType kind, FunctionId functionId)
// TelemetryScope<Operation> can't be shared
var
eventName
=
functionId
.
GetEventName
();
switch
(
kind
)
return
kind
switch
{
case
LogType
.
Trace
:
return
_session
.
StartOperation
(
eventName
);
case
LogType
.
UserAction
:
return
_session
.
StartUserTask
(
eventName
);
default
:
return
FatalError
.
Report
(
new
Exception
(
$"unknown type:
{
kind
}
"
));
}
LogType
.
Trace
=>
_session
.
StartOperation
(
eventName
),
LogType
.
UserAction
=>
_session
.
StartUserTask
(
eventName
),
_
=>
(
object
)
FatalError
.
Report
(
new
Exception
(
$"unknown type:
{
kind
}
"
)),
};
}
private
TelemetryEvent
CreateTelemetryEvent
(
FunctionId
functionId
,
KeyValueLogMessage
logMessage
)
...
...
src/VisualStudio/Core/Impl/CodeModel/MethodXml/AbstractMethodXmlBuilder.cs
浏览文件 @
e7080140
...
...
@@ -136,23 +136,15 @@ private void AppendLeafTag(string name)
}
private
static
string
GetBinaryOperatorKindText
(
BinaryOperatorKind
kind
)
{
switch
(
kind
)
=>
kind
switch
{
case
BinaryOperatorKind
.
Plus
:
return
"plus"
;
case
BinaryOperatorKind
.
BitwiseOr
:
return
"bitor"
;
case
BinaryOperatorKind
.
BitwiseAnd
:
return
"bitand"
;
case
BinaryOperatorKind
.
Concatenate
:
return
"concatenate"
;
case
BinaryOperatorKind
.
AddDelegate
:
return
"adddelegate"
;
default
:
throw
new
InvalidOperationException
(
"Invalid BinaryOperatorKind: "
+
kind
.
ToString
());
}
}
BinaryOperatorKind
.
Plus
=>
"plus"
,
BinaryOperatorKind
.
BitwiseOr
=>
"bitor"
,
BinaryOperatorKind
.
BitwiseAnd
=>
"bitand"
,
BinaryOperatorKind
.
Concatenate
=>
"concatenate"
,
BinaryOperatorKind
.
AddDelegate
=>
"adddelegate"
,
_
=>
throw
new
InvalidOperationException
(
"Invalid BinaryOperatorKind: "
+
kind
.
ToString
()),
};
private
static
string
GetVariableKindText
(
VariableKind
kind
)
=>
kind
switch
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
浏览文件 @
e7080140
...
...
@@ -2761,34 +2761,22 @@ private static AccessorListSyntax GetAccessorList(SyntaxNode declaration)
};
private
static
bool
CanHaveAccessors
(
SyntaxNode
declaration
)
{
switch
(
declaration
.
Kind
())
=>
declaration
.
Kind
()
switch
{
case
SyntaxKind
.
PropertyDeclaration
:
return
((
PropertyDeclarationSyntax
)
declaration
).
ExpressionBody
==
null
;
case
SyntaxKind
.
IndexerDeclaration
:
return
((
IndexerDeclarationSyntax
)
declaration
).
ExpressionBody
==
null
;
case
SyntaxKind
.
EventDeclaration
:
return
true
;
default
:
return
false
;
}
}
SyntaxKind
.
PropertyDeclaration
=>
((
PropertyDeclarationSyntax
)
declaration
).
ExpressionBody
==
null
,
SyntaxKind
.
IndexerDeclaration
=>
((
IndexerDeclarationSyntax
)
declaration
).
ExpressionBody
==
null
,
SyntaxKind
.
EventDeclaration
=>
true
,
_
=>
false
,
};
private
static
SyntaxNode
WithAccessorList
(
SyntaxNode
declaration
,
AccessorListSyntax
accessorList
)
{
switch
(
declaration
.
Kind
())
=>
declaration
.
Kind
()
switch
{
case
SyntaxKind
.
PropertyDeclaration
:
return
((
PropertyDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
);
case
SyntaxKind
.
IndexerDeclaration
:
return
((
PropertyDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
);
case
SyntaxKind
.
EventDeclaration
:
return
((
EventDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
);
default
:
return
declaration
;
}
}
SyntaxKind
.
PropertyDeclaration
=>
((
PropertyDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
),
SyntaxKind
.
IndexerDeclaration
=>
((
PropertyDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
),
SyntaxKind
.
EventDeclaration
=>
((
EventDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
),
_
=>
declaration
,
};
private
static
AccessorListSyntax
AsAccessorList
(
IEnumerable
<
SyntaxNode
>
nodes
,
SyntaxKind
parentKind
)
{
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs
浏览文件 @
e7080140
...
...
@@ -65,19 +65,13 @@ private void AddInitializerSuppressOperations(List<SuppressOperation> list, Synt
}
private
InitializerExpressionSyntax
GetInitializerNode
(
SyntaxNode
node
)
{
switch
(
node
)
=>
node
switch
{
case
ObjectCreationExpressionSyntax
objectCreationNode
:
return
objectCreationNode
.
Initializer
;
case
ArrayCreationExpressionSyntax
arrayCreationNode
:
return
arrayCreationNode
.
Initializer
;
case
ImplicitArrayCreationExpressionSyntax
implicitArrayNode
:
return
implicitArrayNode
.
Initializer
;
}
return
null
;
}
ObjectCreationExpressionSyntax
objectCreationNode
=>
objectCreationNode
.
Initializer
,
ArrayCreationExpressionSyntax
arrayCreationNode
=>
arrayCreationNode
.
Initializer
,
ImplicitArrayCreationExpressionSyntax
implicitArrayNode
=>
implicitArrayNode
.
Initializer
,
_
=>
null
,
};
private
SyntaxToken
?
GetLastTokenOfType
(
SyntaxNode
node
)
{
...
...
src/Workspaces/Core/Portable/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
浏览文件 @
e7080140
...
...
@@ -536,26 +536,15 @@ private bool FirstLineBlank()
// next trivia is moved to next line or already on a new line, use indentation
if
(
rule
.
Lines
>
0
||
lineColumnAfterExistingWhitespace
.
WhitespaceOnly
)
{
switch
(
rule
.
IndentationOperation
)
return
rule
.
IndentationOperation
switch
{
case
LineColumnRule
.
IndentationOperations
.
Absolute
:
return
Math
.
Max
(
0
,
rule
.
Indentation
);
case
LineColumnRule
.
IndentationOperations
.
Default
:
return
this
.
Context
.
GetBaseIndentation
(
trivia2
.
RawKind
==
0
?
this
.
EndPosition
:
trivia2
.
SpanStart
);
case
LineColumnRule
.
IndentationOperations
.
Given
:
return
(
trivia2
.
RawKind
==
0
)
?
this
.
Spaces
:
Math
.
Max
(
0
,
_indentation
);
case
LineColumnRule
.
IndentationOperations
.
Follow
:
return
Math
.
Max
(
0
,
lineColumnBeforeTrivia1
.
Column
);
case
LineColumnRule
.
IndentationOperations
.
Preserve
:
return
existingWhitespaceBetween
.
Spaces
;
default
:
throw
ExceptionUtilities
.
UnexpectedValue
(
rule
.
IndentationOperation
);
}
LineColumnRule
.
IndentationOperations
.
Absolute
=>
Math
.
Max
(
0
,
rule
.
Indentation
),
LineColumnRule
.
IndentationOperations
.
Default
=>
this
.
Context
.
GetBaseIndentation
(
trivia2
.
RawKind
==
0
?
this
.
EndPosition
:
trivia2
.
SpanStart
),
LineColumnRule
.
IndentationOperations
.
Given
=>
(
trivia2
.
RawKind
==
0
)
?
this
.
Spaces
:
Math
.
Max
(
0
,
_indentation
),
LineColumnRule
.
IndentationOperations
.
Follow
=>
Math
.
Max
(
0
,
lineColumnBeforeTrivia1
.
Column
),
LineColumnRule
.
IndentationOperations
.
Preserve
=>
existingWhitespaceBetween
.
Spaces
,
_
=>
throw
ExceptionUtilities
.
UnexpectedValue
(
rule
.
IndentationOperation
),
};
}
// okay, we are not on a its own line, use space information
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录