Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ public sealed partial class BasicTests : LinkerTestBase

protected override string TestSuiteName => "Basic";

[Fact]
public Task Calli()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task ComplexNestedClassesHasUnusedRemoved()
{
Expand All @@ -21,30 +27,120 @@ public Task DelegateBeginInvokeEndInvokePair()
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task ExceptionRegions()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task FieldRVA()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task FieldSignature()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task FieldsOfEnum()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task Finalizer()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task First()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task FunctionPointer()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task GenericParameters()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task GenericType()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task InitializerForArrayIsKept()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task InstanceFields()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task InstantiatedTypeWithOverridesFromObject()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task InterfaceCalls()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task InterfaceMethodImplementedOnBaseClassDoesNotGetStripped()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task InterfaceOrder()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task LibraryModeTest()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task LinkerHandlesRefFields()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task MethodSpecSignature()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task MultiDimArraySignature()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task MultiLevelNestedClassesAllRemovedWhenNonUsed()
{
Expand All @@ -63,6 +159,30 @@ public Task NeverInstantiatedTypeWithOverridesFromObject()
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task Resources()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task Switch()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task TypeOf()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task TypeSpecSignature()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task UninvokedInterfaceMemberGetsRemoved()
{
Expand Down Expand Up @@ -177,5 +297,11 @@ public Task UsedStructIsKept()
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task VirtualMethods()
{
return RunTest(allowMissingWarnings: true);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Threading.Tasks;
using Xunit;

namespace ILLink.RoslynAnalyzer.Tests
{
public sealed partial class MultiAssemblyTests : LinkerTestBase
{

protected override string TestSuiteName => "MultiAssembly";

[Fact]
public Task ForwarderReference()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task MultiAssembly()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task TypeRefToAssembly()
{
return RunTest(allowMissingWarnings: true);
}

}
}
28 changes: 28 additions & 0 deletions src/tools/illink/test/Mono.Linker.Tests.Cases/Basic/Calli.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;

namespace Mono.Linker.Tests.Cases.Basic
{
[SetupCompileArgument("/unsafe")]
[SkipILVerify] // ILVerify doesn't handle calli
[KeptMember(".cctor()")]
public unsafe class Calli
{
[Kept]
private static readonly delegate*<object, void> _pfn = null;

public static void Main()
{
CallCalli(null);
}

[Kept]
static void CallCalli(object o)
{
_pfn(o);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Embedded resource content
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Basic
{
[Kept]
public class ExceptionRegions
{
[Kept]
static void Main()
{
try
{
A();
}
catch (CustomException ce)
{
Console.WriteLine(ce.Message);
try
{
B();
}
catch (Exception e) when (e.InnerException != null)
{
Console.WriteLine(e.Message);
}
}
finally
{
C();
}
}

[Kept]
static void A() { }

[Kept]
static void B() { throw new Exception(); }

[Kept]
static void C() { }
}

[Kept]
[KeptBaseType(typeof(Exception))]
class CustomException : Exception
{
}
}
13 changes: 13 additions & 0 deletions src/tools/illink/test/Mono.Linker.Tests.Cases/Basic/FieldRVA.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Basic
{
[Kept]
class FieldRVA
{
[Kept]
[KeptInitializerData]
static int Main() => new byte[] { 1, 2, 3, 4, 5 }.Length;
}
Comment on lines +7 to +12
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation uses tab characters for the type declaration/closing brace; repo .editorconfig sets indent_style=space. Please convert these tabs to spaces to match formatting conventions.

Suggested change
class FieldRVA
{
[Kept]
[KeptInitializerData]
static int Main() => new byte[] { 1, 2, 3, 4, 5 }.Length;
}
class FieldRVA
{
[Kept]
[KeptInitializerData]
static int Main() => new byte[] { 1, 2, 3, 4, 5 }.Length;
}

Copilot uses AI. Check for mistakes.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using System;

namespace Mono.Linker.Tests.Cases.Basic
{
[Kept]
class FieldSignature
{
[Kept]
static FieldType field;

[Kept]
static void Main()
{
field = null;
_ = field;
}

[Kept]
class FieldType
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Basic
{
[Kept]
class FieldsOfEnum
{
[Kept]
static void Main()
{
Console.WriteLine($"{MyEnum.A}");
}
}

[Kept]
[KeptMember("value__")]
[KeptBaseType(typeof(Enum))]
public enum MyEnum
{
[Kept]
A = 0,

[Kept]
B = 1,

[Kept]
C = 2,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using System;

namespace Mono.Linker.Tests.Cases.Basic
{
[Kept]
class Finalizer
{
static void Main()
{
MentionUnallocatedType(null);
new AllocatedTypeWithFinalizer();
}

[Kept]
static void MentionUnallocatedType(UnallocatedTypeWithFinalizer u) { }

[Kept]
class UnallocatedTypeWithFinalizer
{
// Not kept
~UnallocatedTypeWithFinalizer() { }
}

[Kept]
[KeptMember(".ctor()")]
class AllocatedTypeWithFinalizer
{
[Kept]
~AllocatedTypeWithFinalizer() { }
}
}
}
Loading
Loading