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
path: root/test
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2019-10-04 19:31:40 +0300
committerMarek Safar <marek.safar@gmail.com>2019-10-07 12:39:34 +0300
commitab3667782f32459bd44bcea906b4a16b151a4b5a (patch)
tree3d13bf4d8db81cc0b86762db0e9290a190ae885d /test
parente8fea0e48e63e3e5706246b28efd6ef935c5c58c (diff)
Add simple detection for custom TypeConvertors
Contributes to #153
Diffstat (limited to 'test')
-rw-r--r--test/Mono.Linker.Tests.Cases/ComponentModel/CustomTypeConvertor.cs68
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs27
-rw-r--r--test/Mono.Linker.Tests/TestCases/TestDatabase.cs7
-rw-r--r--test/Mono.Linker.Tests/TestCases/TestSuites.cs8
4 files changed, 103 insertions, 7 deletions
diff --git a/test/Mono.Linker.Tests.Cases/ComponentModel/CustomTypeConvertor.cs b/test/Mono.Linker.Tests.Cases/ComponentModel/CustomTypeConvertor.cs
new file mode 100644
index 000000000..4f94ed07e
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/ComponentModel/CustomTypeConvertor.cs
@@ -0,0 +1,68 @@
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Metadata;
+
+namespace Mono.Linker.Tests.Cases.ComponentModel
+{
+ [TypeConverter (typeof (Custom1))]
+
+ [Kept]
+ [KeptAttributeAttribute (typeof (TypeConverterAttribute))]
+ class CustomDataType
+ {
+ [Kept]
+ [KeptBaseType (typeof (TypeConverter))]
+ class Custom1 : TypeConverter
+ {
+ [Kept]
+ public Custom1 (Type type)
+ {
+ }
+
+ [Kept]
+ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ return "test";
+ }
+ }
+ }
+
+ [TypeConverter ("Mono.Linker.Tests.Cases.ComponentModel.CustomDataType_2/Custom2")]
+
+ [Kept]
+ [KeptAttributeAttribute (typeof (TypeConverterAttribute))]
+ class CustomDataType_2
+ {
+ [Kept]
+ [KeptBaseType (typeof (TypeConverter))]
+ class Custom2 : TypeConverter
+ {
+ [Kept]
+ public Custom2 ()
+ {
+ }
+
+ [Kept]
+ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ return "test";
+ }
+ }
+ }
+
+ [Reference ("System.dll")]
+ public class CustomTypeConvertor
+ {
+ public static void Main ()
+ {
+ var tc1 = TypeDescriptor.GetConverter (typeof (CustomDataType));
+ var res1 = tc1.ConvertFromString ("from");
+
+ var tc2 = TypeDescriptor.GetConverter (typeof (CustomDataType_2));
+ var res2 = tc2.ConvertFromString ("from");
+
+ }
+ }
+}
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs
index 93c7eeb5c..07a01b1ae 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs
@@ -11,7 +11,7 @@ namespace Mono.Linker.Tests.Cases.Reflection {
TestEmptyString ();
TestFullString ();
TestGenericString ();
- TestFullStringConst();
+ TestFullStringConst ();
TestTypeAsmName ();
TestType ();
TestPointer ();
@@ -21,6 +21,7 @@ namespace Mono.Linker.Tests.Cases.Reflection {
TestMultiDimensionalArray ();
TestMultiDimensionalArrayFullString ();
TestMultiDimensionalArrayAsmName ();
+ TestDeeplyNested ();
}
[Kept]
@@ -61,10 +62,10 @@ namespace Mono.Linker.Tests.Cases.Reflection {
public class FullConst { }
[Kept]
- public static void TestFullStringConst()
+ public static void TestFullStringConst ()
{
const string reflectionTypeKeptString = "Mono.Linker.Tests.Cases.Reflection.TypeUsedViaReflection+FullConst, test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null";
- var typeKept = Type.GetType(reflectionTypeKeptString, false);
+ var typeKept = Type.GetType (reflectionTypeKeptString, false);
}
[Kept]
@@ -118,7 +119,7 @@ namespace Mono.Linker.Tests.Cases.Reflection {
}
[Kept]
- public class ArrayOfArray{ }
+ public class ArrayOfArray { }
[Kept]
public static void TestArrayOfArray ()
@@ -129,7 +130,7 @@ namespace Mono.Linker.Tests.Cases.Reflection {
[Kept]
- public class MultiDimensionalArray{ }
+ public class MultiDimensionalArray { }
[Kept]
public static void TestMultiDimensionalArray ()
@@ -157,5 +158,21 @@ namespace Mono.Linker.Tests.Cases.Reflection {
const string reflectionTypeKeptString = "Mono.Linker.Tests.Cases.Reflection.TypeUsedViaReflection+MultiDimensionalArrayAsmName[,], test";
var typeKept = Type.GetType (reflectionTypeKeptString, false);
}
+
+ [Kept]
+ class Nested1 {
+ [Kept]
+ class N2 {
+ [Kept]
+ class N3 {
+ }
+ }
+ }
+
+ [Kept]
+ static void TestDeeplyNested ()
+ {
+ var typeKept = Type.GetType ("Mono.Linker.Tests.Cases.Reflection.TypeUsedViaReflection+Nested1+N2+N3");
+ }
}
}
diff --git a/test/Mono.Linker.Tests/TestCases/TestDatabase.cs b/test/Mono.Linker.Tests/TestCases/TestDatabase.cs
index 874f555d3..893b55508 100644
--- a/test/Mono.Linker.Tests/TestCases/TestDatabase.cs
+++ b/test/Mono.Linker.Tests/TestCases/TestDatabase.cs
@@ -75,7 +75,12 @@ namespace Mono.Linker.Tests.TestCases
{
return NUnitCasesBySuiteName ("Reflection");
}
-
+
+ public static IEnumerable<TestCaseData> ComponentModelTests ()
+ {
+ return NUnitCasesBySuiteName ("ComponentModel");
+ }
+
public static IEnumerable<TestCaseData> SymbolsTests ()
{
return NUnitCasesBySuiteName ("Symbols");
diff --git a/test/Mono.Linker.Tests/TestCases/TestSuites.cs b/test/Mono.Linker.Tests/TestCases/TestSuites.cs
index 90d2f2e69..b3aa7ad50 100644
--- a/test/Mono.Linker.Tests/TestCases/TestSuites.cs
+++ b/test/Mono.Linker.Tests/TestCases/TestSuites.cs
@@ -90,7 +90,13 @@ namespace Mono.Linker.Tests.TestCases
{
Run (testCase);
}
-
+
+ [TestCaseSource (typeof (TestDatabase), nameof (TestDatabase.ComponentModelTests))]
+ public void ComponentModelTests (TestCase testCase)
+ {
+ Run (testCase);
+ }
+
[TestCaseSource (typeof (TestDatabase), nameof (TestDatabase.PreserveDependenciesTests))]
public void PreserveDependenciesTests (TestCase testCase)
{