Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
5191bfdc
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,发现更多精彩内容 >>
未验证
提交
5191bfdc
编写于
10月 12, 2018
作者:
S
Sam Harwell
提交者:
GitHub
10月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29800 from sharwell/missing-parens
Do not remove parentheses from incomplete expressions
上级
9950c9ee
84791429
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
0 deletion
+37
-0
src/EditorFeatures/CSharpTest/RemoveUnnecessaryParentheses/RemoveUnnecessaryParenthesesTests.cs
...necessaryParentheses/RemoveUnnecessaryParenthesesTests.cs
+14
-0
src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryParentheses/RemoveUnnecessaryParenthesesTests.vb
...necessaryParentheses/RemoveUnnecessaryParenthesesTests.vb
+11
-0
src/Workspaces/CSharp/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.cs
...ble/Extensions/ParenthesizedExpressionSyntaxExtensions.cs
+6
-0
src/Workspaces/VisualBasic/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.vb
...ble/Extensions/ParenthesizedExpressionSyntaxExtensions.vb
+6
-0
未找到文件。
src/EditorFeatures/CSharpTest/RemoveUnnecessaryParentheses/RemoveUnnecessaryParenthesesTests.cs
浏览文件 @
5191bfdc
...
...
@@ -44,6 +44,20 @@ void M()
}"
,
new
TestParameters
(
options
:
IgnoreAllParentheses
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnnecessaryParentheses
)]
[
WorkItem
(
29736
,
"https://github.com/dotnet/roslyn/issues/29736"
)]
public
async
Task
TestVariableInitializer_TestMissingParenthesis
()
{
await
TestMissingAsync
(
@"class C
{
void M()
{
int x = $$(1;
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnnecessaryParentheses
)]
public
async
Task
TestArithmeticRequiredForClarity1
()
{
...
...
src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryParentheses/RemoveUnnecessaryParenthesesTests.vb
浏览文件 @
5191bfdc
...
...
@@ -38,6 +38,17 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.RemoveUnnecessaryP
end class"
,
New
TestParameters
(
options
:
=
IgnoreAllParentheses
))
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnnecessaryParentheses
)
>
<
WorkItem
(
29736
,
"https://github.com/dotnet/roslyn/issues/29736"
)
>
Public
Async
Function
TestVariableInitializer_MissingParenthesis
()
As
Task
Await
TestMissingAsync
(
"class C
sub M()
dim x = $$(1
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnnecessaryParentheses
)
>
Public
Async
Function
TestArithmeticRequiredForClarity1
()
As
Task
Await
TestMissingAsync
(
...
...
src/Workspaces/CSharp/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.cs
浏览文件 @
5191bfdc
...
...
@@ -14,6 +14,12 @@ internal static class ParenthesizedExpressionSyntaxExtensions
{
public
static
bool
CanRemoveParentheses
(
this
ParenthesizedExpressionSyntax
node
,
SemanticModel
semanticModel
)
{
if
(
node
.
OpenParenToken
.
IsMissing
||
node
.
CloseParenToken
.
IsMissing
)
{
// int x = (3;
return
false
;
}
var
expression
=
node
.
Expression
;
// The 'direct' expression that contains this parenthesized node. Note: in the case
...
...
src/Workspaces/VisualBasic/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.vb
浏览文件 @
5191bfdc
...
...
@@ -42,6 +42,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Optional
cancellationToken
As
CancellationToken
=
Nothing
)
As
Boolean
If
node
.
OpenParenToken
.
IsMissing
OrElse
node
.
CloseParenToken
.
IsMissing
Then
' Cases:
' (3
Return
False
End
If
Dim
expression
=
node
.
Expression
' Cases:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录