| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,7 +79,7 @@ private interface IPrivate | |||
| 79 | 79 | { | |
| 80 | 80 | } | |
| 81 | 81 | } | |
| 82 | - | ||
| 82 | + | ||
| 83 | 83 | public interface IOutArg | |
| 84 | 84 | { | |
| 85 | 85 | string MyMethod_Out(string name, out int index); | |
@@ -93,4 +93,25 @@ public static int CallMyMethod_Out(IOutArg myInterface) | |||
| 93 | 93 | return index; | |
| 94 | 94 | } | |
| 95 | 95 | } | |
| 96 | + | ||
| 97 | + public interface IGenericInterface<T> | ||
| 98 | + { | ||
| 99 | + public T Get(T x); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public class SpecificInterfaceUser | ||
| 103 | + { | ||
| 104 | + public SpecificInterfaceUser(IGenericInterface<int> some, int x) | ||
| 105 | + { | ||
| 106 | + some.Get(x); | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + public class GenericInterfaceUser<T> | ||
| 111 | + { | ||
| 112 | + public GenericInterfaceUser(IGenericInterface<T> some, T x) | ||
| 113 | + { | ||
| 114 | + some.Get(x); | ||
| 115 | + } | ||
| 116 | + } | ||
| 96 | 117 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ | |||
| 9 | 9 | import System | |
| 10 | 10 | import pytest | |
| 11 | 11 | from Python.Test import (IInterfaceTest, SubClassTest, EventArgsTest, | |
| 12 | - FunctionsTest) | ||
| 12 | + FunctionsTest, IGenericInterface) | ||
| 13 | 13 | from System.Collections.Generic import List | |
| 14 | 14 | ||
| 15 | 15 | ||
@@ -29,6 +29,17 @@ def bar(self, x, i): | |||
| 29 | 29 | return InterfaceTestClass | |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | + def interface_generic_class_fixture(subnamespace): | ||
| 33 | + | ||
| 34 | + class GenericInterfaceImpl(IGenericInterface[int]): | ||
| 35 | + __namespace__ = "Python.Test." + subnamespace | ||
| 36 | + | ||
| 37 | + def Get(self, x): | ||
| 38 | + return x | ||
| 39 | + | ||
| 40 | + return GenericInterfaceImpl | ||
| 41 | + | ||
| 42 | + | ||
| 32 | 43 | def derived_class_fixture(subnamespace): | |
| 33 | 44 | """Delay creation of class until test starts.""" | |
| 34 | 45 | ||
@@ -306,3 +317,13 @@ class Derived(BaseClass): | |||
| 306 | 317 | ||
| 307 | 318 | import gc | |
| 308 | 319 | gc.collect() | |
| 320 | + | ||
| 321 | + def test_generic_interface(): | ||
| 322 | + from System import Int32 | ||
| 323 | + from Python.Test import GenericInterfaceUser, SpecificInterfaceUser | ||
| 324 | + | ||
| 325 | + GenericInterfaceImpl = interface_generic_class_fixture(test_generic_interface.__name__) | ||
| 326 | + | ||
| 327 | + obj = GenericInterfaceImpl() | ||
| 328 | + SpecificInterfaceUser(obj, Int32(0)) | ||
| 329 | + GenericInterfaceUser[Int32](obj, Int32(0)) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments