Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4705c00d
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,发现更多精彩内容 >>
未验证
提交
4705c00d
编写于
10月 12, 2017
作者:
F
Fredric Silberberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed VB formatting, added an additional C# test.
上级
03b6c499
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
100 addition
and
0 deletion
+100
-0
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IUsingStatement.cs
...st/Semantic/IOperation/IOperationTests_IUsingStatement.cs
+99
-0
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IUsingStatement.vb
...st/Semantic/IOperation/IOperationTests_IUsingStatement.vb
+1
-0
未找到文件。
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IUsingStatement.cs
浏览文件 @
4705c00d
...
...
@@ -62,6 +62,68 @@ public static void M1()
VerifyOperationTreeAndDiagnosticsForTest
<
UsingStatementSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
public
void
IUsingStatement_MultipleNewVariable
()
{
string
source
=
@"
using System;
class C : IDisposable
{
public void Dispose()
{
}
public static void M1()
{
/*<bind>*/using (C c1 = new C(), c2 = new C())
{
Console.WriteLine(c1.ToString());
}/*</bind>*/
}
}
"
;
string
expectedOperationTree
=
@"
IUsingStatement (OperationKind.UsingStatement) (Syntax: 'using (C c1 ... }')
Resources:
IVariableDeclarationStatement (2 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'C c1 = new ... 2 = new C()')
IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'c1 = new C()')
Variables: Local_1: C c1
Initializer:
IObjectCreationExpression (Constructor: C..ctor()) (OperationKind.ObjectCreationExpression, Type: C) (Syntax: 'new C()')
Arguments(0)
Initializer:
null
IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'c2 = new C()')
Variables: Local_1: C c2
Initializer:
IObjectCreationExpression (Constructor: C..ctor()) (OperationKind.ObjectCreationExpression, Type: C) (Syntax: 'new C()')
Arguments(0)
Initializer:
null
Body:
IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... oString());')
Expression:
IInvocationExpression (void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... ToString())')
Instance Receiver:
null
Arguments(1):
IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'c1.ToString()')
IInvocationExpression (virtual System.String System.Object.ToString()) (OperationKind.InvocationExpression, Type: System.String) (Syntax: 'c1.ToString()')
Instance Receiver:
ILocalReferenceExpression: c1 (OperationKind.LocalReferenceExpression, Type: C) (Syntax: 'c1')
Arguments(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
=
DiagnosticDescription
.
None
;
VerifyOperationTreeAndDiagnosticsForTest
<
UsingStatementSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
public
void
IUsingStatement_SimpleUsingStatementExistingResource
()
...
...
@@ -782,5 +844,42 @@ public static void M1()
VerifyOperationTreeAndDiagnosticsForTest
<
IdentifierNameSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
public
void
IUsingStatement_UsingStatementSyntax_VariableDeclaratorSyntax
()
{
string
source
=
@"
using System;
class C : IDisposable
{
public void Dispose()
{
}
public static void M1()
{
using (C /*<bind>*/c1 = new C()/*</bind>*/, c2 = new C())
{
Console.WriteLine(c1.ToString());
}
}
}
"
;
string
expectedOperationTree
=
@"
IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'c1 = new C()')
Variables: Local_1: C c1
Initializer:
IObjectCreationExpression (Constructor: C..ctor()) (OperationKind.ObjectCreationExpression, Type: C) (Syntax: 'new C()')
Arguments(0)
Initializer:
null
"
;
var
expectedDiagnostics
=
DiagnosticDescription
.
None
;
VerifyOperationTreeAndDiagnosticsForTest
<
VariableDeclaratorSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
}
}
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IUsingStatement.vb
浏览文件 @
4705c00d
...
...
@@ -709,6 +709,7 @@ BC36010: 'Using' operand of type 'Object' must implement 'System.IDisposable'.
VerifyOperationTreeAndDiagnosticsForTest
(
Of
UsingBlockSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
End
Sub
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
Fact
()
>
Public
Sub
IUsingStatement_UsingWithoutSavedReference
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录