seesharper / LightInject.Interception

LightInject.Interception supports Aspect Oriented Programming through proxy-based method interceptors.
11 stars 7 forks source link

CreateCustomAttributeBuilder fail #2

Closed marcello-passeri closed 8 years ago

marcello-passeri commented 8 years ago

Hi, updating Lightinject, in LightInejct.Iterception v 1.0.0.10 (.Net v 4.6.1) an exception is thrown when I try to create a ServiceHost (Lightinject.Wcf ) Inside the method private static CustomAttributeBuilder CreateCustomAttributeBuilder(CustomAttributeData customAttributeData)

this statement fail var constructor = customAttributeData.AttributeType.GetTypeInfo().DeclaredConstructors.Where(c => c.GetParameters().Select(p => p.ParameterType).SequenceEqual(constructorArguments)).Single();

Unsing Lightinject.Wcf we have a this object {Name = "ServiceBehaviorAttribute" FullName = "System.ServiceModel.ServiceBehaviorAttribute"} that has 2 contruction with 0 parameters (one of them is static)

image

so the single statement fails

seesharper commented 8 years ago

Could you create a solution (console app or similiar) that reproduces the bug?

marcello-passeri commented 8 years ago

Hi, thanks for your reply. Here it is the sample Test.zip

By the way I fixed the code of the method by checking for non static and public constructors like this:

var constructor = customAttributeData.AttributeType.GetTypeInfo() .DeclaredConstructors .Where(c => c.GetParameters().Select(p => p.ParameterType).SequenceEqual(constructorArguments) && !c.IsStatic && c.IsPublic) .Single();

Would it be fine like that? I am asking because I need to make it works quickly but of course I do not understand each implication of this code... Thanks again

marcello-passeri commented 8 years ago

Any news?

seesharper commented 8 years ago

LightInject.Interception.1.0.0.11 just released to the official NuGet feed.

On Tue, Mar 8, 2016 at 6:18 PM, marcello-passeri notifications@github.com wrote:

Any news?

— Reply to this email directly or view it on GitHub https://github.com/seesharper/LightInject.Interception/issues/2#issuecomment-193875412 .

marcello-passeri commented 8 years ago

Thanks a lot!