public async Task <IFolder> ResolveAsync(string folderToResolve, IErrorsAndInfos errorsAndInfos) { if (folderToResolve == null) { return(null); } await FindReplacementsIfNecessaryAsync(); foreach (var(key, value) in Replacements.Where(replacement => folderToResolve.Contains(replacement.Key))) { folderToResolve = folderToResolve.Replace(key, value); } if (!folderToResolve.Contains("$(")) { return(new Folder(folderToResolve)); } var startIndex = -1; int endIndex; var machineDriveSecretFileName = SecretRepository.FileName(new MachineDrivesSecret(), false, false); var logicalFolderSecretFileName = SecretRepository.FileName(new LogicalFoldersSecret(), false, false); var missingPlaceHolders = new List <string>(); do { startIndex = folderToResolve.IndexOf("$(", startIndex + 1, StringComparison.Ordinal); if (startIndex >= 0) { endIndex = folderToResolve.IndexOf(")", startIndex, StringComparison.Ordinal); missingPlaceHolders.Add("'" + folderToResolve.Substring(startIndex, endIndex - startIndex + 1) + "'"); } else { endIndex = -1; } } while (startIndex >= 0 && endIndex > startIndex); errorsAndInfos.Errors.Add(missingPlaceHolders.Count == 1 ? string.Format(Properties.Resources.FolderPlaceholderNotFound, missingPlaceHolders[0], machineDriveSecretFileName, logicalFolderSecretFileName) : string.Format(Properties.Resources.FolderPlaceholdersNotFound, string.Join(", ", missingPlaceHolders), machineDriveSecretFileName, logicalFolderSecretFileName)); return(new Folder(folderToResolve)); }