提交 09c32d1a 编写于 作者: C Cyrus Najmabadi

Tests

上级 e18778ca
......@@ -2227,39 +2227,113 @@ public override int GetHashCode()
parameters: CSharp6Implicit);
}
[WorkItem(37297, "https://github.com/dotnet/roslyn/issues/37297")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEqualsAndGetHashCode)]
public async Task TestPublicSystemHashCodeOtherProject()
{
await TestInRegularAndScript1Async(
@"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" Name=""P1"">
<Document>
using System.Collections.Generic;
namespace System { public struct HashCode { } }
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" Name=""P2"">
<ProjectReference>P1</ProjectReference>
<Document>
struct S
{
[|int j;|]
}
</Document>
</Project>
</Workspace>",
@"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" Name=""P1"">
<Document>
using System.Collections.Generic;
namespace System { public struct HashCode { } }
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" Name=""P2"">
<ProjectReference>P1</ProjectReference>
<Document>
using System;
struct S
{
int j;
public override bool Equals(object obj)
{
return obj is S s &amp;&amp;
j == s.j;
}
public override int GetHashCode()
{
return HashCode.Combine(j);
}
}
</Document>
</Project>
</Workspace>",
index: 1,
parameters: CSharp6Implicit);
}
[WorkItem(37297, "https://github.com/dotnet/roslyn/issues/37297")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEqualsAndGetHashCode)]
public async Task TestInternalSystemHashCode()
{
await TestInRegularAndScript1Async(
@"using System.Collections.Generic;
@"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" Name=""P1"">
<Document>
using System.Collections.Generic;
namespace System { internal struct HashCode { } }
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" Name=""P2"">
<ProjectReference>P1</ProjectReference>
<Document>
struct S
{
[|int j;|]
}",
@"using System.Collections.Generic;
}
</Document>
</Project>
</Workspace>",
@"<Workspace>
<Project Language=""C#"" CommonReferences=""true"" Name=""P1"">
<Document>
using System.Collections.Generic;
namespace System { internal struct HashCode { } }
</Document>
</Project>
<Project Language=""C#"" CommonReferences=""true"" Name=""P2"">
<ProjectReference>P1</ProjectReference>
<Document>
struct S
{
int j;
public override bool Equals(object obj)
{
if (!(obj is S))
{
return false;
}
var s = (S)obj;
return j == s.j;
return obj is S s &amp;&amp;
j == s.j;
}
public override int GetHashCode()
{
return 1424088837 + j.GetHashCode();
}
}",
}
</Document>
</Project>
</Workspace>",
index: 1,
parameters: CSharp6Implicit);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册