User: xtoff
Date: 2009/11/11 12:33 PM
Modified:
/DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
ClassProxyTargetContributor.cs, Delegates.cs,
InterfaceMethodGeneratorBase.cs, InterfaceProxyWithoutTargetContributor.cs,
MinimialisticMethodGenerator.cs
/DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
GeneratorUtil.cs, MethodWithCallbackGenerator.cs
Log:
- fixed issue with non-proxied abstract methods
File Changes:
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
====================================================================
File [modified]: ClassProxyTargetContributor.cs
Delta lines: +3 -0
===================================================================
--- DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/Delegates.cs
2009-11-10 21:08:21 UTC (rev 6311)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/Delegates.cs
2009-11-11 19:33:37 UTC (rev 6312)
@@ -15,10 +15,13 @@
namespace Castle.DynamicProxy.Contributors
{
using System.Reflection;
+
+ using Castle.DynamicProxy.Generators;
using Castle.DynamicProxy.Generators.Emitters;
using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
public delegate MethodEmitter CreateMethodDelegate(string name,
MethodAttributes attributes);
+ public delegate MethodAttributes GetMethodAttributesDelegate(out string
methodName, MethodToGenerate method);
public delegate Expression GetTargetExpressionDelegate(ClassEmitter
@class, MethodInfo method);
File [modified]: Delegates.cs
Delta lines: +1 -16
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceMethodGeneratorBase.cs
2009-11-10 21:08:21 UTC (rev 6311)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceMethodGeneratorBase.cs
2009-11-11 19:33:37 UTC (rev 6312)
@@ -42,7 +42,7 @@
public override MethodEmitter Generate(ClassEmitter @class,
ProxyGenerationOptions options, INamingScope namingScope)
{
string name;
- MethodAttributes atts = ObtainMethodAttributes(out
name);
+ MethodAttributes atts
=GeneratorUtil.ObtainInterfaceMethodAttributes(out name, method);
MethodEmitter methodEmitter = createMethod(name, atts);
MethodEmitter proxiedMethod =
ImplementProxiedMethod(methodEmitter, @class,options,namingScope);
@@ -50,22 +50,7 @@
return proxiedMethod;
}
- private MethodAttributes ObtainMethodAttributes(out string name)
- {
- var methodInfo = method.Method;
- name = methodInfo.DeclaringType.Name + "." +
methodInfo.Name;
- var attributes = MethodAttributes.Virtual |
- MethodAttributes.Private |
- MethodAttributes.HideBySig |
- MethodAttributes.NewSlot |
- MethodAttributes.Final;
- if (method.Standalone == false)
- {
- attributes |= MethodAttributes.SpecialName;
- }
- return attributes;
- }
protected abstract MethodEmitter
ImplementProxiedMethod(MethodEmitter emitter, ClassEmitter @class,
ProxyGenerationOptions options, INamingScope namingScope);
File [modified]: InterfaceMethodGeneratorBase.cs
Delta lines: +1 -1
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyWithoutTargetContributor.cs
2009-11-10 21:08:21 UTC (rev 6311)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyWithoutTargetContributor.cs
2009-11-11 19:33:37 UTC (rev 6312)
@@ -116,7 +116,7 @@
}
else
{
- generator= new
MinimialisticMethodGenerator(method, createMethod);
+ generator= new
MinimialisticMethodGenerator(method, createMethod,
GeneratorUtil.ObtainInterfaceMethodAttributes);
}
File [modified]: InterfaceProxyWithoutTargetContributor.cs
Delta lines: +77 -0
===================================================================
--- DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/GeneratorUtil.cs
2009-11-10 21:08:21 UTC (rev 6311)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/GeneratorUtil.cs
2009-11-11 19:33:37 UTC (rev 6312)
@@ -22,6 +22,83 @@
public static class GeneratorUtil
{
+ private static bool
IsInterfaceMethodForExplicitImplementation(MethodToGenerate methodToGenerate)
+ {
+ return
methodToGenerate.Method.DeclaringType.IsInterface &&
+ methodToGenerate.MethodOnTarget.IsFinal;
+ }
+
+ public static MethodAttributes ObtainClassMethodAttributes(out
string name, MethodToGenerate methodToGenerate)
+ {
+ var methodInfo = methodToGenerate.Method;
+ MethodAttributes attributes = MethodAttributes.Virtual;
+ if
(IsInterfaceMethodForExplicitImplementation(methodToGenerate))
+ {
+ name = methodInfo.DeclaringType.Name + "." +
methodInfo.Name;
+ attributes |= MethodAttributes.Private |
+
MethodAttributes.HideBySig |
+
MethodAttributes.NewSlot |
+
MethodAttributes.Final;
+ }
+ else
+ {
+ if (methodInfo.IsFinal)
+ {
+ attributes |= MethodAttributes.NewSlot;
+ }
+
+ if (methodInfo.IsPublic)
+ {
+ attributes |= MethodAttributes.Public;
+ }
+
+ if (methodInfo.IsHideBySig)
+ {
+ attributes |=
MethodAttributes.HideBySig;
+ }
+ if (InternalsHelper.IsInternal(methodInfo) &&
InternalsHelper.IsInternalToDynamicProxy(methodInfo.DeclaringType.Assembly))
+ {
+ attributes |= MethodAttributes.Assembly;
+ }
+ if (methodInfo.IsFamilyAndAssembly)
+ {
+ attributes |=
MethodAttributes.FamANDAssem;
+ }
+ else if (methodInfo.IsFamilyOrAssembly)
+ {
+ attributes |=
MethodAttributes.FamORAssem;
+ }
+ else if (methodInfo.IsFamily)
+ {
+ attributes |= MethodAttributes.Family;
+ }
+ name = methodInfo.Name;
+ }
+
+ if (methodToGenerate.Standalone == false)
+ {
+ attributes |= MethodAttributes.SpecialName;
+ }
+ return attributes;
+ }
+
+ public static MethodAttributes
ObtainInterfaceMethodAttributes(out string name, MethodToGenerate
methodToGenerate)
+ {
+ var methodInfo = methodToGenerate.Method;
+ name = methodInfo.DeclaringType.Name + "." +
methodInfo.Name;
+ var attributes = MethodAttributes.Virtual |
+
MethodAttributes.Private |
+
MethodAttributes.HideBySig |
+
MethodAttributes.NewSlot |
+ MethodAttributes.Final;
+
+ if (methodToGenerate.Standalone == false)
+ {
+ attributes |= MethodAttributes.SpecialName;
+ }
+ return attributes;
+ }
+
public static void CopyOutAndRefParameters(TypeReference[]
dereferencedArguments, LocalReference invocation, MethodInfo method,
MethodEmitter emitter)
{
File [modified]: MinimialisticMethodGenerator.cs
Delta lines: None
None
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
==================================================================
File [modified]: GeneratorUtil.cs
Delta lines: +1 -59
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/MethodWithCallbackGenerator.cs
2009-11-10 21:08:21 UTC (rev 6311)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/MethodWithCallbackGenerator.cs
2009-11-11 19:33:37 UTC (rev 6312)
@@ -44,7 +44,7 @@
public override MethodEmitter Generate(ClassEmitter @class,
ProxyGenerationOptions options, INamingScope namingScope)
{
string name;
- var atts = ObtainMethodAttributes(out name);
+ var atts =
GeneratorUtil.ObtainClassMethodAttributes(out name, method);
var methodEmitter = createMethod(name, atts);
var proxiedMethod =
ImplementProxiedMethod(methodEmitter,
@class,
@@ -214,64 +214,6 @@
genericParamsArrayLocal))));
}
- private bool IsInterfaceMethodForExplicitImplementation()
- {
- return method.Method.DeclaringType.IsInterface &&
- method.MethodOnTarget.IsFinal;
- }
- private MethodAttributes ObtainMethodAttributes(out string name)
- {
- var methodInfo = method.Method;
- MethodAttributes attributes = MethodAttributes.Virtual;
- if (IsInterfaceMethodForExplicitImplementation())
- {
- name = methodInfo.DeclaringType.Name + "." +
methodInfo.Name;
- attributes |= MethodAttributes.Private |
- MethodAttributes.HideBySig |
- MethodAttributes.NewSlot |
- MethodAttributes.Final;
- }
- else
- {
- if (methodInfo.IsFinal)
- {
- attributes |= MethodAttributes.NewSlot;
- }
-
- if (methodInfo.IsPublic)
- {
- attributes |= MethodAttributes.Public;
- }
-
- if (methodInfo.IsHideBySig)
- {
- attributes |=
MethodAttributes.HideBySig;
- }
- if (InternalsHelper.IsInternal(methodInfo) &&
InternalsHelper.IsInternalToDynamicProxy(methodInfo.DeclaringType.Assembly))
- {
- attributes |= MethodAttributes.Assembly;
- }
- if (methodInfo.IsFamilyAndAssembly)
- {
- attributes |=
MethodAttributes.FamANDAssem;
- }
- else if (methodInfo.IsFamilyOrAssembly)
- {
- attributes |=
MethodAttributes.FamORAssem;
- }
- else if (methodInfo.IsFamily)
- {
- attributes |= MethodAttributes.Family;
- }
- name = methodInfo.Name;
- }
-
- if (method.Standalone == false)
- {
- attributes |= MethodAttributes.SpecialName;
- }
- return attributes;
- }
}
}
File [modified]: MethodWithCallbackGenerator.cs
Delta lines: +0 -0
===================================================================
--
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=.