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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Urban-Forster <lewurm@gmail.com>2020-04-28 21:40:42 +0300
committerBernhard Urban-Forster <lewurm@gmail.com>2020-04-28 21:40:42 +0300
commit8f70804a42dc13c182706b00275f0de75c150ee4 (patch)
treeb355b65978a9ea64a59ced041b9b037aad5fb454
parent928e97ec880a979c82b864fe187abb21d9dfcaec (diff)
[enc] add AddClass test (fails)
-rw-r--r--mono/tests/enc/AddClass.cs36
-rw-r--r--mono/tests/enc/AddClass_v1.cs38
-rw-r--r--mono/tests/enc/Makefile.am1
3 files changed, 75 insertions, 0 deletions
diff --git a/mono/tests/enc/AddClass.cs b/mono/tests/enc/AddClass.cs
new file mode 100644
index 00000000000..24e362dc183
--- /dev/null
+++ b/mono/tests/enc/AddClass.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using MonoEnc;
+
+public class AddClass {
+ public static int Main (string []args) {
+ Assembly assm = typeof (AddClass).Assembly;
+ var replacer = EncHelper.Make ();
+
+ var secondClassType = ReplaceMe ();
+ if (secondClassType != typeof (AddClass))
+ return 1;
+
+ try {
+ replacer.Update (assm);
+ /* doesn't work yet, thus should throw exception */
+ return 2;
+ } catch (TargetInvocationException e) {
+ Console.WriteLine ("e: " + e);
+ if (e.InnerException.Message.Contains ("cannot add new class"))
+ return 0;
+ }
+ /* we should not get here, yet */
+ secondClassType = ReplaceMe ();
+ if (secondClassType != typeof (AddClass)) {
+ /* would be expected if it would work */
+ return 4;
+ }
+ return 3;
+ }
+
+ public static System.Type ReplaceMe () {
+ return typeof (AddClass);
+ }
+}
diff --git a/mono/tests/enc/AddClass_v1.cs b/mono/tests/enc/AddClass_v1.cs
new file mode 100644
index 00000000000..ada9324b394
--- /dev/null
+++ b/mono/tests/enc/AddClass_v1.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using MonoEnc;
+
+public class AddClass {
+ public static int Main (string []args) {
+ Assembly assm = typeof (AddClass).Assembly;
+ var replacer = EncHelper.Make ();
+
+ var secondClassType = ReplaceMe ();
+ if (secondClassType != typeof (AddClass))
+ return 1;
+
+ try {
+ replacer.Update (assm);
+ /* doesn't work yet, thus should throw exception */
+ return 2;
+ } catch (TargetInvocationException e) {
+ Console.WriteLine ("e: " + e);
+ if (e.InnerException.Message.Contains ("cannot add new class"))
+ return 0;
+ }
+ /* we should not get here, yet */
+ secondClassType = ReplaceMe ();
+ if (secondClassType != typeof (AddClass)) {
+ /* would be expected if it would work */
+ return 4;
+ }
+ return 3;
+ }
+
+ public static System.Type ReplaceMe () {
+ return typeof (SecondClass);
+ }
+}
+
+class SecondClass { }
diff --git a/mono/tests/enc/Makefile.am b/mono/tests/enc/Makefile.am
index d14219d95b4..ae1019892d2 100644
--- a/mono/tests/enc/Makefile.am
+++ b/mono/tests/enc/Makefile.am
@@ -2,6 +2,7 @@ include ../common_mixed.mk
ROSLYNILDIFF ?=/Users/lewurm/work/roslynildiff/bin/Debug/roslynildiff.exe
TESTS_REGULAR := \
+ AddClass.dll \
AddStaticMethod.dll \
CallExisting.dll \
LambdaFunc.dll \