Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0b767d7b
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,发现更多精彩内容 >>
提交
0b767d7b
编写于
6月 04, 2020
作者:
A
Andy Gocke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adjust tests from comments
上级
3b8cccc3
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
79 addition
and
1 deletion
+79
-1
src/Compilers/CSharp/Test/Symbol/Symbols/Source/RecordTests.cs
...ompilers/CSharp/Test/Symbol/Symbols/Source/RecordTests.cs
+78
-0
src/Compilers/CSharp/Test/Syntax/Parsing/RecordParsing.cs
src/Compilers/CSharp/Test/Syntax/Parsing/RecordParsing.cs
+1
-1
未找到文件。
src/Compilers/CSharp/Test/Symbol/Symbols/Source/RecordTests.cs
浏览文件 @
0b767d7b
...
...
@@ -1071,5 +1071,83 @@ .maxstack 2
IL_001b: ret
}"
);
}
[
Fact
]
public
void
DataClassAndStruct
()
{
var
src
=
@"
data class C1 { }
data class C2(int X, int Y);
data struct S1 { }
data struct S2(int X, int Y);"
;
var
comp
=
CreateCompilation
(
src
);
comp
.
VerifyDiagnostics
(
// error CS8805: Program using top-level statements must be an executable.
Diagnostic
(
ErrorCode
.
ERR_SimpleProgramNotAnExecutable
).
WithLocation
(
1
,
1
),
// (2,1): error CS0116: A namespace cannot directly contain members such as fields or methods
// data class C1 { }
Diagnostic
(
ErrorCode
.
ERR_NamespaceUnexpected
,
"data"
).
WithLocation
(
2
,
1
),
// (3,1): error CS0116: A namespace cannot directly contain members such as fields or methods
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_NamespaceUnexpected
,
"data"
).
WithLocation
(
3
,
1
),
// (3,14): error CS1514: { expected
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_LbraceExpected
,
"("
).
WithLocation
(
3
,
14
),
// (3,14): error CS1513: } expected
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_RbraceExpected
,
"("
).
WithLocation
(
3
,
14
),
// (3,14): error CS8803: Top-level statements must precede namespace and type declarations.
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_TopLevelStatementAfterNamespaceOrType
,
"(int X, int Y);"
).
WithLocation
(
3
,
14
),
// (3,14): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_IllegalStatement
,
"(int X, int Y)"
).
WithLocation
(
3
,
14
),
// (3,15): error CS8185: A declaration is not allowed in this context.
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_DeclarationExpressionNotPermitted
,
"int X"
).
WithLocation
(
3
,
15
),
// (3,15): error CS0165: Use of unassigned local variable 'X'
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_UseDefViolation
,
"int X"
).
WithArguments
(
"X"
).
WithLocation
(
3
,
15
),
// (3,22): error CS8185: A declaration is not allowed in this context.
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_DeclarationExpressionNotPermitted
,
"int Y"
).
WithLocation
(
3
,
22
),
// (3,22): error CS0165: Use of unassigned local variable 'Y'
// data class C2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_UseDefViolation
,
"int Y"
).
WithArguments
(
"Y"
).
WithLocation
(
3
,
22
),
// (4,1): error CS0116: A namespace cannot directly contain members such as fields or methods
// data struct S1 { }
Diagnostic
(
ErrorCode
.
ERR_NamespaceUnexpected
,
"data"
).
WithLocation
(
4
,
1
),
// (5,1): error CS0116: A namespace cannot directly contain members such as fields or methods
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_NamespaceUnexpected
,
"data"
).
WithLocation
(
5
,
1
),
// (5,15): error CS1514: { expected
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_LbraceExpected
,
"("
).
WithLocation
(
5
,
15
),
// (5,15): error CS1513: } expected
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_RbraceExpected
,
"("
).
WithLocation
(
5
,
15
),
// (5,15): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_IllegalStatement
,
"(int X, int Y)"
).
WithLocation
(
5
,
15
),
// (5,16): error CS8185: A declaration is not allowed in this context.
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_DeclarationExpressionNotPermitted
,
"int X"
).
WithLocation
(
5
,
16
),
// (5,16): error CS0165: Use of unassigned local variable 'X'
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_UseDefViolation
,
"int X"
).
WithArguments
(
"X"
).
WithLocation
(
5
,
16
),
// (5,20): error CS0128: A local variable or function named 'X' is already defined in this scope
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_LocalDuplicate
,
"X"
).
WithArguments
(
"X"
).
WithLocation
(
5
,
20
),
// (5,23): error CS8185: A declaration is not allowed in this context.
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_DeclarationExpressionNotPermitted
,
"int Y"
).
WithLocation
(
5
,
23
),
// (5,23): error CS0165: Use of unassigned local variable 'Y'
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_UseDefViolation
,
"int Y"
).
WithArguments
(
"Y"
).
WithLocation
(
5
,
23
),
// (5,27): error CS0128: A local variable or function named 'Y' is already defined in this scope
// data struct S2(int X, int Y);
Diagnostic
(
ErrorCode
.
ERR_LocalDuplicate
,
"Y"
).
WithArguments
(
"Y"
).
WithLocation
(
5
,
27
)
);
}
}
}
src/Compilers/CSharp/Test/Syntax/Parsing/RecordParsing.cs
浏览文件 @
0b767d7b
...
...
@@ -1314,7 +1314,7 @@ public void WithParsing19()
}
[
Fact
]
public
void
InvalidBase
()
public
void
BadParameterListAndBaseListOnClass
()
{
var
text
=
@
$"
class
C
(
int
X
,
int
Y
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录