public MethodInvocationExpression CreateGenericConstructorInvocation(IType classType, IEnumerable <TypeReference> genericArgs) { var gpp = classType as IGenericParametersProvider; IConstructor constructor; if (gpp == null || !genericArgs.Any()) { constructor = classType.GetConstructors().First(); return(CreateConstructorInvocation(constructor)); } classType = new GenericConstructedType( classType, genericArgs.Select(a => a.Entity).Cast <IType>().ToArray()); constructor = classType.GetConstructors().First(); var result = new MethodInvocationExpression { Target = CreateReference(constructor.DeclaringType) }; result.Target.Entity = constructor; result.ExpressionType = constructor.DeclaringType; return(result); }