User: xtoff
Date: 2009/12/29 12:02 PM
Modified:
/DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/
ExplicitInterfaceTestCase.cs
/DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
MixinContributor.cs
/DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
GeneratorUtil.cs, InterfaceProxyWithTargetGenerator.cs,
InterfaceProxyWithoutTargetGenerator.cs
Log:
- made explicitly implemented properties for interface proxies public
File Changes:
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/
=============================================================
File [modified]: ExplicitInterfaceTestCase.cs
Delta lines: +0 -0
===================================================================
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
====================================================================
File [modified]: MixinContributor.cs
Delta lines: +1 -1
===================================================================
--- DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/GeneratorUtil.cs
2009-12-29 16:55:27 UTC (rev 6541)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/GeneratorUtil.cs
2009-12-29 19:02:18 UTC (rev 6542)
@@ -89,7 +89,7 @@
var methodInfo = methodToGenerate.Method;
var name = methodInfo.DeclaringType.Name + "." +
methodInfo.Name;
var attributes = MethodAttributes.Virtual |
-
MethodAttributes.Private |
+
MethodAttributes.Public |
MethodAttributes.HideBySig |
MethodAttributes.NewSlot |
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
==================================================================
File [modified]: GeneratorUtil.cs
Delta lines: +6 -7
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetGenerator.cs
2009-12-29 16:55:27 UTC (rev 6541)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetGenerator.cs
2009-12-29 19:02:18 UTC (rev 6542)
@@ -126,13 +126,12 @@
protected virtual Type GenerateType(string typeName, Type
proxyTargetType, Type[] interfaces, INamingScope namingScope)
{
- // TODO: this anemic dictionary should be made into a
real object
IEnumerable<ITypeContributor> contributors;
- var typeImplementerMapping =
GetTypeImplementerMapping(interfaces, proxyTargetType, out
contributors,namingScope);
+ var allInterfaces =
GetTypeImplementerMapping(interfaces, proxyTargetType, out contributors,
namingScope);
ClassEmitter emitter;
FieldReference interceptorsField;
- Type baseType = Init(typeName, typeImplementerMapping,
out emitter, proxyTargetType, out interceptorsField);
+ Type baseType = Init(typeName, out emitter,
proxyTargetType, out interceptorsField, allInterfaces);
// Collect methods
@@ -180,11 +179,11 @@
return generatedType;
}
- protected virtual Type Init(string typeName, IDictionary<Type,
ITypeContributor> typeImplementerMapping, out ClassEmitter emitter, Type
proxyTargetType, out FieldReference interceptorsField)
+ protected virtual Type Init(string typeName, out ClassEmitter
emitter, Type proxyTargetType, out FieldReference interceptorsField,
IEnumerable<Type> interfaces)
{
Type baseType =
ProxyGenerationOptions.BaseTypeForInterfaceProxy;
- emitter = BuildClassEmitter(typeName, baseType,
typeImplementerMapping.Keys);
+ emitter = BuildClassEmitter(typeName, baseType,
interfaces);
CreateOptionsField(emitter);
emitter.AddCustomAttributes(ProxyGenerationOptions);
#if SILVERLIGHT
@@ -224,7 +223,7 @@
get { return false; }
}
- protected virtual IDictionary<Type, ITypeContributor>
GetTypeImplementerMapping(Type[] interfaces, Type proxyTargetType, out
IEnumerable<ITypeContributor> contributors, INamingScope namingScope)
+ protected virtual IEnumerable<Type>
GetTypeImplementerMapping(Type[] interfaces, Type proxyTargetType, out
IEnumerable<ITypeContributor> contributors, INamingScope namingScope)
{
IDictionary<Type, ITypeContributor>
typeImplementerMapping = new Dictionary<Type, ITypeContributor>();
var mixins = new MixinContributor(namingScope,
AllowChangeTarget) { Logger = Logger };
@@ -291,7 +290,7 @@
mixins,
instance
};
- return typeImplementerMapping;
+ return typeImplementerMapping.Keys;
}
File [modified]: InterfaceProxyWithTargetGenerator.cs
Delta lines: +2 -2
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithoutTargetGenerator.cs
2009-12-29 16:55:27 UTC (rev 6541)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithoutTargetGenerator.cs
2009-12-29 19:02:18 UTC (rev 6542)
@@ -44,7 +44,7 @@
{
// TODO: this anemic dictionary should be made into a
real object
IEnumerable<ITypeContributor> contributors;
- var typeImplementerMapping =
GetTypeImplementerMapping(interfaces, targetType, out contributors,namingScope);
+ var allInterfaces =
GetTypeImplementerMapping(interfaces, targetType, out contributors,namingScope);
// collect elements
foreach (var contributor in contributors)
@@ -56,7 +56,7 @@
ClassEmitter emitter;
FieldReference interceptorsField;
- Type baseType = Init(typeName, typeImplementerMapping,
out emitter, proxyTargetType, out interceptorsField);
+ Type baseType = Init(typeName, out emitter,
proxyTargetType, out interceptorsField, allInterfaces);
File [modified]: InterfaceProxyWithoutTargetGenerator.cs
Delta lines: +29 -0
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/ExplicitInterfaceTestCase.cs
2009-12-29 16:55:27 UTC (rev 6541)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/ExplicitInterfaceTestCase.cs
2009-12-29 19:02:18 UTC (rev 6542)
@@ -14,6 +14,8 @@
namespace Castle.DynamicProxy.Tests
{
+ using System;
+
using Castle.DynamicProxy.Tests.Classes;
using Castle.DynamicProxy.Tests.Interceptors;
@@ -81,5 +83,32 @@
Assert.AreEqual (0, result); // indicates that original
method was not called
}
+
+ [Test]
+ public void
ExplicitInterface_properties_should_be_public_interface()
+ {
+ var interceptor = new LogInvocationInterceptor {
Proceed = false };
+
+ var proxy =
generator.CreateInterfaceProxyWithoutTarget(typeof(ISimpleInterfaceWithProperty),
interceptor);
+ Assert.IsNotEmpty(proxy.GetType().GetProperties());
+ }
+
+ [Test]
+ public void
ExplicitInterface_properties_should_be_public_class()
+ {
+ var interceptor = new LogInvocationInterceptor {
Proceed = false };
+
+ var proxy =
generator.CreateClassProxy(typeof(ExplicitInterfaceWithPropertyImplementation),
new[] { typeof(ISimpleInterfaceWithProperty) },
+ interceptor);
+ Assert.IsNotEmpty(proxy.GetType().GetProperties());
+ }
}
+
+ public class ExplicitInterfaceWithPropertyImplementation:
ISimpleInterfaceWithProperty
+ {
+ public int Age
+ {
+ get { throw new NotImplementedException(); }
+ }
+ }
}
--
You received this message because you are subscribed to the Google Groups
"Castle Project Commits" 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-commits?hl=en.