Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c2c0fcf6
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,发现更多精彩内容 >>
提交
c2c0fcf6
编写于
10月 25, 2016
作者:
O
Omar Tawfik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added missing warnings to tests
上级
116b720a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
24 deletion
+45
-24
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs
...rs/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs
+10
-8
src/Compilers/CSharp/Test/Symbol/Symbols/OverriddenOrHiddenMembersTests.cs
...arp/Test/Symbol/Symbols/OverriddenOrHiddenMembersTests.cs
+9
-3
src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs
src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs
+25
-12
src/Compilers/Test/Utilities/CSharp/DiagnosticTestUtilities.cs
...ompilers/Test/Utilities/CSharp/DiagnosticTestUtilities.cs
+1
-1
未找到文件。
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs
浏览文件 @
c2c0fcf6
...
...
@@ -1631,26 +1631,28 @@ public static void Main()
comp
.
VerifyDiagnostics
(
// (12,21): warning CS0108: 'Base.Derived.Method()' hides inherited member 'Base.Method()'. Use the new keyword if hiding was intended.
// static void Method() { Console.WriteLine("Derived.Method()"); }
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Method"
).
WithArguments
(
"Base.Derived.Method()"
,
"Base.Method()"
),
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Method"
).
WithArguments
(
"Base.Derived.Method()"
,
"Base.Method()"
)
.
WithLocation
(
12
,
21
)
,
// (62,13): warning CS0108: 'Base2.Derived2.Field' hides inherited member 'Base2.Field'. Use the new keyword if hiding was intended.
// int Field = 2;
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Field"
).
WithArguments
(
"Base2.Derived2.Field"
,
"Base2.Field"
),
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Field"
).
WithArguments
(
"Base2.Derived2.Field"
,
"Base2.Field"
)
.
WithLocation
(
62
,
13
)
,
// (63,20): warning CS0108: 'Base2.Derived2.Field2' hides inherited member 'Base2.Field2'. Use the new keyword if hiding was intended.
// public int Field2 = 3;
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Field2"
).
WithArguments
(
"Base2.Derived2.Field2"
,
"Base2.Field2"
),
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Field2"
).
WithArguments
(
"Base2.Derived2.Field2"
,
"Base2.Field2"
)
.
WithLocation
(
63
,
20
)
,
// (74,22): warning CS0108: 'Base2.Derived2.Type2<T>' hides inherited member 'Base2.Type2<T>'. Use the new keyword if hiding was intended.
// public class Type2<T>
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Type2"
).
WithArguments
(
"Base2.Derived2.Type2<T>"
,
"Base2.Type2<T>"
),
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Type2"
).
WithArguments
(
"Base2.Derived2.Type2<T>"
,
"Base2.Type2<T>"
)
.
WithLocation
(
74
,
22
)
,
// (99,13): warning CS0109: The member 'Derived3.Field' does not hide an inherited member. The new keyword is not required.
// new int Field = 2;
Diagnostic
(
ErrorCode
.
WRN_NewNotRequired
,
"Field"
).
WithArguments
(
"Derived3.Field"
),
Diagnostic
(
ErrorCode
.
WRN_NewNotRequired
,
"Field"
).
WithArguments
(
"Derived3.Field"
)
.
WithLocation
(
99
,
13
)
,
// (101,26): warning CS0108: 'Derived3.Field2' hides inherited member 'Base3.Field2'. Use the new keyword if hiding was intended.
// protected static int Field2 = 1;
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Field2"
).
WithArguments
(
"Derived3.Field2"
,
"Base3.Field2"
),
Diagnostic
(
ErrorCode
.
WRN_NewRequired
,
"Field2"
).
WithArguments
(
"Derived3.Field2"
,
"Base3.Field2"
)
.
WithLocation
(
101
,
26
)
,
// (92,9): warning CS0414: The field 'Base3.Field' is assigned but its value is never used
// int Field = 1;
Diagnostic
(
ErrorCode
.
WRN_UnreferencedFieldAssg
,
"Field"
).
WithArguments
(
"Base3.Field"
)
);
Diagnostic
(
ErrorCode
.
WRN_UnreferencedFieldAssg
,
"Field"
).
WithArguments
(
"Base3.Field"
).
WithLocation
(
92
,
9
),
// (99,13): warning CS0414: The field 'Derived3.Field' is assigned but its value is never used
// new int Field = 2;
Diagnostic
(
ErrorCode
.
WRN_UnreferencedFieldAssg
,
"Field"
).
WithArguments
(
"Derived3.Field"
).
WithLocation
(
99
,
13
));
}
[
Fact
]
...
...
src/Compilers/CSharp/Test/Symbol/Symbols/OverriddenOrHiddenMembersTests.cs
浏览文件 @
c2c0fcf6
...
...
@@ -2543,12 +2543,18 @@ class D : C
Assert
.
Equal
(
0
,
ohmD
.
HiddenMembers
.
Length
);
comp
.
VerifyDiagnostics
(
// (19,41): error CS1715: 'D.E': type must be '
System.
Func<int>' to match overridden member 'C.E'
// (19,41): error CS1715: 'D.E': type must be 'Func<int>' to match overridden member 'C.E'
// public override event System.Action E;
Diagnostic
(
ErrorCode
.
ERR_CantChangeTypeOnOverride
,
"E"
).
WithArguments
(
"D.E"
,
"C.E"
,
"System.Func<int>"
),
Diagnostic
(
ErrorCode
.
ERR_CantChangeTypeOnOverride
,
"E"
).
WithArguments
(
"D.E"
,
"C.E"
,
"System.Func<int>"
)
.
WithLocation
(
19
,
41
)
,
// (19,41): warning CS0067: The event 'D.E' is never used
// public override event System.Action E;
Diagnostic
(
ErrorCode
.
WRN_UnreferencedEvent
,
"E"
).
WithArguments
(
"D.E"
));
Diagnostic
(
ErrorCode
.
WRN_UnreferencedEvent
,
"E"
).
WithArguments
(
"D.E"
).
WithLocation
(
19
,
41
),
// (9,41): warning CS0067: The event 'B.E' is never used
// public override event System.Action E;
Diagnostic
(
ErrorCode
.
WRN_UnreferencedEvent
,
"E"
).
WithArguments
(
"B.E"
).
WithLocation
(
9
,
41
),
// (14,47): warning CS0067: The event 'C.E' is never used
// public new virtual event System.Func<int> E;
Diagnostic
(
ErrorCode
.
WRN_UnreferencedEvent
,
"E"
).
WithArguments
(
"C.E"
).
WithLocation
(
14
,
47
));
}
[
WorkItem
(
545653
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545653"
)]
...
...
src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs
浏览文件 @
c2c0fcf6
...
...
@@ -921,7 +921,10 @@ public static void f()
CreateCompilationWithMscorlib(text).VerifyDiagnostics(
// (6,22): error CS0068: 'I.d': event in interface cannot have initializer
// event MyDelegate d = new MyDelegate(M.f); // CS0068
Diagnostic(ErrorCode.ERR_InterfaceEventInitializer, "d").WithArguments("I.d"));
Diagnostic(ErrorCode.ERR_InterfaceEventInitializer, "d").WithArguments("I.d").WithLocation(6, 22),
// (6,22): warning CS0067: The event 'I.d' is never used
// event MyDelegate d = new MyDelegate(M.f); // CS0068
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "d").WithArguments("I.d").WithLocation(6, 22));
}
[Fact]
...
...
@@ -979,7 +982,10 @@ abstract class Test
CreateCompilationWithMscorlib(text).VerifyDiagnostics(
// (6,29): error CS0074: 'Test.e': abstract event cannot have initializer
// public abstract event D e = null; // CS0074
Diagnostic(ErrorCode.ERR_AbstractEventInitializer, "e").WithArguments("Test.e"));
Diagnostic(ErrorCode.ERR_AbstractEventInitializer, "e").WithArguments("Test.e").WithLocation(6, 29),
// (6,29): warning CS0414: The field 'Test.e' is assigned but its value is never used
// public abstract event D e = null; // CS0074
Diagnostic(ErrorCode.WRN_UnreferencedFieldAssg, "e").WithArguments("Test.e").WithLocation(6, 29));
}
[Fact]
...
...
@@ -1991,7 +1997,9 @@ abstract class B : A
var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription { Code = (int)ErrorCode.ERR_StaticNotVirtual, Line = 7, Column = 51 },
new ErrorDescription { Code = (int)ErrorCode.ERR_StaticNotVirtual, Line = 8, Column = 47 },
new ErrorDescription { Code = (int)ErrorCode.ERR_StaticNotVirtual, Line = 9, Column = 50 });
new ErrorDescription { Code = (int)ErrorCode.ERR_StaticNotVirtual, Line = 9, Column = 50 },
new ErrorDescription { Code = (int)ErrorCode.WRN_UnreferencedEvent, Line = 7, Column = 51, IsWarning = true },
new ErrorDescription { Code = (int)ErrorCode.WRN_UnreferencedEvent, Line = 8, Column = 47, IsWarning = true });
}
[Fact]
...
...
@@ -2069,16 +2077,19 @@ class B : A
CreateCompilationWithMscorlib(text).VerifyDiagnostics(
// (9,51): error CS0113: A member 'B.Q' marked as override cannot be marked as new or virtual
// internal virtual override event System.Action Q;
Diagnostic(ErrorCode.ERR_OverrideNotNew, "Q").WithArguments("B.Q"),
Diagnostic(ErrorCode.ERR_OverrideNotNew, "Q").WithArguments("B.Q")
.WithLocation(9, 51)
,
// (8,48): error CS0113: A member 'B.P' marked as override cannot be marked as new or virtual
// protected new override event System.Action P;
Diagnostic(ErrorCode.ERR_OverrideNotNew, "P").WithArguments("B.P"),
Diagnostic(ErrorCode.ERR_OverrideNotNew, "P").WithArguments("B.P")
.WithLocation(8, 48)
,
// (8,48): warning CS0067: The event 'B.P' is never used
// protected new override event System.Action P;
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "P").WithArguments("B.P"),
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "P").WithArguments("B.P")
.WithLocation(8, 48)
,
// (9,51): warning CS0067: The event 'B.Q' is never used
// internal virtual override event System.Action Q;
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "Q").WithArguments("B.Q"));
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "Q").WithArguments("B.Q").WithLocation(9, 51),
// (4,42): warning CS0067: The event 'A.Q' is never used
// internal virtual event System.Action Q;
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "Q").WithArguments("A.Q").WithLocation(4, 42));
}
[Fact]
...
...
@@ -8935,16 +8946,18 @@ abstract class A3 : B3
}
";
CreateCompilationWithMscorlib(text).VerifyDiagnostics(
// (31,32): error CS0533: '
NS.A3.foo' hides inherited abstract member 'NS.
B3.foo()'
// (31,32): error CS0533: '
A3.foo' hides inherited abstract member '
B3.foo()'
// new protected double[] foo; // CS0533
Diagnostic(ErrorCode.ERR_HidingAbstractMethod, "foo").WithArguments("NS.A3.foo", "NS.B3.foo()"),
Diagnostic(ErrorCode.ERR_HidingAbstractMethod, "foo").WithArguments("NS.A3.foo", "NS.B3.foo()")
.WithLocation(31, 32)
,
// (9,24): error CS0533: 'A1.foo' hides inherited abstract member 'B1.foo'
// new protected enum foo { } // CS0533
Diagnostic(ErrorCode.ERR_HidingAbstractMethod, "foo").WithArguments("A1.foo", "B1.foo"),
Diagnostic(ErrorCode.ERR_HidingAbstractMethod, "foo").WithArguments("A1.foo", "B1.foo")
.WithLocation(9, 24)
,
// (18,36): error CS0533: 'A1.A2.foo' hides inherited abstract member 'A1.B2.foo()'
// new public delegate object foo(); // CS0533
Diagnostic(ErrorCode.ERR_HidingAbstractMethod, "foo").WithArguments("A1.A2.foo", "A1.B2.foo()")
);
Diagnostic(ErrorCode.ERR_HidingAbstractMethod, "foo").WithArguments("A1.A2.foo", "A1.B2.foo()").WithLocation(18, 36),
// (31,32): warning CS0649: Field 'A3.foo' is never assigned to, and will always have its default value null
// new protected double[] foo; // CS0533
Diagnostic(ErrorCode.WRN_UnassignedInternalField, "foo").WithArguments("NS.A3.foo", "null").WithLocation(31, 32));
}
[WorkItem(540464, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540464")]
...
...
src/Compilers/Test/Utilities/CSharp/DiagnosticTestUtilities.cs
浏览文件 @
c2c0fcf6
...
...
@@ -182,7 +182,7 @@ public static void VerifyErrorCodes(IEnumerable<Diagnostic> actualErrors, params
Assert
.
True
(
experr
.
Column
==
acterr
.
Column
,
String
.
Format
(
"Col {0}!={1}"
,
experr
.
Column
,
acterr
.
Column
));
}
Assert
.
Equal
(
experr
.
IsWarning
,
acterr
.
IsWarning
);
Assert
.
True
(
experr
.
IsWarning
==
acterr
.
IsWarning
,
String
.
Format
(
"IsWarning {0}!={1}"
,
experr
.
IsWarning
,
acterr
.
IsWarning
)
);
//if the expected contains parameters, validate those too.
if
(
experr
.
Parameters
!=
null
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录