@@ -843,6 +843,210 @@ raise AssertionError('failed to raise')
843843 assert foo is not bar
844844 " ,
845845 } ,
846+
847+ new TestCase
848+ {
849+ Name = "ref_to_out_param" ,
850+ DotNetBefore = @"
851+ namespace TestNamespace
852+ {
853+
854+ [System.Serializable]
855+ public class Data
856+ {
857+ public int num = -1;
858+ }
859+
860+ [System.Serializable]
861+ public class Cls
862+ {
863+ public static void MyFn (ref Data a)
864+ {
865+ a.num = 7;
866+ }
867+ }
868+ }" ,
869+ DotNetAfter = @"
870+ namespace TestNamespace
871+ {
872+
873+ [System.Serializable]
874+ public class Data
875+ {
876+ public int num = -1;
877+ }
878+
879+ [System.Serializable]
880+ public class Cls
881+ {
882+ public static void MyFn (out Data a)
883+ {
884+ a = new Data();
885+ a.num = 9001;
886+ }
887+ }
888+ }" ,
889+ PythonCode = @"
890+ import clr
891+ import sys
892+ clr.AddReference('DomainTests')
893+ import TestNamespace
894+ import System
895+
896+ def before_reload():
897+
898+ foo = TestNamespace.Data()
899+ bar = TestNamespace.Cls.MyFn(foo)
900+ # foo should have changed
901+ assert foo.num == 7
902+ assert bar.num == 7
903+
904+
905+ def after_reload():
906+
907+ foo = TestNamespace.Data()
908+ bar = TestNamespace.Cls.MyFn(foo)
909+ assert bar.num == 9001
910+ # foo shouldn't have changed.
911+ assert foo.num == -1
912+ # this should work too
913+ baz = TestNamespace.Cls.MyFn(None)
914+ assert baz.num == 9001
915+ " ,
916+ } ,
917+ new TestCase
918+ {
919+ Name = "ref_to_in_param" ,
920+ DotNetBefore = @"
921+ namespace TestNamespace
922+ {
923+
924+ [System.Serializable]
925+ public class Data
926+ {
927+ public int num = -1;
928+ }
929+
930+ [System.Serializable]
931+ public class Cls
932+ {
933+ public static void MyFn (ref Data a)
934+ {
935+ a.num = 7;
936+ System.Console.Write(""Method with ref parameter: "");
937+ System.Console.WriteLine(a.num);
938+ }
939+ }
940+ }" ,
941+ DotNetAfter = @"
942+ namespace TestNamespace
943+ {
944+ [System.Serializable]
945+ public class Data
946+ {
947+ public int num = -1;
948+ }
949+
950+ [System.Serializable]
951+ public class Cls
952+ {
953+ public static void MyFn (Data a)
954+ {
955+ System.Console.Write(""Method with in parameter: "");
956+ System.Console.WriteLine(a.num);
957+ }
958+ }
959+ }" ,
960+ PythonCode = @"
961+ import clr
962+ import sys
963+ clr.AddReference('DomainTests')
964+ import TestNamespace
965+ import System
966+
967+ def before_reload():
968+
969+ foo = TestNamespace.Data()
970+ bar = TestNamespace.Cls.MyFn(foo)
971+ # foo should have changed
972+ assert foo.num == 7
973+ assert bar.num == 7
974+
975+ def after_reload():
976+
977+ foo = TestNamespace.Data()
978+ TestNamespace.Cls.MyFn(foo)
979+ # foo should not have changed
980+ assert foo.num == TestNamespace.Data().num
981+
982+ " ,
983+ } ,
984+ new TestCase
985+ {
986+ Name = "in_to_ref_param" ,
987+ DotNetBefore = @"
988+ namespace TestNamespace
989+ {
990+ [System.Serializable]
991+ public class Data
992+ {
993+ public int num = -1;
994+ }
995+
996+ [System.Serializable]
997+ public class Cls
998+ {
999+ public static void MyFn (Data a)
1000+ {
1001+ System.Console.Write(""Method with in parameter: "");
1002+ System.Console.WriteLine(a.num);
1003+ }
1004+ }
1005+ }" ,
1006+ DotNetAfter = @"
1007+ namespace TestNamespace
1008+ {
1009+
1010+ [System.Serializable]
1011+ public class Data
1012+ {
1013+ public int num = -1;
1014+ }
1015+
1016+ [System.Serializable]
1017+ public class Cls
1018+ {
1019+ public static void MyFn (ref Data a)
1020+ {
1021+ a.num = 7;
1022+ System.Console.Write(""Method with ref parameter: "");
1023+ System.Console.WriteLine(a.num);
1024+ }
1025+ }
1026+ }" ,
1027+ PythonCode = @"
1028+ import clr
1029+ import sys
1030+ clr.AddReference('DomainTests')
1031+ import TestNamespace
1032+ import System
1033+
1034+ def before_reload():
1035+
1036+ foo = TestNamespace.Data()
1037+ TestNamespace.Cls.MyFn(foo)
1038+ # foo should not have changed
1039+ assert foo.num == TestNamespace.Data().num
1040+
1041+ def after_reload():
1042+
1043+ foo = TestNamespace.Data()
1044+ bar = TestNamespace.Cls.MyFn(foo)
1045+ # foo should have changed
1046+ assert foo.num == 7
1047+ assert bar.num == 7
1048+ " ,
1049+ } ,
8461050 new TestCase
8471051 {
8481052 Name = "nested_type" ,
0 commit comments