Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
24f9a505
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,体验更适合开发者的 AI 搜索 >>
提交
24f9a505
编写于
10月 03, 2017
作者:
M
Manish Vasani
提交者:
GitHub
10月 03, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22444 from mavasani/IOmittedArgumentExpression
Add unit tests for omitted arguments
上级
63b321a7
095381b5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
0 deletion
+75
-0
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs
...arp/Test/Semantic/IOperation/IOperationTests_IArgument.cs
+39
-0
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IArgument.vb
...sic/Test/Semantic/IOperation/IOperationTests_IArgument.vb
+36
-0
未找到文件。
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs
浏览文件 @
24f9a505
...
@@ -1191,6 +1191,45 @@ void M2(int x = 0)
...
@@ -1191,6 +1191,45 @@ void M2(int x = 0)
VerifyOperationTreeAndDiagnosticsForTest
<
InvocationExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
VerifyOperationTreeAndDiagnosticsForTest
<
InvocationExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
public
void
TestOmittedArgument
()
{
string
source
=
@"
class P
{
void M1()
{
/*<bind>*/M2(1,)/*</bind>*/;
}
void M2(int y, int x = 0)
{ }
}
"
;
string
expectedOperationTree
=
@"
IInvocationExpression ( void P.M2(System.Int32 y, [System.Int32 x = 0])) (OperationKind.InvocationExpression, Type: System.Void, IsInvalid) (Syntax: 'M2(1,)')
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'M2')
Arguments(2):
IArgument (ArgumentKind.Explicit, Matching Parameter: null) (OperationKind.Argument) (Syntax: '1')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
IArgument (ArgumentKind.Explicit, Matching Parameter: null) (OperationKind.Argument, IsInvalid) (Syntax: '')
IInvalidExpression (OperationKind.InvalidExpression, Type: null, IsInvalid) (Syntax: '')
Children(0)
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
"
;
var
expectedDiagnostics
=
new
DiagnosticDescription
[]
{
// file.cs(6,24): error CS1525: Invalid expression term ')'
// /*<bind>*/M2(1,)/*</bind>*/;
Diagnostic
(
ErrorCode
.
ERR_InvalidExprTerm
,
")"
).
WithArguments
(
")"
).
WithLocation
(
6
,
24
)
};
VerifyOperationTreeAndDiagnosticsForTest
<
InvocationExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
[
Fact
]
public
void
WrongArgumentType
()
public
void
WrongArgumentType
()
...
...
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IArgument.vb
浏览文件 @
24f9a505
...
@@ -744,6 +744,42 @@ BC30057: Too many arguments to 'Public Sub M2(x As Integer, [y As Integer = 0],
...
@@ -744,6 +744,42 @@ BC30057: Too many arguments to 'Public Sub M2(x As Integer, [y As Integer = 0],
VerifyOperationTreeAndDiagnosticsForTest
(
Of
InvocationExpressionSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
VerifyOperationTreeAndDiagnosticsForTest
(
Of
InvocationExpressionSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
End
Sub
End
Sub
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
Fact
()
>
Public
Sub
TestValidDynamicInvocation_OmittedArgument
()
Dim
source
=
<
!
[
CDATA
[
Option Strict Off
Class
P
Sub
M1
(
o
As
Object
)
M2
(
o
,,)
'BIND:"M2(o,,)"
End
Sub
Sub
M2
(
x
As
Integer
,
Optional
y
As
Integer
=
0
,
Optional
z
As
Integer
=
0
)
End
Sub
Sub
M2
(
x
As
Double
,
Optional
y
As
Integer
=
0
,
Optional
z
As
Integer
=
0
)
End
Sub
End
Class
]]
>
.
Value
Dim
expectedOperationTree
=
<
!
[
CDATA
[
IDynamicInvocationExpression
(
OperationKind
.
DynamicInvocationExpression
,
Type
:
System
.
Object
)
(
Syntax
:
'M2(o,,)')
Expression
:
IDynamicMemberReferenceExpression
(
Member
Name
:
"M2"
,
Containing
Type
:
null
)
(
OperationKind
.
DynamicMemberReferenceExpression
,
Type
:
System
.
Object
)
(
Syntax
:
'M2')
Type
Arguments
(
0
)
Instance
Receiver
:
IInstanceReferenceExpression
(
OperationKind
.
InstanceReferenceExpression
,
Type
:
P
)
(
Syntax
:
'M2')
Arguments
(
3
):
IParameterReferenceExpression
:
o
(
OperationKind
.
ParameterReferenceExpression
,
Type
:
System
.
Object
)
(
Syntax
:
'o')
IOmittedArgumentExpression
(
OperationKind
.
OmittedArgumentExpression
,
Type
:
System
.
Object
)
(
Syntax
:
'')
IOmittedArgumentExpression
(
OperationKind
.
OmittedArgumentExpression
,
Type
:
System
.
Object
)
(
Syntax
:
'')
ArgumentNames
(
0
)
ArgumentRefKinds
:
null
]]
>
.
Value
Dim
expectedDiagnostics
=
String
.
Empty
VerifyOperationTreeAndDiagnosticsForTest
(
Of
InvocationExpressionSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
End
Sub
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
Fact
()
>
<
Fact
()
>
Public
Sub
Error_OmittingParamArrayArgument
()
Public
Sub
Error_OmittingParamArrayArgument
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录