Skip to content

Commit 7925059

Browse files
committed
Add regression test
1 parent 635aa1f commit 7925059

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
/*
5+
https://github.com/dotnet/runtime/issues/103365
6+
When using an interface with a generic out type, an explicit implementation, and a derived class, the base classes implementation is called instead of the derived class when running on Android. Running on Windows yields the expected behavior.
7+
*/
8+
9+
using System;
10+
using System.Collections;
11+
using System.Collections.Generic;
12+
using System.Runtime.CompilerServices;
13+
using Xunit;
14+
15+
public interface IBaseInterface<out T>
16+
{
17+
string explicitDeclaration();
18+
}
19+
20+
public class BasicBaseClass : IBaseInterface<BasicBaseClass>
21+
{
22+
string className = "BasicBaseClass";
23+
string IBaseInterface<BasicBaseClass>.explicitDeclaration()
24+
{
25+
return className;
26+
}
27+
}
28+
29+
public class BasicDerivedClass : BasicBaseClass, IBaseInterface<BasicDerivedClass>
30+
{
31+
string className = "BasicDerivedClass";
32+
33+
string IBaseInterface<BasicDerivedClass>.explicitDeclaration()
34+
{
35+
return className;
36+
}
37+
}
38+
39+
public static class Test_Issue103365
40+
{
41+
[Fact]
42+
public static void Main ()
43+
{
44+
var instances = new IBaseInterface<BasicBaseClass>[2];
45+
instances[0] = new BasicBaseClass();
46+
instances[1] = new BasicDerivedClass();
47+
Assert.Equal("BasicBaseClass", instances[0].explicitDeclaration());
48+
Assert.Equal("BasicDerivedClass", instances[1].explicitDeclaration());
49+
}
50+
}
51+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<ItemGroup>
3+
<Compile Include="103365.cs" />
4+
</ItemGroup>
5+
<ItemGroup>
6+
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)