Browse files

I love and hate linq

  • Loading branch information...
1 parent c041f06 commit 93305b41b2fbb8cb2bf2f24c1ac0d722dcb50841 Lucas Meijer committed Apr 15, 2012
Showing with 7 additions and 5 deletions.
  1. +6 −4 RecursiveIncludeScanner.cs
  2. +1 −1 Tests/RecursiveIncludeScannerTest.cs
View
10 RecursiveIncludeScanner.cs
@@ -18,22 +18,24 @@ public RecursiveIncludeScanner(IEnumerable<string> includePaths, WillFileBeGener
_scanFileForIncludes = scanFileForIncludes;
}
- public IEnumerable<string> GetFilesIncludedBy(string file)
+ public List<string> GetFilesIncludedBy(string file)
{
+ var results = new List<string>();
+
foreach (var includedFile in _scanFileForIncludes(file))
{
var foundIncludeFile = FindSpecifiedIncludeFileInSearchDirs(file,includedFile);
if (foundIncludeFile == null)
throw new MissingHeaderException(file, includedFile);
- yield return foundIncludeFile;
+ results.Add(foundIncludeFile);
//this can happen if we found the right includefile in the depgraph, but it hasn't been generated yet.
if (!File.Exists(foundIncludeFile))
continue;
- foreach (var file2 in GetFilesIncludedBy(foundIncludeFile))
- yield return file2;
+ results.AddRange(GetFilesIncludedBy(foundIncludeFile));
}
+ return results;
}
private string FindSpecifiedIncludeFileInSearchDirs(string includingFile, string includedFile)
View
2 Tests/RecursiveIncludeScannerTest.cs
@@ -32,7 +32,7 @@ public void FailToFindNonExistingHeader()
WillFileBeGeneratedAtPath willFileBeGeneratedAtPath = file => false;
var ris = new RecursiveIncludeScanner(new string[0], willFileBeGeneratedAtPath, ScanFileMock);
- Assert.Throws<MissingHeaderException>(()=>ris.GetFilesIncludedBy("test.c").ToArray());
+ Assert.Throws<MissingHeaderException>(()=>ris.GetFilesIncludedBy("test.c"));
}
private static IEnumerable<string> ScanFileMock(string file)

0 comments on commit 93305b4

Please sign in to comment.