private void PopulateContributedFunctions(ITypeSpecBuilder spec, ITypeSpecImmutable[] functions, IMetamodel metamodel) { var result = functions.AsParallel().SelectMany(functionsSpec => { var serviceActions = functionsSpec.ObjectActions.Where(sa => sa != null).ToArray(); var matchingActionsForObject = new List <IActionSpecImmutable>(); foreach (var sa in serviceActions) { if (IsContributedFunction(sa, spec)) { matchingActionsForObject.Add(sa); } } return(matchingActionsForObject); }).ToList(); spec.AddContributedFunctions(result); }