Examples of errors detected by the V3083 diagnostic.


V3083. Unsafe invocation of event, NullReferenceException is possible. Consider assigning event to a local variable before invoking it.


Accord.Net

V3083 Unsafe invocation of event 'TempoDetected', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. Accord.Audio Metronome.cs 223


private void timeUp_Elapsed(object sender, ElapsedEventArgs e)
{
  ....
  if (TempoDetected != null)
    TempoDetected(this, EventArgs.Empty);
}

Old NASA World Wind (C#)

V3083 Unsafe invocation of event 'Elapsed', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. TimeKeeper.cs 78


private static void m_timer_Elapsed(....)
{
  ....
  if (Elapsed != null)
     Elapsed(sender, e);
}

Similar errors can be found in some other places:

  • V3083 Unsafe invocation of event 'Navigate', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. InternalWebBrowser.cs 65
  • V3083 Unsafe invocation of event 'Close', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. InternalWebBrowser.cs 73
  • V3083 Unsafe invocation of event 'OnMouseEnterEvent', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. WavingFlagLayer.cs 672
  • And 22 additional diagnostic messages.

Unity3D

V3083 Unsafe invocation of event 'unload', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. AssetBundleDemo AssetBundleManager.cs 47


internal void OnUnload()
{
  m_AssetBundle.Unload(false);
  if (unload != null)
    unload(); // <=
}

Logify Alert Clients

V3083 Unsafe invocation of event, NullReferenceException is possible. Consider assigning event to a local variable before invoking it. LogifyClient.cs 169


protected override bool
RaiseConfirmationDialogShowing(ReportConfirmationModel model) {
  if(ConfirmationDialogShowing != null) {                   // <=
    ConfirmationDialogModel actualModel =
      model as ConfirmationDialogModel;
    if(actualModel == null)
        return false;
    ConfirmationDialogEventArgs args =
      new ConfirmationDialogEventArgs(actualModel);
    ConfirmationDialogShowing(this, args);                  // <=
    return args.Handled;
  }
  return false;
}

Similar errors can be found in some other places:

  • V3083 Unsafe invocation of event 'NotifyProgress', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. Zip.cs 1035
  • V3083 Unsafe invocation of event, NullReferenceException is possible. Consider assigning event to a local variable before invoking it. LogifyClient.cs 156
  • V3083 Unsafe invocation of event 'FocusChanged', NullReferenceException is possible. Consider assigning event to a local variable before invoking it. BreadcrumbsRecorder.cs 391
  • And 4 additional diagnostic messages.


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;
We use cookies for the analysis of events to improve our content and make user interaction more convenient. By continuing the view of our web-pages you accept the terms of using these files. You can find out more about cookie-files and privacy policy or close the notification, by clicking on the button. Learn More →
Do not show