1
Vote

when validating generic parameters compilation fails

description

I have following code:
public IQuery<T> SetSearchFilter([NotNull] Expression<Func<T, bool>> filteringExpression){}
 
When I build this code I recieve following error:
 
Error 1 Unhandled exception: ValidationAspects.ValidationException: Failed to construct validator for [type:MyNameSpace.BusinessLogic.Implementation.Query1[T]] [method:SetSearchFilter] [parameter:filteringExpression]. ---> ValidationAspects.ValidationException: Failed to construct validator for [type:System.Linq.Expressions.Expression1[System.Func2[T,System.Boolean]]]. ---> System.ArgumentException: Cannot create an instance of ValidationAspects.Sdk.ValidatorFactoryExtensions+ValidatorFactoryInvoker1[System.Linq.Expressions.Expression1[System.Func2[T,System.Boolean]]] because Type.ContainsGenericParameters is true.
at System.RuntimeType.CreateInstanceCheckThis()
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at ValidationAspects.Sdk.ValidatorFactoryExtensions.Create(IValidatorFactory factory, Type type)
at ValidationAspects.Core.ValidationRegistry1.ResolveValidator(T target)
--- End of inner exception stack trace ---
at ValidationAspects.Core.ValidationRegistry
1.ResolveValidator(T target)
at ValidationAspects.ParameterValidationRegistry.ResolveValidator(ParameterInfo parameterInfo)
--- End of inner exception stack trace ---
at ValidationAspects.ParameterValidationRegistry.ResolveValidator(ParameterInfo parameterInfo)
at ValidationAspects.PostSharp.ValidateAttribute.ProvideAspects(Object target, LaosReflectionAspectCollection collection)
at PostSharp.Laos.CompoundAspect.PostSharp.Laos.ILaosReflectionAspectProvider.ProvideAspects(LaosReflectionAspectCollection collection)
at PostSharp.Laos.Weaver.LaosAspectWeaver.ProvideAspects(LaosReflectionAspectCollection collection)
at PostSharp.Laos.Weaver.LaosTask.EnqueueAspects(ILaosReflectionAspectProvider provider)
at PostSharp.Laos.Weaver.LaosTask.Execute()
at PostSharp.Extensibility.Project.ExecutePhase(String phase)
at PostSharp.Extensibility.Project.Execute()
at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()
at PostSharp.Extensibility.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)
at PostSharp.MSBuild.PostSharpRemoteTask.Execute(PostSharpTaskParameters parameters, TaskLoggingHelper log) C:\Program Files\PostSharp 1.5\PostSharp-1.5.targets 261 5 MyNameSpace.BusinessLogic.Implementation

comments