Skip to content

Commit 0839742

Browse files
authored
Merge pull request github#16968 from tamasvajk/feature/buildless-deterministic-file-order-2
C#: Order syntax trees before creating compilation
2 parents f6627cc + 5a41b2c commit 0839742

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileProvider.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private string[] SelectTextFileNamesByExtension(string filetype, params string[]
6262
private string[] SelectTextFileNamesByName(string name)
6363
{
6464
var ret = allNonBinary.Value.SelectFileNamesByName(name).ToArray();
65-
var ending = ret.Length == 0 ? "." : $": {string.Join(", ", ret)}.";
65+
var ending = ret.Length == 0 ? "." : $": {string.Join(", ", ret.OrderBy(s => s))}.";
6666
logger.LogInfo($"Found {ret.Length} {name} files in {SourceDir}{ending}");
6767
return ret;
6868
}
@@ -91,9 +91,7 @@ private IEnumerable<FileInfo> SelectSmallFiles(IEnumerable<FileInfo> files)
9191
private FileInfo[] GetAllFiles()
9292
{
9393
logger.LogInfo($"Finding files in {SourceDir}...");
94-
var files = SourceDir
95-
.GetFiles("*.*", new EnumerationOptions { RecurseSubdirectories = true })
96-
.OrderBy(f => f.FullName);
94+
var files = SourceDir.GetFiles("*.*", new EnumerationOptions { RecurseSubdirectories = true });
9795

9896
var filteredFiles = files.Where(f =>
9997
{

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Extractor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ public static ExitCode Analyse(Stopwatch stopwatch, Analyser analyser, CommonOpt
435435
}
436436
}
437437

438+
syntaxTrees.Sort((a, b) => string.Compare(a.FilePath, b.FilePath, StringComparison.Ordinal));
439+
438440
var compilation = getCompilation(syntaxTrees, references);
439441

440442
initializeAnalyser(compilation, options);

0 commit comments

Comments
 (0)