Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix IDE1005 (simplify delegate invocation)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Aug 13, 2019
1 parent 117217f commit cbf8ac8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2782,9 +2782,7 @@ internal void DoCommand(EventCommandEventArgs commandArgs)
}

this.OnEventCommand(commandArgs);
var eventCommandCallback = this.m_eventCommandExecuted;
if (eventCommandCallback != null)
eventCommandCallback(this, commandArgs);
this.m_eventCommandExecuted?.Invoke(this, commandArgs);

if (!commandArgs.enable)
{
Expand Down Expand Up @@ -2835,9 +2833,7 @@ internal void DoCommand(EventCommandEventArgs commandArgs)
// Debug.Assert(matchAnyKeyword == EventKeywords.None);

this.OnEventCommand(commandArgs);
var eventCommandCallback = m_eventCommandExecuted;
if (eventCommandCallback != null)
eventCommandCallback(this, commandArgs);
m_eventCommandExecuted?.Invoke(this, commandArgs);
}
}
catch (Exception e)
Expand Down Expand Up @@ -4255,11 +4251,7 @@ protected internal virtual void OnEventSourceCreated(EventSource eventSource)
/// <param name="eventData"></param>
protected internal virtual void OnEventWritten(EventWrittenEventArgs eventData)
{
EventHandler<EventWrittenEventArgs>? callBack = this.EventWritten;
if (callBack != null)
{
callBack(this, eventData);
}
this.EventWritten?.Invoke(this, eventData);
}


Expand Down
10 changes: 2 additions & 8 deletions src/System.Private.CoreLib/shared/System/IO/Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,7 @@ internal IAsyncResult BlockingBeginRead(byte[] buffer, int offset, int count, As
asyncResult = new SynchronousAsyncResult(ex, state, isWrite: false);
}

if (callback != null)
{
callback(asyncResult);
}
callback?.Invoke(asyncResult);

return asyncResult;
}
Expand Down Expand Up @@ -861,10 +858,7 @@ internal IAsyncResult BlockingBeginWrite(byte[] buffer, int offset, int count, A
asyncResult = new SynchronousAsyncResult(ex, state, isWrite: true);
}

if (callback != null)
{
callback(asyncResult);
}
callback?.Invoke(asyncResult);

return asyncResult;
}
Expand Down
4 changes: 2 additions & 2 deletions src/System.Private.CoreLib/shared/System/Progress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ private void InvokeHandlers(object? state)
Action<T>? handler = _handler;
EventHandler<T>? changedEvent = ProgressChanged;

if (handler != null) handler(value);
if (changedEvent != null) changedEvent(this, value);
handler?.Invoke(value);
changedEvent?.Invoke(this, value);
}
}

Expand Down

0 comments on commit cbf8ac8

Please sign in to comment.