diff --git a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs
index 34d81a81..13a01aec 100644
--- a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs
+++ b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs
@@ -362,7 +362,8 @@ namespace Spring.Proxy
{
ArrayList attributes = new ArrayList();
- if (this.ProxyTargetAttributes)
+ if (this.ProxyTargetAttributes &&
+ !type.Equals(typeof(object)))
{
// add attributes that apply to the target type
attributes.AddRange(ReflectionUtils.GetCustomAttributes(type));
@@ -388,7 +389,8 @@ namespace Spring.Proxy
{
ArrayList attributes = new ArrayList();
- if (this.ProxyTargetAttributes)
+ if (this.ProxyTargetAttributes &&
+ !method.DeclaringType.IsInterface)
{
// add attributes that apply to the target method
attributes.AddRange(ReflectionUtils.GetCustomAttributes(method));
@@ -427,7 +429,8 @@ namespace Spring.Proxy
{
ArrayList attributes = new ArrayList();
- if (this.ProxyTargetAttributes)
+ if (this.ProxyTargetAttributes &&
+ !method.DeclaringType.IsInterface)
{
// add attributes that apply to the target method' return type
object[] attrs = method.ReturnTypeCustomAttributes.GetCustomAttributes(false);
@@ -476,7 +479,8 @@ namespace Spring.Proxy
{
ArrayList attributes = new ArrayList();
- if (this.ProxyTargetAttributes)
+ if (this.ProxyTargetAttributes &&
+ !method.DeclaringType.IsInterface)
{
// add attributes that apply to the target method's parameter
#if NET_2_0
diff --git a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs
index b6bd2be1..aaac9280 100644
--- a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs
+++ b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs
@@ -707,8 +707,10 @@ namespace Spring.Proxy
{
}
+ [Marker]
public interface IAnotherMarkerInterface
{
+ [Marker]
void MarkerMethod();
}
diff --git a/test/Spring/Spring.Core.Tests/Proxy/CompositionProxyTypeBuilderTests.cs b/test/Spring/Spring.Core.Tests/Proxy/CompositionProxyTypeBuilderTests.cs
index 4cecd54b..92751b34 100644
--- a/test/Spring/Spring.Core.Tests/Proxy/CompositionProxyTypeBuilderTests.cs
+++ b/test/Spring/Spring.Core.Tests/Proxy/CompositionProxyTypeBuilderTests.cs
@@ -21,6 +21,8 @@
#region Imports
using System;
+using System.Reflection;
+
using NUnit.Framework;
#endregion
@@ -31,6 +33,7 @@ namespace Spring.Proxy
/// Unit tests for the CompositionProxyTypeBuilder class.
///
/// Rick Evans
+ /// Bruno Baia
[TestFixture]
public class CompositionProxyTypeBuilderTests : AbstractProxyTypeBuilderTests
{
@@ -128,9 +131,30 @@ namespace Spring.Proxy
((IFrameworkInterface)foo).FrameworkMethod();
}
+
+ [Test] // SPRNET-1424
+ public void DoesNotProxyInterfaceMethodAttributes()
+ {
+ IProxyTypeBuilder builder = GetProxyBuilder();
+ builder.TargetType = typeof(object);
+ builder.Interfaces = new Type[] { typeof(IAnotherMarkerInterface) };
+
+ Type proxy = builder.BuildProxyType();
+ Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to BuildProxy() was null.");
+ MethodInfo method = proxy.GetMethod("Spring.Proxy.IAnotherMarkerInterface.MarkerMethod", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (method == null)
+ {
+ method = proxy.GetMethod("MarkerMethod");
+ }
+ Assert.IsNotNull(method);
+ object[] attrs = method.GetCustomAttributes(false);
+ Assert.IsNotNull(attrs, "Should have 0 attribute applied to the target method.");
+ Assert.AreEqual(0, attrs.Length, "Should have 0 attribute applied to the target method.");
+ }
+
protected override IProxyTypeBuilder GetProxyBuilder()
{
return new CompositionProxyTypeBuilder();
- }
- }
+ }
+ }
}
\ No newline at end of file