Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET
Roslyn
提交
0ca43e5b
R
Roslyn
项目概览
dotNET
/
Roslyn
通知
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,发现更多精彩内容 >>
未验证
提交
0ca43e5b
编写于
12月 13, 2019
作者:
C
Charles Stoner
提交者:
GitHub
12月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce complexity of ParseStatementNoDeclaration (#40290)
上级
97ff81a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
96 addition
and
6 deletion
+96
-6
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
+3
-3
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
+93
-3
未找到文件。
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
浏览文件 @
0ca43e5b
...
...
@@ -6480,7 +6480,7 @@ private StatementSyntax ParseStatementNoDeclaration(bool allowAnyExpression)
}
else
{
return
this
.
ParseLocalDeclarationStatement
(
parseAwaitKeyword
());
return
this
.
ParseLocalDeclarationStatement
(
parseAwaitKeyword
(
MessageID
.
None
));
}
}
else
if
(
this
.
IsPossibleLabeledStatement
())
...
...
@@ -6523,11 +6523,11 @@ bool isPossibleAwaitUsing()
this
.
PeekToken
(
1
).
Kind
==
SyntaxKind
.
UsingKeyword
;
}
SyntaxToken
parseAwaitKeyword
(
MessageID
?
feature
=
null
)
SyntaxToken
parseAwaitKeyword
(
MessageID
feature
)
{
Debug
.
Assert
(
this
.
CurrentToken
.
ContextualKind
==
SyntaxKind
.
AwaitKeyword
);
SyntaxToken
awaitToken
=
this
.
EatContextualToken
(
SyntaxKind
.
AwaitKeyword
);
return
feature
.
HasValue
?
CheckFeatureAvailability
(
awaitToken
,
feature
.
GetValueOrDefault
()
)
:
awaitToken
;
return
feature
!=
MessageID
.
None
?
CheckFeatureAvailability
(
awaitToken
,
feature
)
:
awaitToken
;
}
}
...
...
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
浏览文件 @
0ca43e5b
...
...
@@ -2,10 +2,7 @@
using
Roslyn.Test.Utilities
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Xunit
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
...
...
@@ -43,6 +40,54 @@ private static void RunInThread(Action action)
}
}
private
static
void
RunTest
(
int
expectedDepth
,
Action
<
int
>
runTest
)
{
if
(
runTestAndCatch
(
expectedDepth
))
{
return
;
}
int
minDepth
=
0
;
int
maxDepth
=
expectedDepth
;
int
actualDepth
;
while
(
true
)
{
int
depth
=
(
maxDepth
-
minDepth
)
/
2
+
minDepth
;
if
(
depth
<=
minDepth
)
{
actualDepth
=
minDepth
;
break
;
}
if
(
depth
>=
maxDepth
)
{
actualDepth
=
maxDepth
;
break
;
}
if
(
runTestAndCatch
(
depth
))
{
minDepth
=
depth
;
}
else
{
maxDepth
=
depth
;
}
}
Assert
.
Equal
(
expectedDepth
,
actualDepth
);
bool
runTestAndCatch
(
int
depth
)
{
try
{
runTest
(
depth
);
return
true
;
}
catch
(
Exception
)
{
return
false
;
}
}
}
// This test is a canary attempting to make sure that we don't regress the # of fluent calls that
// the compiler can handle.
[
WorkItem
(
16669
,
"https://github.com/dotnet/roslyn/issues/16669"
)]
...
...
@@ -175,5 +220,50 @@ public static void Main(string[] args)
});
}
}
[
ConditionalFact
(
typeof
(
WindowsOnly
))]
public
void
NestedIfStatements
()
{
int
nestingLevel
=
(
ExecutionConditionUtil
.
Architecture
,
ExecutionConditionUtil
.
Configuration
)
switch
{
(
ExecutionArchitecture
.
x86
,
ExecutionConfiguration
.
Debug
)
=>
310
,
(
ExecutionArchitecture
.
x86
,
ExecutionConfiguration
.
Release
)
=>
1650
,
(
ExecutionArchitecture
.
x64
,
ExecutionConfiguration
.
Debug
)
=>
200
,
(
ExecutionArchitecture
.
x64
,
ExecutionConfiguration
.
Release
)
=>
780
,
_
=>
throw
new
Exception
(
$"Unexpected configuration
{
ExecutionConditionUtil
.
Architecture
}
{
ExecutionConditionUtil
.
Configuration
}
"
)
};
RunTest
(
nestingLevel
,
runTest
);
static
void
runTest
(
int
nestingLevel
)
{
var
builder
=
new
StringBuilder
();
builder
.
AppendLine
(
@"class Program
{
static bool F(int i) => true;
static void Main()
{"
);
for
(
int
i
=
0
;
i
<
nestingLevel
;
i
++)
{
builder
.
AppendLine
(
$@" if (F(
{
i
}
))
{{
");
}
for
(
int
i
=
0
;
i
<
nestingLevel
;
i
++)
{
builder
.
AppendLine
(
" }"
);
}
builder
.
AppendLine
(
@" }
}"
);
var
source
=
builder
.
ToString
();
RunInThread
(()
=>
{
var
comp
=
CreateCompilation
(
source
);
comp
.
VerifyDiagnostics
();
});
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录