| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d6c0081 commit ed6763c
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -843,6 +843,210 @@ raise AssertionError('failed to raise') | |||
| 843 | 843 | assert foo is not bar | |
| 844 | 844 | ", | |
| 845 | 845 | }, | |
| 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 | + }, | ||
| 846 | 1050 | new TestCase | |
| 847 | 1051 | { | |
| 848 | 1052 | Name = "nested_type", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,6 +83,18 @@ def test_construct_removed_class(): | |||
| 83 | 83 | def test_out_to_ref_param(): | |
| 84 | 84 | _run_test("out_to_ref_param") | |
| 85 | 85 | ||
| 86 | + @pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library') | ||
| 87 | + def test_ref_to_out_param(): | ||
| 88 | + _run_test("ref_to_out_param") | ||
| 89 | + | ||
| 90 | + @pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library') | ||
| 91 | + def test_ref_to_in_param(): | ||
| 92 | + _run_test("ref_to_in_param") | ||
| 93 | + | ||
| 94 | + @pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library') | ||
| 95 | + def test_in_to_ref_param(): | ||
| 96 | + _run_test("in_to_ref_param") | ||
| 97 | + | ||
| 86 | 98 | @pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library') | |
| 87 | 99 | def test_nested_type(): | |
| 88 | 100 | _run_test("nested_type") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,11 +35,11 @@ public ParameterHelper(ParameterInfo tp) | |||
| 35 | 35 | Name = tp.ParameterType.AssemblyQualifiedName; | |
| 36 | 36 | Modifier = TypeModifier.None; | |
| 37 | 37 | ||
| 38 | - if (tp.IsIn) | ||
| 38 | + if (tp.IsIn && tp.ParameterType.IsByRef) | ||
| 39 | 39 | { | |
| 40 | 40 | Modifier = TypeModifier.In; | |
| 41 | 41 | } | |
| 42 | - else if (tp.IsOut) | ||
| 42 | + else if (tp.IsOut && tp.ParameterType.IsByRef) | ||
| 43 | 43 | { | |
| 44 | 44 | Modifier = TypeModifier.Out; | |
| 45 | 45 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments