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-23 00:18:28 +0300
committerBernhard Urban-Forster <lewurm@gmail.com>2020-04-23 00:18:28 +0300
commit810342d48575036647f258ebafbfa0d5020a35cf (patch)
tree049ce3a8ce282ccb80492fe944124942d9633aa9
parentf51b5faa14e13aa7134dd174177e56970722d5ff (diff)
[enc] add ReplacePrivateVirtualMethod test
-rw-r--r--mono/tests/enc/Makefile.am1
-rw-r--r--mono/tests/enc/ReplacePrivateVirtualMethod.cs54
-rw-r--r--mono/tests/enc/ReplacePrivateVirtualMethod_v1.cs54
3 files changed, 109 insertions, 0 deletions
diff --git a/mono/tests/enc/Makefile.am b/mono/tests/enc/Makefile.am
index d8e4b7fdfd1..bcddbb91da7 100644
--- a/mono/tests/enc/Makefile.am
+++ b/mono/tests/enc/Makefile.am
@@ -6,6 +6,7 @@ TESTS_REGULAR := \
CallExisting.dll \
ReplaceMethod.dll \
ReplaceMethodOften.dll \
+ ReplacePrivateVirtualMethod.dll \
TypeTokenSwap.dll \
UserStringSwap.dll
diff --git a/mono/tests/enc/ReplacePrivateVirtualMethod.cs b/mono/tests/enc/ReplacePrivateVirtualMethod.cs
new file mode 100644
index 00000000000..6c8946bbc16
--- /dev/null
+++ b/mono/tests/enc/ReplacePrivateVirtualMethod.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using MonoEnc;
+
+class Container {
+ private Thickness _margin;
+
+ public Thickness Margin
+ {
+ get { return _margin; }
+ set { _margin = value; }
+ }
+}
+
+class Thickness {
+ public int val;
+
+ public Thickness (int val)
+ {
+ this.val = val;
+ }
+}
+
+public class Sample {
+ private Container listView;
+
+ public static int Main (string []args) {
+ Assembly assm = typeof (Sample).Assembly;
+ var replacer = EncHelper.Make ();
+
+ Sample s = new Sample ();
+ s.listView = new Container ();
+
+ s.OnItemSelected (null, null);
+ if (s.listView.Margin.val != 30)
+ return 1;
+
+ replacer.Update (assm);
+
+ s.OnItemSelected (null, null);
+ if (s.listView.Margin.val != 40)
+ return 2;
+
+ return 0;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void OnItemSelected (object sender, object s)
+ {
+ listView.Margin = new Thickness (30);
+ }
+}
+
diff --git a/mono/tests/enc/ReplacePrivateVirtualMethod_v1.cs b/mono/tests/enc/ReplacePrivateVirtualMethod_v1.cs
new file mode 100644
index 00000000000..ed40ab374c1
--- /dev/null
+++ b/mono/tests/enc/ReplacePrivateVirtualMethod_v1.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using MonoEnc;
+
+class Container {
+ private Thickness _margin;
+
+ public Thickness Margin
+ {
+ get { return _margin; }
+ set { _margin = value; }
+ }
+}
+
+class Thickness {
+ public int val;
+
+ public Thickness (int val)
+ {
+ this.val = val;
+ }
+}
+
+public class Sample {
+ private Container listView;
+
+ public static int Main (string []args) {
+ Assembly assm = typeof (Sample).Assembly;
+ var replacer = EncHelper.Make ();
+
+ Sample s = new Sample ();
+ s.listView = new Container ();
+
+ s.OnItemSelected (null, null);
+ if (s.listView.Margin.val != 30)
+ return 1;
+
+ replacer.Update (assm);
+
+ s.OnItemSelected (null, null);
+ if (s.listView.Margin.val != 40)
+ return 2;
+
+ return 0;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void OnItemSelected (object sender, object s)
+ {
+ listView.Margin = new Thickness (40);
+ }
+}
+