Skip to content

Commit 6eaa8c8

Browse files
committed
Fix filelist compare bug
1 parent a5750e3 commit 6eaa8c8

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

core/IncrementalCompiler/Compiler.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ private CompileResult BuildFull(CompileOptions options)
3939
{
4040
var result = new CompileResult();
4141

42+
_logger.Info("BuildFull");
4243
_options = options;
4344

4445
_referenceFileList = new FileTimeList();
@@ -71,28 +72,30 @@ private CompileResult BuildIncremental(CompileOptions options)
7172
{
7273
var result = new CompileResult();
7374

75+
_logger.Info("BuildIncremental");
7476
_options = options;
7577

76-
// TODO: guard failure of compilation, ...
77-
7878
// update reference files
7979

8080
var referenceChanges = _referenceFileList.Update(options.References);
8181
foreach (var file in referenceChanges.Added)
8282
{
83+
_logger.Info("+ {0}", file);
8384
var reference = CreateReference(file);
8485
_compilation = _compilation.AddReferences(reference);
8586
_referenceMap.Add(file, reference);
8687
}
8788
foreach (var file in referenceChanges.Changed)
8889
{
90+
_logger.Info("* {0}", file);
8991
var reference = CreateReference(file);
9092
_compilation = _compilation.RemoveReferences(_referenceMap[file])
9193
.AddReferences(reference);
9294
_referenceMap[file] = reference;
9395
}
9496
foreach (var file in referenceChanges.Removed)
9597
{
98+
_logger.Info("- {0}", file);
9699
_compilation = _compilation.RemoveReferences(_referenceMap[file]);
97100
_referenceMap.Remove(file);
98101
}
@@ -103,19 +106,22 @@ private CompileResult BuildIncremental(CompileOptions options)
103106
var parseOption = new CSharpParseOptions(LanguageVersion.CSharp6, DocumentationMode.Parse, SourceCodeKind.Regular, options.Defines);
104107
foreach (var file in sourceChanges.Added)
105108
{
109+
_logger.Info("+ {0}", file);
106110
var syntaxTree = ParseSource(file, parseOption);
107111
_compilation = _compilation.AddSyntaxTrees(syntaxTree);
108112
_sourceMap.Add(file, syntaxTree);
109113
}
110114
foreach (var file in sourceChanges.Changed)
111115
{
116+
_logger.Info("* {0}", file);
112117
var syntaxTree = ParseSource(file, parseOption);
113118
_compilation = _compilation.RemoveSyntaxTrees(_sourceMap[file])
114119
.AddSyntaxTrees(syntaxTree);
115120
_sourceMap[file] = syntaxTree;
116121
}
117122
foreach (var file in sourceChanges.Removed)
118123
{
124+
_logger.Info("- {0}", file);
119125
_compilation = _compilation.RemoveSyntaxTrees(_sourceMap[file]);
120126
_sourceMap.Remove(file);
121127
}

core/IncrementalCompiler/CompilerService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public CompileResult Build(string projectPath, CompileOptions options)
2525

2626
if (string.IsNullOrEmpty(_projectPath) || _projectPath != projectPath)
2727
{
28-
// Flush existing
29-
28+
// create new one
3029
_compilerMap = new Dictionary<string, Compiler>();
31-
_logger.Info("Flush old project. (Project={0})", _projectPath);
30+
if (string.IsNullOrEmpty(_projectPath) == false)
31+
_logger.Info("Flush old project. (Project={0})", _projectPath);
3232
}
3333

3434
_projectPath = projectPath;

core/IncrementalCompiler/FileTimeList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Result Update(IEnumerable<Tuple<string, DateTime>> files)
4646
var j = 0;
4747
while (i < _files.Count && j < oldFiles.Count)
4848
{
49-
var c = Comparer<string>.Default.Compare(_files[i].Item1, oldFiles[i].Item1);
49+
var c = Comparer<string>.Default.Compare(_files[i].Item1, oldFiles[j].Item1);
5050
if (c == 0)
5151
{
5252
if (_files[i].Item2 != oldFiles[j].Item2)

0 commit comments

Comments
 (0)