User: xtoff
Date: 2009/10/27 11:55 AM

Added:
 /DynamicProxy/trunk/src/Castle.DynamicProxy/
  IAttributeDisassembler.cs

Removed:
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
  TypeContributor.cs
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/
  IHasCustomAttributesEmitter.cs

Modified:
 /DynamicProxy/trunk/src/Castle.DynamicProxy/
  AttributeUtil.cs, Castle.DynamicProxy-vs2008.csproj
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
  ClassProxyInstanceContributor.cs, ClassProxyTargetContributor.cs, 
InterfaceProxyTargetContributor.cs, InterfaceProxyWithoutTargetContributor.cs, 
MembersCollector.cs, MixinContributor.cs, MixinContributorBase.cs, 
ProxyInstanceContributor.cs
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
  PropertyToGenerate.cs
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/
  AbstractTypeEmitter.cs, MethodEmitter.cs, PropertyEmitter.cs

Log:
 - Due to fact that CustomAttributeData is internal in Silverlight the solution 
from earlier committ won't work in SL. Hence IAttributeDisassembler is back, to 
support SL (and fallback scenarios in .NET).

File Changes:

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/
=======================================================

File [modified]: AttributeUtil.cs
Delta lines: +1 -2
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Castle.DynamicProxy-vs2008.csproj    
    2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Castle.DynamicProxy-vs2008.csproj    
    2009-10-27 18:55:22 UTC (rev 6275)
@@ -110,12 +110,10 @@
     <Compile Include="Contributors\MethodWithCallbackGenerator.cs" />
     <Compile Include="Contributors\MixinContributorBase.cs" />
     <Compile Include="Contributors\ForwardingMethodGenerator.cs" />
-    <Compile Include="Contributors\TypeContributor.cs" />
     <Compile Include="DefaultProxyBuilder.cs" />
     <Compile Include="Contributors\ClassProxyInstanceContributor.cs" />
     <Compile Include="Contributors\ClassProxyTargetContributor.cs" />
     <Compile Include="AttributeUtil.cs" />
-    <Compile Include="Generators\Emitters\IHasCustomAttributesEmitter.cs" />
     <Compile 
Include="Generators\Emitters\SimpleAST\AssignArgumentStatement.cs" />
     <Compile Include="Generators\Emitters\SimpleAST\AsTypeReference.cs" />
     <Compile Include="Generators\AttributesToAvoidReplicating.cs" />
@@ -295,6 +293,7 @@
     <Compile Include="Contributors\MembersCollector.cs" />
     <Compile Include="Contributors\ProxyInstanceContributor.cs" />
     <Compile Include="Generators\ProxyMethod.cs" />
+    <Compile Include="IAttributeDisassembler.cs" />
     <Compile Include="InternalsHelper.cs" />
     <Compile Include="InvalidMixinConfigurationException.cs" />

File [modified]: Castle.DynamicProxy-vs2008.csproj
Delta lines: +4 -1
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassProxyInstanceContributor.cs
    2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassProxyInstanceContributor.cs
    2009-10-27 18:55:22 UTC (rev 6275)
@@ -59,7 +59,10 @@
                        }
 #endif
                        ImplementProxyTargetAccessor(@class, interceptors);
-                       ReplicateNonInheritableAttributes(targetType, @class);
+                       foreach (var attribute in 
AttributeUtil.GetNonInheritableAttributes(targetType))
+                       {
+                               @class.DefineCustomAttribute(attribute);
+                       }
                }
 #if !SILVERLIGHT

File [added]: IAttributeDisassembler.cs
Delta lines: +0 -0
===================================================================

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
====================================================================

File [modified]: ClassProxyInstanceContributor.cs
Delta lines: +7 -4
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassProxyTargetContributor.cs
      2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassProxyTargetContributor.cs
      2009-10-27 18:55:22 UTC (rev 6275)
@@ -23,7 +23,7 @@
        using Generators.Emitters;
        using Generators.Emitters.SimpleAST;
 
-       public /* internal? */ class ClassProxyTargetContributor : 
TypeContributor
+       public /* internal? */ class ClassProxyTargetContributor : 
ITypeContributor
        {
                private readonly Type targetType;
                private readonly IList<MethodInfo> methodsToSkip;
@@ -50,7 +50,7 @@
                        interfaces.Add(@interface, 
targetType.GetInterfaceMap(@interface));
                }
 
-               public override void 
CollectElementsToProxy(IProxyGenerationHook hook)
+               public void CollectElementsToProxy(IProxyGenerationHook hook)
                {
                        Debug.Assert(hook != null, "hook != null");
 
@@ -67,7 +67,7 @@
 
                }
 
-               public override void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
+               public void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
                {
                        foreach (var target in targets)
                        {
@@ -146,7 +146,10 @@
                                generator = new EmptyMethodGenerator(method, 
createMethod);
                        }
                        var proxyMethod = generator.Generate(@class, options, 
namingScope);
-                       ReplicateNonInheritableAttributes(method.Method, 
proxyMethod);
+                       foreach (var attribute in 
AttributeUtil.GetNonInheritableAttributes(method.Method))
+                       {
+                               proxyMethod.DefineCustomAttribute(attribute);
+                       }
                }
 

File [modified]: ClassProxyTargetContributor.cs
Delta lines: +7 -5
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyTargetContributor.cs
  2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyTargetContributor.cs
  2009-10-27 18:55:22 UTC (rev 6275)
@@ -21,7 +21,7 @@
        using Castle.DynamicProxy.Generators;
        using Castle.DynamicProxy.Generators.Emitters;
 
-       public class InterfaceProxyTargetContributor:TypeContributor
+       public class InterfaceProxyTargetContributor: ITypeContributor
        {
                private readonly Type targetType;
                private readonly IDictionary<Type, InterfaceMapping> interfaces 
= new Dictionary<Type, InterfaceMapping>();
@@ -55,7 +55,7 @@
                        return targetType.GetInterfaceMap(@interface);
                }
 
-               public override void 
CollectElementsToProxy(IProxyGenerationHook hook)
+               public void CollectElementsToProxy(IProxyGenerationHook hook)
                {
                        Debug.Assert(hook != null, "hook != null");
 
@@ -67,7 +67,7 @@
                        }
                }
 
-               public override void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
+               public void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
                {
                        foreach (var target in targets)
                        {
@@ -147,8 +147,10 @@
                                generator = new 
ForwardingMethodGenerator(method, createMethod, (c, m) => 
c.GetField("__target"));
                        }
                        var proxyMethod = generator.Generate(@class, options, 
namingScope);
-                       ReplicateNonInheritableAttributes(method.Method, 
proxyMethod);
-
+                       foreach (var attribute in 
AttributeUtil.GetNonInheritableAttributes(method.Method))
+                       {
+                               proxyMethod.DefineCustomAttribute(attribute);
+                       }
                }
        }
 }

File [modified]: InterfaceProxyTargetContributor.cs
Delta lines: +7 -4
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyWithoutTargetContributor.cs
   2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyWithoutTargetContributor.cs
   2009-10-27 18:55:22 UTC (rev 6275)
@@ -8,7 +8,7 @@
        using Castle.DynamicProxy.Generators.Emitters;
        using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
 
-       public class InterfaceProxyWithoutTargetContributor : TypeContributor
+       public class InterfaceProxyWithoutTargetContributor : ITypeContributor
        {
                private readonly IList<MembersCollector> targets = new 
List<MembersCollector>();
                private readonly IList<Type> interfaces = new List<Type>();
@@ -19,7 +19,7 @@
                        this.namingScope = namingScope;
                }
 
-               public override void 
CollectElementsToProxy(IProxyGenerationHook hook)
+               public void CollectElementsToProxy(IProxyGenerationHook hook)
                {
                        Debug.Assert(hook != null, "hook != null");
                        foreach (var @interface in interfaces)
@@ -40,7 +40,7 @@
                        interfaces.Add(@interface);
                }
 
-               public override void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
+               public void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
                {
                        foreach (var target in targets)
                        {
@@ -120,7 +120,10 @@
                        }
 
                        var proxiedMethod = generator.Generate(@class, options, 
namingScope);
-                       ReplicateNonInheritableAttributes(method.Method, 
proxiedMethod);
+                       foreach (var attribute in 
AttributeUtil.GetNonInheritableAttributes(method.Method))
+                       {
+                               proxiedMethod.DefineCustomAttribute(attribute);
+                       }
                }
 

File [modified]: InterfaceProxyWithoutTargetContributor.cs
Delta lines: +2 -38
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MembersCollector.cs 
2009-10-27 15:44:20 UTC (rev 6274)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MembersCollector.cs 
2009-10-27 18:55:22 UTC (rev 6275)
@@ -17,6 +17,7 @@
        using System;
        using System.Collections.Generic;
        using System.Reflection;
+       using System.Reflection.Emit;
        using Generators;
 
        public class MembersCollector
@@ -114,7 +115,7 @@
                                return;
                        }
 
-                       var nonInheritableAttributes = 
GetNonInheritableAttributes(property);
+                       var nonInheritableAttributes = 
AttributeUtil.GetNonInheritableAttributes(property);
                        properties[property] = new 
PropertyToGenerate(property.Name,
                                                                      
property.PropertyType,
                                                                      getter,
@@ -271,43 +272,6 @@
                        return hook.ShouldInterceptMethod(type, method);
                }
 
-               private IEnumerable<CustomAttributeData> 
GetNonInheritableAttributes(MemberInfo propertyInfo)
-               {
-                       var attributes = 
CustomAttributeData.GetCustomAttributes(propertyInfo);
 
-                       foreach (var attribute in attributes)
-                       {
-                               if 
(ShouldSkipAttributeReplication(attribute.Constructor.DeclaringType)) continue;
-
-                               yield return attribute;
-                       }
-               }
-
-               /// <summary>
-               /// Attributes should be replicated if they are non-inheritable,
-               /// but there are some special cases where the attributes means
-               /// something to the CLR, where they should be skipped.
-               /// </summary>
-               private bool ShouldSkipAttributeReplication(Type attribute)
-               {
-                       if 
(SpecialCaseAttributThatShouldNotBeReplicated(attribute))
-                               return true;
-
-                       object[] attrs = attribute.GetCustomAttributes(typeof 
(AttributeUsageAttribute), true);
-
-                       if (attrs.Length != 0)
-                       {
-                               var usage = (AttributeUsageAttribute) attrs[0];
-
-                               return usage.Inherited;
-                       }
-
-                       return true;
-               }
-
-               private static bool 
SpecialCaseAttributThatShouldNotBeReplicated(Type attribute)
-               {
-                       return AttributesToAvoidReplicating.Contains(attribute);
-               }
        }
 }

File [modified]: MembersCollector.cs
Delta lines: +4 -2
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MixinContributor.cs 
2009-10-27 15:44:20 UTC (rev 6274)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MixinContributor.cs 
2009-10-27 18:55:22 UTC (rev 6275)
@@ -140,8 +140,10 @@
                                                                          (c, 
i) => target);
                        }
                        var proxyMethod = generator.Generate(emitter, options, 
namingScope);
-                       ReplicateNonInheritableAttributes(method.Method, 
proxyMethod);
-
+                       foreach (var attribute in 
AttributeUtil.GetNonInheritableAttributes(method.Method))
+                       {
+                               proxyMethod.DefineCustomAttribute(attribute);
+                       }
                }
        }
 }

File [modified]: MixinContributor.cs
Delta lines: +5 -1
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MixinContributorBase.cs 
    2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MixinContributorBase.cs 
    2009-10-27 18:55:22 UTC (rev 6275)
@@ -15,11 +15,12 @@
 namespace Castle.DynamicProxy.Contributors
 {
        using System;
+       using System.Reflection;
        using Generators.Emitters;
        using Generators.Emitters.SimpleAST;
 
        //TODO: this class should be factored out as soon as we get rid of the 
need for BackingField property
-       public abstract class MixinContributorBase : TypeContributor
+       public abstract class MixinContributorBase : ITypeContributor
        {
                protected FieldReference field;
 
@@ -39,5 +40,8 @@
                {
                        return emitter.CreateField("__mixin_" + 
type.FullName.Replace(".", "_"), type);
                }
+
+               public abstract void 
CollectElementsToProxy(IProxyGenerationHook hook);
+               public abstract void Generate(ClassEmitter @class, 
ProxyGenerationOptions options);
        }
 }

File [modified]: MixinContributorBase.cs
Delta lines: +7 -4
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ProxyInstanceContributor.cs
 2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ProxyInstanceContributor.cs
 2009-10-27 18:55:22 UTC (rev 6275)
@@ -26,7 +26,7 @@
        using Generators.Emitters.SimpleAST;
        using Tokens;
 
-       public abstract class ProxyInstanceContributor : TypeContributor
+       public abstract class ProxyInstanceContributor : ITypeContributor
        {
                // TODO: this whole type (and its descendants) should be #if 
!SILVERLIGHT... and empty type should be used instead for SL
 
@@ -42,14 +42,17 @@
                protected abstract Expression 
GetTargetReferenceExpression(ClassEmitter emitter);
 
 
-               public override void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
+               public virtual void Generate(ClassEmitter @class, 
ProxyGenerationOptions options)
                {
                        var interceptors = @class.GetField("__interceptors");
 #if !SILVERLIGHT
                        ImplementGetObjectData(@class);
 #endif
                        ImplementProxyTargetAccessor(@class, interceptors);
-                       ReplicateNonInheritableAttributes(targetType, @class);
+                       foreach (var attribute in 
AttributeUtil.GetNonInheritableAttributes(targetType))
+                       {
+                               @class.DefineCustomAttribute(attribute);
+                       }
                }
 
                protected void ImplementProxyTargetAccessor(ClassEmitter 
emitter, FieldReference interceptorsField)
@@ -162,7 +165,7 @@
 
                protected abstract void 
CustomizeGetObjectData(AbstractCodeBuilder builder, ArgumentReference 
serializationInfo, ArgumentReference streamingContext, ClassEmitter emitter);
 #endif
-               public override void 
CollectElementsToProxy(IProxyGenerationHook hook)
+               public void CollectElementsToProxy(IProxyGenerationHook hook)
                {
                }

File [modified]: ProxyInstanceContributor.cs
Delta lines: +0 -67
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/TypeContributor.cs  
2009-10-27 15:44:20 UTC (rev 6274)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/TypeContributor.cs  
2009-10-27 18:55:22 UTC (rev 6275)
@@ -1,67 +0,0 @@
-// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
-// 
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// 
-//     http://www.apache.org/licenses/LICENSE-2.0
-// 
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-namespace Castle.DynamicProxy.Contributors
-{
-       using System;
-       using System.Reflection;
-       using Castle.DynamicProxy.Generators;
-       using Castle.DynamicProxy.Generators.Emitters;
-
-       public abstract class TypeContributor:ITypeContributor
-       {
-               protected void ReplicateNonInheritableAttributes(MemberInfo 
member, IHasCustomAttributesEmitter emitter)
-               {
-                       var attributes = 
CustomAttributeData.GetCustomAttributes(member);
-
-                       foreach (var attribute in attributes)
-                       {
-                               if 
(ShouldSkipAttributeReplication(attribute.Constructor.DeclaringType)) continue;
-
-                               emitter.DefineCustomAttribute(attribute);
-                       }
-               }
-
-               private static bool 
SpecialCaseAttributThatShouldNotBeReplicated(Type attribute)
-               {
-                       return AttributesToAvoidReplicating.Contains(attribute);
-               }
-
-               /// <summary>
-               /// Attributes should be replicated if they are non-inheritable,
-               /// but there are some special cases where the attributes means
-               /// something to the CLR, where they should be skipped.
-               /// </summary>
-               private bool ShouldSkipAttributeReplication(Type attribute)
-               {
-                       if 
(SpecialCaseAttributThatShouldNotBeReplicated(attribute))
-                               return true;
-
-                       object[] attrs = attribute.GetCustomAttributes(typeof 
(AttributeUsageAttribute), true);
-
-                       if (attrs.Length != 0)
-                       {
-                               var usage = (AttributeUsageAttribute) attrs[0];
-
-                               return usage.Inherited;
-                       }
-
-                       return true;
-               }
-
-               public abstract void 
CollectElementsToProxy(IProxyGenerationHook hook);
-
-               public abstract void Generate(ClassEmitter @class, 
ProxyGenerationOptions options);
-       }
-}

File [removed]: TypeContributor.cs
Delta lines: +3 -4
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/AbstractTypeEmitter.cs
       2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/AbstractTypeEmitter.cs
       2009-10-27 18:55:22 UTC (rev 6275)
@@ -21,7 +21,7 @@
        using System.Reflection.Emit;
        using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
 
-       public abstract class AbstractTypeEmitter : IHasCustomAttributesEmitter
+       public abstract class AbstractTypeEmitter
        {
                private readonly TypeBuilder typebuilder;
                private readonly ConstructorCollection constructors;
@@ -215,10 +215,9 @@
                }
 
                
-               public void DefineCustomAttribute(CustomAttributeData attribute)
+               public void DefineCustomAttribute(CustomAttributeBuilder 
attribute)
                {
-                       var customAttributeBuilder = 
AttributeUtil.CreateBuilder(attribute);
-                       typebuilder.SetCustomAttribute(customAttributeBuilder);
+                       typebuilder.SetCustomAttribute(attribute);
                }
 

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/
===========================================================================

File [modified]: AbstractTypeEmitter.cs
Delta lines: +0 -23
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/IHasCustomAttributesEmitter.cs
       2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/IHasCustomAttributesEmitter.cs
       2009-10-27 18:55:22 UTC (rev 6275)
@@ -1,23 +0,0 @@
-// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
-// 
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// 
-//     http://www.apache.org/licenses/LICENSE-2.0
-// 
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-namespace Castle.DynamicProxy.Generators.Emitters
-{
-       using System.Reflection;
-
-       public interface IHasCustomAttributesEmitter
-       {
-               void DefineCustomAttribute(CustomAttributeData attribute);
-       }
-}

File [removed]: IHasCustomAttributesEmitter.cs
Delta lines: +3 -4
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/MethodEmitter.cs 
    2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/MethodEmitter.cs 
    2009-10-27 18:55:22 UTC (rev 6275)
@@ -23,7 +23,7 @@
        using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
 
        [DebuggerDisplay("{builder.Name}")]
-       public class MethodEmitter : IMemberEmitter,IHasCustomAttributesEmitter
+       public class MethodEmitter : IMemberEmitter
        {
                private readonly MethodBuilder builder;
 
@@ -173,10 +173,9 @@
                        }
                }
 
-               public void DefineCustomAttribute(CustomAttributeData attribute)
+               public void DefineCustomAttribute(CustomAttributeBuilder 
attribute)
                {
-                       var customAttributeBuilder = 
AttributeUtil.CreateBuilder(attribute);
-                       builder.SetCustomAttribute(customAttributeBuilder);
+                       builder.SetCustomAttribute(attribute);
                }
 

File [modified]: MethodEmitter.cs
Delta lines: +2 -3
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/PropertyEmitter.cs
   2009-10-27 15:44:20 UTC (rev 6274)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/Emitters/PropertyEmitter.cs
   2009-10-27 18:55:22 UTC (rev 6275)
@@ -194,10 +194,9 @@
                        }
                }
 
-               public void DefineCustomAttribute(CustomAttributeData attribute)
+               public void DefineCustomAttribute(CustomAttributeBuilder 
attribute)
                {
-                       var customAttributeBuilder = 
AttributeUtil.CreateBuilder(attribute);
-                       builder.SetCustomAttribute(customAttributeBuilder);
+                       builder.SetCustomAttribute(attribute);
                }
        }
 }

File [modified]: PropertyEmitter.cs
Delta lines: +5 -2
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/PropertyToGenerate.cs 
2009-10-27 15:44:20 UTC (rev 6274)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/PropertyToGenerate.cs 
2009-10-27 18:55:22 UTC (rev 6275)
@@ -18,6 +18,7 @@
        using System.Collections.Generic;
        using System.Diagnostics;
        using System.Reflection;
+       using System.Reflection.Emit;
        using Castle.DynamicProxy.Generators.Emitters;
 
        public class PropertyToGenerate
@@ -27,10 +28,10 @@
                private readonly MethodToGenerate getter;
                private readonly MethodToGenerate setter;
                private readonly PropertyAttributes attributes;
-               private readonly IEnumerable<CustomAttributeData> 
customAttributes;
+               private readonly IEnumerable<CustomAttributeBuilder> 
customAttributes;
                private PropertyEmitter emitter;
 
-               public PropertyToGenerate(string name, Type type, 
MethodToGenerate getter, MethodToGenerate setter, PropertyAttributes 
attributes, IEnumerable<CustomAttributeData> customAttributes)
+               public PropertyToGenerate(string name, Type type, 
MethodToGenerate getter, MethodToGenerate setter, PropertyAttributes 
attributes, IEnumerable<CustomAttributeBuilder> customAttributes)
                {
                        this.name = GetName(name,getter,setter);
                        this.type = type;
@@ -159,7 +160,9 @@
 
                        emitter = classEmitter.CreateProperty(name, attributes, 
type);
                        foreach (var attribute in customAttributes)
+                       {
                                emitter.DefineCustomAttribute(attribute);
+                       }
                }
        }
 }

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
==================================================================

File [modified]: PropertyToGenerate.cs
Delta lines: +43 -0
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/IAttributeDisassembler.cs        
                        (rev 0)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/IAttributeDisassembler.cs        
2009-10-27 18:55:22 UTC (rev 6275)
@@ -0,0 +1,43 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Castle.DynamicProxy
+{
+       using System;
+       using System.Reflection.Emit;
+
+       /// <summary>
+       /// Provides functionality for disassembling instances of attributes to 
CustomAttributeBuilder form, during the process of emiting new types by Dynamic 
Proxy.
+       /// </summary>
+       /// <remarks>
+       /// Usually Dynamic Proxy will handle disassembly process internally 
and will call out to implementers of this interface for help only in fallback 
scenarios and in Silverlight,
+       /// where mechanisms used usually by Dynamic Proxy are not available.
+       /// To register instance of class implementing this interface with 
Dynamic Proxy library call <see 
cref="AttributeUtil.AddDisassembler{TAttribute}"/> method passing as generic 
parameter attribute type that the disassembler handles.
+       /// When disassembling an attribute Dynamic Proxy will first check if 
an custom disassembler has been registered to handle attributes of that type, 
and if no, it'll use its internal default disassembler.
+       /// </remarks>
+       public interface IAttributeDisassembler
+       {
+               /// <summary>
+               /// Disassembles given attribute instance back to corresponding 
CustomAttributeBuilder.
+               /// </summary>
+               /// <param name="attribute">An instance of attribute to 
disassemble</param>
+               /// <returns><see cref="CustomAttributeBuilder"/> corresponding 
1 to 1 to given attribute instance</returns>
+               /// <remarks>
+               /// Implementers should return <see 
cref="CustomAttributeBuilder"/> that corresponds to given attribute instance 1 
to 1,
+               /// that is after calling specified constructor with specified 
arguments, and setting specified properties and fields with values specified
+               /// we should be able to get an attribute instance identical to 
the one passed in <paramref name="attribute"/>.
+               /// </remarks>
+               CustomAttributeBuilder Disassemble(Attribute attribute);
+       }
+}


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to