// of the world, but there's little that can be done about that.)
if (directoryEntry.Parent != parent)
{
- directoryEntry.Parent?.Children!.Remove (directoryEntry);
+ // Work around https://github.com/dotnet/csharplang/issues/3393 preventing Parent?.Children!. from behaving as expected
+ if (directoryEntry.Parent != null)
+ {
+ directoryEntry.Parent.Children!.Remove(directoryEntry);
+ }
+
directoryEntry.Parent = parent;
if (parent != null)
{
Debug.Assert (_includeSubdirectories);
lock (SyncObj)
{
- directoryEntry.Parent?.Children!.Remove(directoryEntry);
+ // Work around https://github.com/dotnet/csharplang/issues/3393 preventing Parent?.Children!. from behaving as expected
+ if (directoryEntry.Parent != null)
+ {
+ directoryEntry.Parent.Children!.Remove(directoryEntry);
+ }
+
RemoveWatchedDirectoryUnlocked (directoryEntry, removeInotify);
}
}