Skip to content

Commit dfa2186

Browse files
committed
Fix
1 parent 394dc84 commit dfa2186

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ void FileChangedCallback(ChangedPath change)
224224
break;
225225
}
226226

227-
// If the changes include addition wait a little bit more for possible matching deletion.
228-
// This eliminates reevaluations caused by teared temp file add/delete change pair.
229-
if (!extendTimeout && changedFilesAccumulator.Any(change => change.Kind == ChangeKind.Add))
227+
// If the changes include addition/deletion wait a little bit more for possible matching deletion/addition.
228+
// This eliminates reevaluations caused by teared add + delete of a temp file or a move of a file.
229+
if (!extendTimeout && changedFilesAccumulator.Any(change => change.Kind is ChangeKind.Add or ChangeKind.Delete))
230230
{
231231
extendTimeout = true;
232232
continue;
@@ -689,6 +689,10 @@ internal static IEnumerable<ChangedPath> NormalizePathChanges(IEnumerable<Change
689689
lastAdd = null;
690690
lastUpdate ??= item with { Kind = ChangeKind.Update };
691691
}
692+
else
693+
{
694+
lastAdd = item;
695+
}
692696
}
693697
else if (item.Kind == ChangeKind.Delete)
694698
{
@@ -720,7 +724,16 @@ internal static IEnumerable<ChangedPath> NormalizePathChanges(IEnumerable<Change
720724
}
721725
}
722726

723-
return lastDelete ?? lastAdd ?? lastUpdate;
727+
var result = lastDelete ?? lastAdd ?? lastUpdate;
728+
729+
// On macOS may report Update followed by Add when a new file is created.
730+
// Convert any update
731+
//if (result?.Kind == ChangeKind.Update && !fileExists(group.Key))
732+
//{
733+
// return new ChangedPath(group.Key, ChangeKind.Add);
734+
//}
735+
736+
return result;
724737
})
725738
.Where(item => item != null)
726739
.Select(item => item!.Value);

src/BuiltInTools/dotnet-watch/Internal/FileWatcher.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public void WatchDirectories(IEnumerable<string> directories)
6464
}
6565

6666
var newWatcher = FileWatcherFactory.CreateWatcher(directory);
67+
if (newWatcher is EventBasedDirectoryWatcher eventBasedWatcher)
68+
{
69+
eventBasedWatcher.Logger = message => reporter.Verbose(message);
70+
}
71+
6772
newWatcher.OnFileChange += WatcherChangedHandler;
6873
newWatcher.OnError += WatcherErrorHandler;
6974
newWatcher.EnableRaisingEvents = true;

src/BuiltInTools/dotnet-watch/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"dotnet-watch": {
44
"commandName": "Project",
55
"commandLineArgs": "--verbose /bl:DotnetRun.binlog",
6-
"workingDirectory": "$(RepoRoot)src\\Assets\\TestProjects\\BlazorWasmWithLibrary\\blazorwasm",
6+
"workingDirectory": "C:\\sdk1\\artifacts\\tmp\\Debug\\RenameDirecto---333D0BB9\\AppWithDeps",
77
"environmentVariables": {
88
"DOTNET_WATCH_DEBUG_SDK_DIRECTORY": "$(RepoRoot)artifacts\\bin\\redist\\$(Configuration)\\dotnet\\sdk\\$(Version)",
99
"DCP_IDE_REQUEST_TIMEOUT_SECONDS": "100000",

0 commit comments

Comments
 (0)