public async Task Write(Arguments arguments, CancellationToken cancellationToken) { var profiles = await profileReader.ReadFiles(arguments.Inputs, cancellationToken); var input = profiles.Concat(profileReader.ReadVariables(arguments.Variables)); var schemes = await profileReader.ReadFiles(arguments.Schemes, cancellationToken); var usedNames = input.OfType <Payload>() .Select(p => p.Name) .Distinct() .ToList(); await Task.WhenAll( from scheme in treeBuilder.BuildScheme(schemes, usedNames).AsParallel() from tree in treeBuilder.Build(input, scheme.GetSubstituteTypes()) from alteredScheme in treeBuilder.BuildScheme( scheme.WithImplicitHiddenKeys(tree), usedNames) from pair in formatterBuilder.Build(alteredScheme) from subTree in tree.GetSubTrees(pair.prefix) // RK TODO: Logging if no suitable subtrees. select pair.formatter.Write(subTree, cancellationToken)); }