Dynamic proxying IEnumerable <T>

I am trying to create a dynamic proxy for a list of objects of a specific class. For instance:

var proxy = generator.CreateInterfaceProxyWithoutTarget(typeof (IEnumerable<string>), interceptor); 

But I get the following exception:

Cannot resolve the System.Collections.Generic.IEnumerator`1 [System .__ Canon] GetEnumerator () method because declaring the type of the method to handle System.Collections.Generic.IEnumerable`1 [T] is universal. Explicitly specify the type of declaration GetMethodFromHandle.

I am trying to proxy IEnumerable <> to cache calls to create the list itself.

+4
source share

Source: https://habr.com/ru/post/1390924/


All Articles