Skip to content

Commit

Permalink
Add a couple new test
Browse files Browse the repository at this point in the history
Add a few complicated tests with interface sweeping and abstract classes involved.  These tests are green on master.  These tests are setup to come close to triggering a new feature I'm working on `lazy body marking`.

I'm also tired of seeing the `Inheritance.Complex` tests showing up in the Solution Explorer as missing.  Adding these tests provides something to run for that set of tests.
  • Loading branch information
mrvoorhe authored and marek-safar committed Mar 21, 2019
1 parent 9bfeb66 commit 13d864e
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Inheritance.Complex.NoKeptCtor {
public class OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved {
public static void Main ()
{
Foo b = HelperToMarkFooAndRequireBase ();
// Use IBar in another method so that IBar can be removed from Foo
HelperToMarkIBar ();
}

[Kept]
static Foo HelperToMarkFooAndRequireBase ()
{
return null;
}

[Kept]
static void HelperToMarkIBar()
{
GetAnIBar().Method();
}

[Kept]
static IBar GetAnIBar()
{
return null;
}

[Kept]
abstract class Base {
public abstract void Method ();
}

[Kept]
[KeptBaseType (typeof (Base))]
class Foo : Base, IBar {
public override void Method ()
{
UsedByOverride ();
}

void UsedByOverride ()
{
}
}

[Kept]
interface IBar {
[Kept]
void Method ();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Inheritance.Complex.NoKeptCtor {
public class OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved2 {
public static void Main ()
{
Foo b = null;
HelperToKeepLocalAtCompileTime (b);
// Use IBar in another method so that IBar can be removed from Foo
HelperToMarkIBar ();
}

[Kept]
static void HelperToKeepLocalAtCompileTime (Foo f)
{
}

[Kept]
static void HelperToMarkIBar()
{
GetAnIBar().Method();
}

[Kept]
static IBar GetAnIBar()
{
return null;
}

[Kept]
abstract class Base {
public abstract void Method ();
}

[Kept]
[KeptBaseType (typeof (Base))]
class Foo : Base, IBar {
public override void Method ()
{
UsedByOverride ();
}

void UsedByOverride ()
{
}
}

[Kept]
interface IBar {
[Kept]
void Method ();
}
}
}
3 changes: 2 additions & 1 deletion test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@
<Compile Include="Inheritance.AbstractClasses\UnusedVirtualMethodRemoved.cs" />
<Compile Include="Inheritance.AbstractClasses\UsedOverrideOfAbstractMethodIsKept.cs" />
<Compile Include="Inheritance.AbstractClasses\UsedOverrideOfVirtualMethodIsKept.cs" />
<Compile Include="Inheritance.Complex\NoKeptCtor\OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved.cs" />
<Compile Include="Inheritance.Complex\NoKeptCtor\OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved2.cs" />
<Compile Include="Inheritance.Interfaces\Dependencies\InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit_Copy.cs" />
<Compile Include="Inheritance.Interfaces\Dependencies\InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit_Link.cs" />
<Compile Include="Inheritance.Interfaces\Dependencies\InterfaceTypeInOtherUsedOnlyByCopiedAssembly_Copy.cs" />
Expand Down Expand Up @@ -611,7 +613,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Attributes.StructLayout\" />
<Folder Include="Inheritance.Complex" />
<Folder Include="Reflection\Dependencies\" />
<Folder Include="BCLFeatures\" />
<Folder Include="BCLFeatures\ETW\" />
Expand Down

0 comments on commit 13d864e

Please sign in to comment.