Add missing FileSystemWatcher methods#13656
Add missing FileSystemWatcher methods#13656ianhays merged 1 commit intodotnet:masterfrom ianhays:api_fsw
Conversation
| protected void OnRenamed(RenamedEventArgs e) | ||
| { | ||
| _onRenamedHandler?.Invoke(this, e); | ||
| RenamedEventHandler handler = _onRenamedHandler; |
There was a problem hiding this comment.
InvokeOn(e, _onRenamedHandler);
| @@ -473,7 +496,14 @@ protected void OnDeleted(FileSystemEventArgs e) | |||
| [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", MessageId = "0#", Justification = "Changing from protected to private would be a breaking change")] | |||
| protected void OnError(ErrorEventArgs e) | |||
There was a problem hiding this comment.
InvokeOn(e, _onErrorHandler);
There was a problem hiding this comment.
I didn't use the InvokeOn helper for Renamed and Error because of the different handler/args types that do not share a common parent.
| public void EndInit() | ||
| { | ||
| _initializing = false; | ||
| //Start listening to events if _enabled was set to true at some point. |
| } | ||
| } | ||
|
|
||
| /// <summary> |
There was a problem hiding this comment.
The name/comment of this test and the one below are switched
| _enabled = false; | ||
|
|
||
| if (IsSuspended()) | ||
| return; |
There was a problem hiding this comment.
When will the subsequent logic be invoked in this case?
There was a problem hiding this comment.
It won't be. When under initialization, the only action StopRaisingEvents does is to set _enabled to false since actual event watching is paused/stopped/hasn't begun.
This state is reached by first called BeginInit() which will call StopRaisingEvents before setting _enabled, so before we get into an IsSuspended state we will have done the subsequent cleanup necessary.
So the assertion is that when IsSuspended is true, we already did the other stuff in StopRaisingEvents and don't need to do it again.
This is ripped from the desktop code.
| { | ||
| if (handler != null) | ||
| { | ||
| if (SynchronizingObject != null && SynchronizingObject.InvokeRequired) |
There was a problem hiding this comment.
This is happening in a queued work item, right? What happens if SynchronizingObject is changed from null to non-null between these checks or after these checks and before the BeginInvoke call?
There was a problem hiding this comment.
The same could be said for the handler changing from non-null to null between the check and the invocation, yeah?
There was a problem hiding this comment.
Ah yeah, we're not using the _onXHandlers directly.
The SynchronizingObject thing is potentially an issue and one that is present in desktop as well. We can't exactly catch the nullreference here because it's possible that the SynchronizingObject.BeginInvoke implementation may throw that in which case we don't want to mess with it. It also doesn't seem like we would want to copy the object or lock around it either, but I'm not too familiar with this synchronization scheme.
There was a problem hiding this comment.
You can just put it in a local, e.g.
ISynchronizeInvoke syncObj = SynchronizingObject;
if (syncObj != null && syncObj.InvokeRequired) { ... }| "System.Runtime": "4.4.0-beta-24714-01", | ||
| "System.ComponentModel.Primitives": "4.4.0-beta-24714-01" | ||
| "System.ComponentModel.Primitives": "4.4.0-beta-24714-01", | ||
| "System.ComponentModel.TypeConverter": "4.4.0-beta-24714-01" |
There was a problem hiding this comment.
4.4.0-beta-24714-01 [](start = 44, length = 19)
Just as FYI, whenever adding dependencies like in here, make sure that you rebase and update the dependency version before merging, since it is likely that they will change from the moment you sent out your review to the moment you merge.
|
|
||
| // Used for synchronization | ||
| private bool _disposed; | ||
| private ISynchronizeInvoke synchronizingObject; |
Adds source and tests for the remaining missing members in FileSystemWatcher. This required that FileSystemWatcher take a dependency on System.ComponentModel.TypeConverter.
|
Not sure what needs to be done here. @mmitche is this a setup issue? |
|
@dotnet-bot test Innerloop Windows_NT Debug Build and Test please (bug in the build has been fixed) |
Adds source and tests for the remaining missing members in FileSystemWatcher. This required that FileSystemWatcher take a dependency on System.ComponentModel.TypeConverter.
resolves https://github.com/dotnet/corefx/issues/13491
@AlexGhiondea @danmosemsft @joperezr @alexperovich @JeremyKuhne