Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Voorhees <michaelv@unity3d.com>2017-05-31 00:13:58 +0300
committerMarek Safar <marek.safar@gmail.com>2017-05-31 11:17:50 +0300
commitec55e57a57a77f0ff8209dcdf9c5a7ee3e73befa (patch)
treed488f2b62396d10e485a6d9c96ab032549d08cf8
parent88462b1005925c5fd8481ffb53e1e918f45b9b88 (diff)
Better struct support in test framework
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/Basic/UsedStructIsKept.cs21
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/StructUsedFromInterfaceHasInterfaceMethodKept.cs27
-rw-r--r--linker/Tests/TestCasesRunner/AssemblyChecker.cs3
7 files changed, 55 insertions, 4 deletions
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs
index b6af7dc0f..9314b4712 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs
@@ -2,7 +2,7 @@
namespace Mono.Linker.Tests.Cases.Expectations.Assertions
{
- [AttributeUsage (AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
+ [AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
public class KeptInterfaceAttribute : KeptAttribute
{
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs
index e7b77ef8b..34cfc5503 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberAttribute.cs
@@ -1,7 +1,7 @@
using System;
namespace Mono.Linker.Tests.Cases.Expectations.Assertions {
- [AttributeUsage (AttributeTargets.Class | AttributeTargets.Delegate, AllowMultiple = true, Inherited = false)]
+ [AttributeUsage (AttributeTargets.Class | AttributeTargets.Delegate | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
public sealed class KeptMemberAttribute : KeptAttribute {
public KeptMemberAttribute (string name)
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs
index 11cd069c3..1fabca331 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/NotATestCaseAttribute.cs
@@ -1,7 +1,7 @@
using System;
namespace Mono.Linker.Tests.Cases.Expectations.Metadata {
- [AttributeUsage (AttributeTargets.Class)]
+ [AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct)]
public class NotATestCaseAttribute : BaseMetadataAttribute {
}
} \ No newline at end of file
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Basic/UsedStructIsKept.cs b/linker/Tests/Mono.Linker.Tests.Cases/Basic/UsedStructIsKept.cs
new file mode 100644
index 000000000..4af518fed
--- /dev/null
+++ b/linker/Tests/Mono.Linker.Tests.Cases/Basic/UsedStructIsKept.cs
@@ -0,0 +1,21 @@
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+
+namespace Mono.Linker.Tests.Cases.Basic
+{
+ class UsedStructIsKept {
+ public static void Main()
+ {
+ A a;
+ a.MethodVerifiedByKeptMember ();
+ }
+
+ [Kept]
+ // This KeptMember is here to make sure the test framework's support of KeptMember on value types is working correctly
+ [KeptMember ("MethodVerifiedByKeptMember()")]
+ struct A {
+ public void MethodVerifiedByKeptMember ()
+ {
+ }
+ }
+ }
+}
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
index 1ebc87aa6..ba81df75d 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
+++ b/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
@@ -56,6 +56,8 @@
<Compile Include="Basic\UnusedPropertyGetsRemoved.cs" />
<Compile Include="Basic\UnusedPropertySetterRemoved.cs" />
<Compile Include="Basic\UsedPropertyIsKept.cs" />
+ <Compile Include="Basic\UsedStructIsKept.cs" />
+ <Compile Include="VirtualMethods\StructUsedFromInterfaceHasInterfaceMethodKept.cs" />
<Compile Include="CoreLink\CopyOfCoreLibrariesKeepsUnusedTypes.cs" />
<Compile Include="CoreLink\LinkingOfCoreLibrariesRemovesUnusedMethods.cs" />
<Compile Include="CoreLink\LinkingOfCoreLibrariesRemovesUnusedTypes.cs" />
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/StructUsedFromInterfaceHasInterfaceMethodKept.cs b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/StructUsedFromInterfaceHasInterfaceMethodKept.cs
new file mode 100644
index 000000000..bfd632bf5
--- /dev/null
+++ b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/StructUsedFromInterfaceHasInterfaceMethodKept.cs
@@ -0,0 +1,27 @@
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+
+namespace Mono.Linker.Tests.Cases.VirtualMethods
+{
+ class StructUsedFromInterfaceHasInterfaceMethodKept {
+ public static void Main ()
+ {
+ IFoo a = new A ();
+ a.Foo ();
+ }
+
+ [Kept]
+ [KeptInterface (typeof (IFoo))]
+ struct A : IFoo {
+ [Kept]
+ public void Foo ()
+ {
+ }
+ }
+
+ [Kept]
+ public interface IFoo {
+ [Kept]
+ void Foo ();
+ }
+ }
+}
diff --git a/linker/Tests/TestCasesRunner/AssemblyChecker.cs b/linker/Tests/TestCasesRunner/AssemblyChecker.cs
index e9ed80abc..3d28c7ddf 100644
--- a/linker/Tests/TestCasesRunner/AssemblyChecker.cs
+++ b/linker/Tests/TestCasesRunner/AssemblyChecker.cs
@@ -137,7 +137,8 @@ namespace Mono.Linker.Tests.TestCasesRunner {
builder.Append (">");
expectedBaseName = builder.ToString ();
} else {
- expectedBaseName = GetCustomAttributeCtorValues<object> (src, nameof (KeptBaseTypeAttribute)).FirstOrDefault ()?.ToString () ?? "System.Object";
+ var defaultBaseType = src.IsValueType ? "System.ValueType" : "System.Object";
+ expectedBaseName = GetCustomAttributeCtorValues<object> (src, nameof (KeptBaseTypeAttribute)).FirstOrDefault ()?.ToString () ?? defaultBaseType;
}
Assert.AreEqual (expectedBaseName, linked.BaseType?.FullName);
}