@@ -52,6 +52,94 @@ public void Generic_method_of_interface_proxy_without_target__uses__InterfaceMet
5252 Assert . AreEqual ( typeof ( InterfaceMethodWithoutTargetInvocation ) , recorder . InvocationType ) ;
5353 }
5454
55+ [ Test ]
56+ public void Non_generic_abstract_method_of_class_proxy__uses__InheritanceInvocationWithoutTarget ( )
57+ {
58+ var recorder = new InvocationTypeRecorder ( ) ;
59+
60+ var proxy = generator . CreateClassProxy < WithNonGenericAbstractMethod > ( recorder ) ;
61+ proxy . Method ( ) ;
62+
63+ Assert . AreEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
64+ }
65+
66+ [ Test ]
67+ public void Non_generic_protected_abstract_method_of_class_proxy__uses__InheritanceInvocationWithoutTarget ( )
68+ {
69+ var recorder = new InvocationTypeRecorder ( ) ;
70+
71+ var proxy = generator . CreateClassProxy < WithNonGenericProtectedAbstractMethod > ( recorder ) ;
72+ proxy . InvokeMethod ( ) ;
73+
74+ Assert . AreEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
75+ }
76+
77+ [ Test ]
78+ public void Non_generic_virtual_method_of_class_proxy__does_not_use__InheritanceInvocationWithoutTarget ( )
79+ {
80+ var recorder = new InvocationTypeRecorder ( ) ;
81+
82+ var proxy = generator . CreateClassProxy < WithNonGenericVirtualMethod > ( recorder ) ;
83+ proxy . Method ( ) ;
84+
85+ Assert . AreNotEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
86+ }
87+
88+ [ Test ]
89+ public void Non_generic_protected_virtual_method_of_class_proxy__does_not_use__InheritanceInvocationWithoutTarget ( )
90+ {
91+ var recorder = new InvocationTypeRecorder ( ) ;
92+
93+ var proxy = generator . CreateClassProxy < WithNonGenericProtectedVirtualMethod > ( recorder ) ;
94+ proxy . InvokeMethod ( ) ;
95+
96+ Assert . AreNotEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
97+ }
98+
99+ [ Test ]
100+ public void Generic_abstract_method_of_class_proxy__uses__InheritanceInvocationWithoutTarget ( )
101+ {
102+ var recorder = new InvocationTypeRecorder ( ) ;
103+
104+ var proxy = generator . CreateClassProxy < WithGenericAbstractMethod > ( recorder ) ;
105+ proxy . Method ( 42 ) ;
106+
107+ Assert . AreEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
108+ }
109+
110+ [ Test ]
111+ public void Generic_protected_abstract_method_of_class_proxy__uses__InheritanceInvocationWithoutTarget ( )
112+ {
113+ var recorder = new InvocationTypeRecorder ( ) ;
114+
115+ var proxy = generator . CreateClassProxy < WithGenericProtectedAbstractMethod > ( recorder ) ;
116+ proxy . InvokeMethod ( 42 ) ;
117+
118+ Assert . AreEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
119+ }
120+
121+ [ Test ]
122+ public void Generic_virtual_method_of_class_proxy__does_not_use__InheritanceInvocationWithoutTarget ( )
123+ {
124+ var recorder = new InvocationTypeRecorder ( ) ;
125+
126+ var proxy = generator . CreateClassProxy < WithGenericVirtualMethod > ( recorder ) ;
127+ proxy . Method ( 42 ) ;
128+
129+ Assert . AreNotEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
130+ }
131+
132+ [ Test ]
133+ public void Generic_protected_virtual_method_of_class_proxy__does_not_use__InheritanceInvocationWithoutTarget ( )
134+ {
135+ var recorder = new InvocationTypeRecorder ( ) ;
136+
137+ var proxy = generator . CreateClassProxy < WithGenericProtectedVirtualMethod > ( recorder ) ;
138+ proxy . InvokeMethod ( 42 ) ;
139+
140+ Assert . AreNotEqual ( typeof ( InheritanceInvocationWithoutTarget ) , recorder . InvocationType ) ;
141+ }
142+
55143 public interface IWithNonGenericMethod
56144 {
57145 void Method ( ) ;
@@ -62,6 +150,50 @@ public interface IWithGenericMethod
62150 void Method < T > ( T arg ) ;
63151 }
64152
153+ public abstract class WithNonGenericAbstractMethod
154+ {
155+ public abstract void Method ( ) ;
156+ }
157+
158+ public abstract class WithNonGenericProtectedAbstractMethod
159+ {
160+ protected abstract void Method ( ) ;
161+ public void InvokeMethod ( ) => Method ( ) ;
162+ }
163+
164+ public class WithNonGenericVirtualMethod
165+ {
166+ public virtual void Method ( ) { }
167+ }
168+
169+ public class WithNonGenericProtectedVirtualMethod
170+ {
171+ protected virtual void Method ( ) { }
172+ public void InvokeMethod ( ) => Method ( ) ;
173+ }
174+
175+ public abstract class WithGenericAbstractMethod
176+ {
177+ public abstract void Method < T > ( T arg ) ;
178+ }
179+
180+ public abstract class WithGenericProtectedAbstractMethod
181+ {
182+ protected abstract void Method < T > ( T arg ) ;
183+ public void InvokeMethod < T > ( T arg ) => Method ( arg ) ;
184+ }
185+
186+ public class WithGenericVirtualMethod
187+ {
188+ public virtual void Method < T > ( T arg ) { }
189+ }
190+
191+ public class WithGenericProtectedVirtualMethod
192+ {
193+ protected virtual void Method < T > ( T arg ) { }
194+ public void InvokeMethod < T > ( T arg ) => Method ( arg ) ;
195+ }
196+
65197 private sealed class InvocationTypeRecorder : IInterceptor
66198 {
67199 public Type InvocationType { get ; private set ; }
0 commit comments