Hi there,
        
The user Jeremy Roy (jaroy) has changed the issue DYNPROXY-ISSUE-133 "Debug 
assertion in ClassProxyInstanceContributor fails when proxying 
System.Net.WebRequest, System.Net.WebResponse".
        
Here is what the user changed:
        
        Description
                from: The following C# code reliably generates a debug 
assertion for me using 2.2.0.6628:
new ProxyGenerator().CreateClassProxy(
    typeof (System.Net.WebRequest), 
    new IInterceptor[] {});
The assertion stack is:
        
==================================
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Contributors.ClassProxyInstanceContributor.VerifyIfBaseImplementsGetObjectData(System.Type
 baseType = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Collections.Generic.IList<System.Reflection.MethodInfo> methodsToSkip = 
Count = 0) + 0x1b2 bytes    
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Contributors.ClassProxyInstanceContributor.ClassProxyInstanceContributor(System.Type
 targetType = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Collections.Generic.IList<System.Reflection.MethodInfo> methodsToSkip = 
Count = 0, System.Type[] interfaces = null) + 0xf0 bytes        
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Generators.ClassProxyGenerator.GetTypeImplementerMapping(System.Type[]
 interfaces = null, out 
System.Collections.Generic.IEnumerable<Castle.DynamicProxy.Contributors.ITypeContributor>
 contributors = null, Castle.DynamicProxy.Generators.INamingScope namingScope = 
{Castle.DynamicProxy.Generators.NamingScope}) + 0x13a bytes 
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType(string
 name = "Castle.Proxies.WebRequestProxy", System.Type[] interfaces = null, 
Castle.DynamicProxy.Generators.INamingScope namingScope = 
{Castle.DynamicProxy.Generators.NamingScope}) + 0xc9 bytes  
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(System.Type[]
 interfaces = null, Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}) + 0x696 bytes      
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Type[] additionalInterfacesToProxy = null, 
Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}) + 0xe5 bytes    
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.ProxyGenerator.CreateClassProxyType(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Type[] additionalInterfacesToProxy = null, 
Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}) + 0x7d bytes 
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Type[] additionalInterfacesToProxy = null, 
Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}, object[] constructorArguments = 
null, Castle.Core.Interceptor.IInterceptor[] interceptors = 
{Castle.Core.Interceptor.IInterceptor[0]}) + 0x217 bytes     
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
Castle.Core.Interceptor.IInterceptor[] interceptors = 
{Castle.Core.Interceptor.IInterceptor[0]}) + 0x64 bytes 
====================================
Looking at the source, the assertion is comparing the method name to 
"GetObjectData", but for System.Net.WebRequest, the method name returned from 
GetInterfaceMap() is "System.Runtime.Serialization.ISerializable.GetObjectData":
typeof (System.Net.WebRequest).GetInterfaceMap(typeof 
(ISerializable)).TargetMethods[0].Name
I don't know what is special about WebRequest that causes this and have been 
unsuccessful in reproducing it with my own class definition.  The same problem 
occurs with System.Net.WebResponse.
We're using DynamicProxy (via Moq) in our unit tests, so constantly clicking 
away the debug assertion is pretty painful.
                to: The following C# code reliably generates a debug assertion 
for me using 2.2.0.6628:
new ProxyGenerator().CreateClassProxy(typeof (System.Net.WebRequest), new 
IInterceptor[] {});
The assertion stack is:
        
==================================
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Contributors.ClassProxyInstanceContributor.VerifyIfBaseImplementsGetObjectData(System.Type
 baseType = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Collections.Generic.IList<System.Reflection.MethodInfo> methodsToSkip = 
Count = 0) + 0x1b2 bytes    
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Contributors.ClassProxyInstanceContributor.ClassProxyInstanceContributor(System.Type
 targetType = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Collections.Generic.IList<System.Reflection.MethodInfo> methodsToSkip = 
Count = 0, System.Type[] interfaces = null) + 0xf0 bytes        
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Generators.ClassProxyGenerator.GetTypeImplementerMapping(System.Type[]
 interfaces = null, out 
System.Collections.Generic.IEnumerable<Castle.DynamicProxy.Contributors.ITypeContributor>
 contributors = null, Castle.DynamicProxy.Generators.INamingScope namingScope = 
{Castle.DynamicProxy.Generators.NamingScope}) + 0x13a bytes 
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType(string
 name = "Castle.Proxies.WebRequestProxy", System.Type[] interfaces = null, 
Castle.DynamicProxy.Generators.INamingScope namingScope = 
{Castle.DynamicProxy.Generators.NamingScope}) + 0xc9 bytes  
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(System.Type[]
 interfaces = null, Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}) + 0x696 bytes      
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Type[] additionalInterfacesToProxy = null, 
Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}) + 0xe5 bytes    
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.ProxyGenerator.CreateClassProxyType(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Type[] additionalInterfacesToProxy = null, 
Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}) + 0x7d bytes 
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
System.Type[] additionalInterfacesToProxy = null, 
Castle.DynamicProxy.ProxyGenerationOptions options = 
{Castle.DynamicProxy.ProxyGenerationOptions}, object[] constructorArguments = 
null, Castle.Core.Interceptor.IInterceptor[] interceptors = 
{Castle.Core.Interceptor.IInterceptor[0]}) + 0x217 bytes     
        
Castle.DynamicProxy2.dll!Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(System.Type
 classToProxy = {Name = "WebRequest" FullName = "System.Net.WebRequest"}, 
Castle.Core.Interceptor.IInterceptor[] interceptors = 
{Castle.Core.Interceptor.IInterceptor[0]}) + 0x64 bytes 
====================================
Looking at the source, the assertion is comparing the method name to 
"GetObjectData", but for System.Net.WebRequest, the method name returned from 
GetInterfaceMap() is "System.Runtime.Serialization.ISerializable.GetObjectData":
typeof (System.Net.WebRequest).GetInterfaceMap(typeof 
(ISerializable)).TargetMethods[0].Name
I don't know what is special about WebRequest that causes this and have been 
unsuccessful in reproducing it with my own class definition.  The same problem 
occurs with System.Net.WebResponse.
We're using DynamicProxy (via Moq) in our unit tests, so constantly clicking 
away the debug assertion is pretty painful.
        
For more, see 
http://support.castleproject.org/projects/DYNPROXY/issues/view/DYNPROXY-ISSUE-133
 
        
--
donjon
by Castle Stronghold
http://www.castle-donjon.com


-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

Reply via email to