Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
de4866d3
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,发现更多精彩内容 >>
提交
de4866d3
编写于
11月 19, 2018
作者:
N
Neal Gafter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename WellKnownMembers
Add test for missing exceptions.
上级
1c99242c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
4 deletion
+36
-4
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_SwitchExpression.cs
.../Lowering/LocalRewriter/LocalRewriter_SwitchExpression.cs
+2
-2
src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs
src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs
+32
-0
src/Compilers/Core/Portable/WellKnownMember.cs
src/Compilers/Core/Portable/WellKnownMember.cs
+2
-2
未找到文件。
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_SwitchExpression.cs
浏览文件 @
de4866d3
...
...
@@ -91,9 +91,9 @@ private BoundExpression LowerSwitchExpression(BoundSwitchExpression node)
var
thrownExpression
=
(
optionalSavedInput
!=
null
&&
implicitConversionExists
(
optionalSavedInput
,
objectType
)
&&
_factory
.
WellKnownMember
(
WellKnownMember
.
System_MatchFailureException__ctor
1
,
isOptional
:
true
)
is
MethodSymbol
newMatchFailureException1
)
_factory
.
WellKnownMember
(
WellKnownMember
.
System_MatchFailureException__ctor
Object
,
isOptional
:
true
)
is
MethodSymbol
newMatchFailureException1
)
?
_factory
.
New
(
newMatchFailureException1
,
_factory
.
Convert
(
objectType
,
optionalSavedInput
))
:
(
_factory
.
WellKnownMember
(
WellKnownMember
.
System_MatchFailureException__ctor
0
,
isOptional
:
true
)
is
MethodSymbol
newMatchFailureException0
)
(
_factory
.
WellKnownMember
(
WellKnownMember
.
System_MatchFailureException__ctor
,
isOptional
:
true
)
is
MethodSymbol
newMatchFailureException0
)
?
_factory
.
New
(
newMatchFailureException0
)
:
_factory
.
New
(
_factory
.
WellKnownMethod
(
WellKnownMember
.
System_InvalidOperationException__ctor
));
result
.
Add
(
_factory
.
Throw
(
thrownExpression
));
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs
浏览文件 @
de4866d3
...
...
@@ -1969,5 +1969,37 @@ .maxstack 1
IL_0016: ret
}"
);
}
[
Fact
]
public
void
MissingExceptions_01
()
{
var
source
=
@"namespace System {
public class Object { }
public abstract class ValueType { }
public struct Void { }
public struct Boolean { }
public struct Int32 { }
}
static class C {
public static bool M(int i) => i switch { 1 => true };
}
"
;
var
compilation
=
CreateEmptyCompilation
(
source
,
options
:
TestOptions
.
ReleaseDll
);
compilation
.
GetDiagnostics
().
Verify
(
// (9,38): warning CS8509: The switch expression does not handle all possible inputs (it is not exhaustive).
// public static bool M(int i) => i switch { 1 => true };
Diagnostic
(
ErrorCode
.
WRN_SwitchExpressionNotExhaustive
,
"switch"
).
WithLocation
(
9
,
38
)
);
compilation
.
GetEmitDiagnostics
().
Verify
(
// warning CS8021: No value for RuntimeMetadataVersion found. No assembly containing System.Object was found nor was a value for RuntimeMetadataVersion specified through options.
Diagnostic
(
ErrorCode
.
WRN_NoRuntimeMetadataVersion
).
WithLocation
(
1
,
1
),
// (9,36): error CS0656: Missing compiler required member 'System.InvalidOperationException..ctor'
// public static bool M(int i) => i switch { 1 => true };
Diagnostic
(
ErrorCode
.
ERR_MissingPredefinedMember
,
"i switch { 1 => true }"
).
WithArguments
(
"System.InvalidOperationException"
,
".ctor"
).
WithLocation
(
9
,
36
),
// (9,38): warning CS8509: The switch expression does not handle all possible inputs (it is not exhaustive).
// public static bool M(int i) => i switch { 1 => true };
Diagnostic
(
ErrorCode
.
WRN_SwitchExpressionNotExhaustive
,
"switch"
).
WithLocation
(
9
,
38
)
);
}
}
}
src/Compilers/Core/Portable/WellKnownMember.cs
浏览文件 @
de4866d3
...
...
@@ -483,8 +483,8 @@ internal enum WellKnownMember
System_Runtime_CompilerServices_ITuple__get_Length
,
System_InvalidOperationException__ctor
,
System_MatchFailureException__ctor
0
,
System_MatchFailureException__ctor
1
,
System_MatchFailureException__ctor
,
System_MatchFailureException__ctor
Object
,
Count
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录