Method can be made private message showing in a potential wrong case

Take for example the following code:

        public event EventHandler ExportDocument;

        protected void OnExportDocument()
        {
            if(ExportDocument != null) ExportDocument(this, new
EventArgs());
        }


According to the conventions outlined in Microsoft design guidelines, all
events should also have an associated protected On***() method for each
event. This allows derived classes to gain access to the event pipeline.

R# reports that the above method can be made private. While this is
technically correct, its actually invalid from .NET convention perspective.
That method should only be made private if the class is sealed.

1 comment
Comment actions Permalink

Somewhat related, I noticed today that ReSharper 1577 is suggesting removing
the EventArgs parameter from some event handlers that don't use the
parameter. This may just be poor coding practice though because these event
handlers are empty with comments along the lines of TODO: Fill in the
textbox click event.

"App Developer" <appdev@hotmail.com> wrote in message
news:hj4ic1$ni6$1@nntp-server.labs.intellij.net...

Take for example the following code:

>

       public event EventHandler ExportDocument;

>

       protected void OnExportDocument()
       {
           if(ExportDocument != null) ExportDocument(this, new
EventArgs());
       }

>
>

According to the conventions outlined in Microsoft design guidelines, all
events should also have an associated protected On***() method for each
event. This allows derived classes to gain access to the event pipeline.

>

R

  1. reports that the above method can be made private. While this is

technically correct, its actually invalid from .NET convention
perspective. That method should only be made private if the class is
sealed.

0

Please sign in to leave a comment.