At what point do you say WTF?! Runtime addition of methods to class in C#
public interface InterfaceWithExplicitImpl<T> { IEnumerator<T> GetEnum1(); }
1: class Program
2: {
3: static void Main(string[] args)
4: {
5: Console.WriteLine("Before it has {0} methods", typeof(MyInterfaceWithExplicitImpl<int>).GetMethods().Length);
6:
7: ProxyGenerator generator = new ProxyGenerator(new PersistentProxyBuilder());
8: generator.CreateInterfaceProxyWithoutTarget(typeof(MyInterfaceWithExplicitImpl<int>), new StandardInterceptor());
9: generator = new ProxyGenerator(new PersistentProxyBuilder());
10: generator.CreateInterfaceProxyWithoutTarget(typeof(MyGenericInterface<object>),
11: new Type[] { typeof(MyInterfaceWithExplicitImpl<int>) },
12: new StandardInterceptor());
13:
14:
15: Console.WriteLine("After it has {0} methods", typeof(MyInterfaceWithExplicitImpl<int>).GetMethods().Length);
16: }
17: }
18:
19: public interface MyInterfaceWithExplicitImpl<T>
20: {
21: IEnumerator<T> GetEnum1();
22: }
23:
24: public interface MyGenericInterface<T> where T : new()
25: {
26: T DoSomething(T t);
27: }
Comments
That's wild. What are the methods defined on the interface that are picked up in the debugger?
That is not even the debugger's fault.
Run the code I have there, it will print 1 method and the 2 methods!
Comment preview