Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
04417046
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,发现更多精彩内容 >>
提交
04417046
编写于
7月 27, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make certain errors expected
上级
f4a5c268
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
114 deletion
+39
-114
src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs
...omMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs
+39
-114
未找到文件。
src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs
浏览文件 @
04417046
...
...
@@ -283,7 +283,7 @@ public async Task TestReferenceIEquatable()
using System;
using System.Collections.Generic;
class S :
IEquatable<S>
{ }
class S :
{|CS0535:IEquatable<S>|}
{ }
class Program
{
...
...
@@ -293,7 +293,7 @@ class Program
using System;
using System.Collections.Generic;
class S :
IEquatable<S>
{ }
class S :
{|CS0535:IEquatable<S>|}
{ }
class Program
{
...
...
@@ -306,12 +306,7 @@ public override bool Equals(object obj)
EqualityComparer<S>.Default.Equals(a, program.a);
}
}"
,
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,11): error CS0535: 'S' does not implement interface member 'IEquatable<S>.Equals(S)'
DiagnosticResult
.
CompilerError
(
"CS0535"
).
WithSpan
(
5
,
11
,
5
,
24
).
WithArguments
(
"S"
,
"System.IEquatable<S>.Equals(S)"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -323,7 +318,7 @@ public async Task TestNullableReferenceIEquatable()
using System;
using System.Collections.Generic;
class S :
IEquatable<S>
{ }
class S :
{|CS0535:IEquatable<S>|}
{ }
class Program
{
...
...
@@ -334,7 +329,7 @@ class Program
using System;
using System.Collections.Generic;
class S :
IEquatable<S>
{ }
class S :
{|CS0535:IEquatable<S>|}
{ }
class Program
{
...
...
@@ -350,12 +345,7 @@ public override int GetHashCode()
{
return -1757793268 + EqualityComparer<S?>.Default.GetHashCode(a);
}
}"
,
index
:
1
,
options
:
PreferImplicitTypeWithInfo
(),
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(6,11): error CS0535: 'S' does not implement interface member 'IEquatable<S>.Equals(S)'
DiagnosticResult
.
CompilerError
(
"CS0535"
).
WithSpan
(
6
,
11
,
6
,
24
).
WithArguments
(
"S"
,
"System.IEquatable<S>.Equals(S)"
),
});
}"
,
index
:
1
,
options
:
PreferImplicitTypeWithInfo
());
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -366,7 +356,7 @@ public async Task TestValueIEquatable()
using System;
using System.Collections.Generic;
struct S :
IEquatable<S>
{ }
struct S :
{|CS0535:IEquatable<S>|}
{ }
class Program
{
...
...
@@ -376,7 +366,7 @@ class Program
using System;
using System.Collections.Generic;
struct S :
IEquatable<S>
{ }
struct S :
{|CS0535:IEquatable<S>|}
{ }
class Program
{
...
...
@@ -389,12 +379,7 @@ public override bool Equals(object obj)
a.Equals(program.a);
}
}"
,
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,12): error CS0535: 'S' does not implement interface member 'IEquatable<S>.Equals(S)'
DiagnosticResult
.
CompilerError
(
"CS0535"
).
WithSpan
(
5
,
12
,
5
,
25
).
WithArguments
(
"S"
,
"System.IEquatable<S>.Equals(S)"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -710,7 +695,7 @@ public async Task TestEqualsStructAlreadyImplementsIEquatable()
@"using System;
using System.Collections.Generic;
struct ReallyLongName :
IEquatable<ReallyLongName>
struct ReallyLongName :
{|CS0535:IEquatable<ReallyLongName>|}
{
[|int i;
...
...
@@ -719,7 +704,7 @@ struct ReallyLongName : IEquatable<ReallyLongName>
@"using System;
using System.Collections.Generic;
struct ReallyLongName :
IEquatable<ReallyLongName>
struct ReallyLongName :
{|CS0535:IEquatable<ReallyLongName>|}
{
int i;
...
...
@@ -741,12 +726,7 @@ public override bool Equals(object obj)
{
return !(left == right);
}
}"
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(4,25): error CS0535: 'ReallyLongName' does not implement interface member 'IEquatable<ReallyLongName>.Equals(ReallyLongName)'
DiagnosticResult
.
CompilerError
(
"CS0535"
).
WithSpan
(
4
,
25
,
4
,
51
).
WithArguments
(
"ReallyLongName"
,
"System.IEquatable<ReallyLongName>.Equals(ReallyLongName)"
),
});
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -797,7 +777,7 @@ public async Task TestEqualsStructAlreadyImplementsIEquatableAndHasOperators()
@"using System;
using System.Collections.Generic;
struct ReallyLongName :
IEquatable<ReallyLongName>
struct ReallyLongName :
{|CS0535:IEquatable<ReallyLongName>|}
{
[|int i;
...
...
@@ -809,7 +789,7 @@ struct ReallyLongName : IEquatable<ReallyLongName>
@"using System;
using System.Collections.Generic;
struct ReallyLongName :
IEquatable<ReallyLongName>
struct ReallyLongName :
{|CS0535:IEquatable<ReallyLongName>|}
{
int i;
...
...
@@ -824,11 +804,7 @@ public override bool Equals(object obj)
public static bool operator ==(ReallyLongName left, ReallyLongName right) => false;
public static bool operator !=(ReallyLongName left, ReallyLongName right) => false;
}"
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(4,25): error CS0535: 'ReallyLongName' does not implement interface member 'IEquatable<ReallyLongName>.Equals(ReallyLongName)'
DiagnosticResult
.
CompilerError
(
"CS0535"
).
WithSpan
(
4
,
25
,
4
,
51
).
WithArguments
(
"ReallyLongName"
,
"System.IEquatable<ReallyLongName>.Equals(ReallyLongName)"
),
});
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -1243,13 +1219,13 @@ public async Task Tuple_Disabled()
class C
{
[|
(int, string)
a;|]
[|
{|CS8059:(int, string)|}
a;|]
}"
,
@"using System.Collections.Generic;
class C
{
(int, string)
a;
{|CS8059:(int, string)|}
a;
public override bool Equals(object obj)
{
...
...
@@ -1259,12 +1235,7 @@ public override bool Equals(object obj)
}
}"
,
index
:
0
,
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,5): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7.0 or greater.
DiagnosticResult
.
CompilerError
(
"CS8059"
).
WithSpan
(
5
,
5
,
5
,
18
).
WithArguments
(
"tuples"
,
"7.0"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -1275,13 +1246,13 @@ public async Task Tuples_Equals()
class C
{
[|
(int, string)
a;|]
[|
{|CS8059:(int, string)|}
a;|]
}"
,
@"using System.Collections.Generic;
class C
{
(int, string)
a;
{|CS8059:(int, string)|}
a;
public override bool Equals(object obj)
{
...
...
@@ -1290,12 +1261,7 @@ public override bool Equals(object obj)
a.Equals(c.a);
}
}"
,
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,5): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7.0 or greater.
DiagnosticResult
.
CompilerError
(
"CS8059"
).
WithSpan
(
5
,
5
,
5
,
18
).
WithArguments
(
"tuples"
,
"7.0"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -1306,13 +1272,13 @@ public async Task TupleWithNames_Equals()
class C
{
[|
(int x, string y)
a;|]
[|
{|CS8059:(int x, string y)|}
a;|]
}"
,
@"using System.Collections.Generic;
class C
{
(int x, string y)
a;
{|CS8059:(int x, string y)|}
a;
public override bool Equals(object obj)
{
...
...
@@ -1321,12 +1287,7 @@ public override bool Equals(object obj)
a.Equals(c.a);
}
}"
,
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,5): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7.0 or greater.
DiagnosticResult
.
CompilerError
(
"CS8059"
).
WithSpan
(
5
,
5
,
5
,
22
).
WithArguments
(
"tuples"
,
"7.0"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -1337,13 +1298,13 @@ public async Task Tuple_HashCode()
class Program
{
[|
(int, string)
i;|]
[|
{|CS8059:(int, string)|}
i;|]
}"
,
@"using System.Collections.Generic;
class Program
{
(int, string)
i;
{|CS8059:(int, string)|}
i;
public override bool Equals(object obj)
{
...
...
@@ -1358,12 +1319,7 @@ public override int GetHashCode()
}
}"
,
index
:
1
,
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,5): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7.0 or greater.
DiagnosticResult
.
CompilerError
(
"CS8059"
).
WithSpan
(
5
,
5
,
5
,
18
).
WithArguments
(
"tuples"
,
"7.0"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -1374,13 +1330,13 @@ public async Task TupleWithNames_HashCode()
class Program
{
[|
(int x, string y)
i;|]
[|
{|CS8059:(int x, string y)|}
i;|]
}"
,
@"using System.Collections.Generic;
class Program
{
(int x, string y)
i;
{|CS8059:(int x, string y)|}
i;
public override bool Equals(object obj)
{
...
...
@@ -1395,12 +1351,7 @@ public override int GetHashCode()
}
}"
,
index
:
1
,
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,5): error CS8059: Feature 'tuples' is not available in C# 6. Please use language version 7.0 or greater.
DiagnosticResult
.
CompilerError
(
"CS8059"
).
WithSpan
(
5
,
5
,
5
,
22
).
WithArguments
(
"tuples"
,
"7.0"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -1976,7 +1927,7 @@ class Program
public string s;
[||]
public static bool operator
==
(Program left, Program right) => true;
public static bool operator
{|CS0216:==|}
(Program left, Program right) => true;
}"
,
@"
using System.Collections.Generic;
...
...
@@ -1992,21 +1943,11 @@ public override bool Equals(object obj)
s == program.s;
}
public static bool operator
==
(Program left, Program right) => true;
public static bool operator
{|CS0216:==|}
(Program left, Program right) => true;
}"
,
chosenSymbols
:
null
,
optionsCallback
:
options
=>
Assert
.
Null
(
options
.
FirstOrDefault
(
i
=>
i
.
Id
==
GenerateOperatorsId
)),
parameters
:
CSharp6Implicit
,
testExpectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(9,33): error CS0216: The operator 'Program.operator ==(Program, Program)' requires a matching operator '!=' to also be defined
DiagnosticResult
.
CompilerError
(
"CS0216"
).
WithSpan
(
9
,
33
,
9
,
35
).
WithArguments
(
"Program.operator ==(Program, Program)"
,
"!="
),
},
fixedExpectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(15,33): error CS0216: The operator 'Program.operator ==(Program, Program)' requires a matching operator '!=' to also be defined
DiagnosticResult
.
CompilerError
(
"CS0216"
).
WithSpan
(
15
,
33
,
15
,
35
).
WithArguments
(
"Program.operator ==(Program, Program)"
,
"!="
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -2450,7 +2391,7 @@ public async Task TestDoNotOfferIEquatableIfTypeAlreadyImplementsIt()
@"
using System.Collections.Generic;
class Program :
System.IEquatable<Program>
class Program :
{|CS0535:System.IEquatable<Program>|}
{
public string s;
[||]
...
...
@@ -2458,7 +2399,7 @@ class Program : System.IEquatable<Program>
@"
using System.Collections.Generic;
class Program :
System.IEquatable<Program>
class Program :
{|CS0535:System.IEquatable<Program>|}
{
public string s;
...
...
@@ -2471,12 +2412,7 @@ public override bool Equals(object obj)
}"
,
chosenSymbols
:
null
,
optionsCallback
:
options
=>
Assert
.
Null
(
options
.
FirstOrDefault
(
i
=>
i
.
Id
==
ImplementIEquatableId
)),
parameters
:
CSharp6Implicit
,
expectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(4,17): error CS0535: 'Program' does not implement interface member 'IEquatable<Program>.Equals(Program)'
DiagnosticResult
.
CompilerError
(
"CS0535"
).
WithSpan
(
4
,
17
,
4
,
43
).
WithArguments
(
"Program"
,
"System.IEquatable<Program>.Equals(Program)"
),
});
parameters
:
CSharp6Implicit
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateEqualsAndGetHashCode
)]
...
...
@@ -3480,11 +3416,11 @@ public async Task TestAbstractBase()
abstract class Base
{
public abstract override bool Equals(object
?
obj);
public abstract override bool Equals(object
{|CS8632:?|}
obj);
public abstract override int GetHashCode();
}
class
Derived
: Base
class
{|CS0534:{|CS0534:Derived|}|}
: Base
{
[|public int P { get; }|]
}"
,
...
...
@@ -3494,7 +3430,7 @@ namespace System { public struct HashCode { } }
abstract class Base
{
public abstract override bool Equals(object
?
obj);
public abstract override bool Equals(object
{|CS8632:?|}
obj);
public abstract override int GetHashCode();
}
...
...
@@ -3515,19 +3451,8 @@ public override int GetHashCode()
}"
,
index
:
1
,
parameters
:
CSharpLatest
,
testExpectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(5,48): error CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
DiagnosticResult
.
CompilerError
(
"CS8632"
).
WithSpan
(
5
,
48
,
5
,
49
),
// /0/Test0.cs(9,7): error CS0534: 'Derived' does not implement inherited abstract member 'Base.Equals(object?)'
DiagnosticResult
.
CompilerError
(
"CS0534"
).
WithSpan
(
9
,
7
,
9
,
14
).
WithArguments
(
"Derived"
,
"Base.Equals(object?)"
),
// /0/Test0.cs(9,7): error CS0534: 'Derived' does not implement inherited abstract member 'Base.GetHashCode()'
DiagnosticResult
.
CompilerError
(
"CS0534"
).
WithSpan
(
9
,
7
,
9
,
14
).
WithArguments
(
"Derived"
,
"Base.GetHashCode()"
),
},
fixedExpectedDiagnostics
:
new
List
<
DiagnosticResult
>
{
// /0/Test0.cs(7,48): error CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
DiagnosticResult
.
CompilerError
(
"CS8632"
).
WithSpan
(
7
,
48
,
7
,
49
),
// /0/Test0.cs(23,25): error CS0117: 'HashCode' does not contain a definition for 'Combine'
DiagnosticResult
.
CompilerError
(
"CS0117"
).
WithSpan
(
23
,
25
,
23
,
32
).
WithArguments
(
"System.HashCode"
,
"Combine"
),
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录