Private method 'Page_Load' is never used

Is there a way to turn off the complaining about the Page_Load method not being used? It does this on every page. ReSharper should know that this method is provided by the .NET framework and will be called by the underlying Page.

8 comments
Comment actions Permalink

The method is not called by the underlying Page. What is called is the
Load event which, by default, has an event handler of Page_Load assigned to
it. My guess is your event handler has become detached so nothing is
referencing Page_Load. Regardless, you should not use Page_Load but instead
OnLoad, which is more in line with traditional OOP practices and is faster
than events.


0
Comment actions Permalink

With the AutoEventWireup attribute set to true, the event does get called
without anything referencing it, that is, only the code generated from the
aspx page will reference it, but you won't find that code in your project.
With this attribute you don't have a choice regarding the name of the event
handlers.

Anyway, I made a request on this subject and the status of my request has,
this morning, been changed to duplicate. So I guess it will be solved soon.

Erwin

"Nathan Alden" <visualcsharpcoder@hotmail.com> schreef in bericht
news:dt54i7$5jr$1@is.intellij.net...

The method is not called by the underlying Page. What is called is the
Load event which, by default, has an event handler of Page_Load assigned
to it. My guess is your event handler has become detached so nothing is
referencing Page_Load. Regardless, you should not use Page_Load but
instead OnLoad, which is more in line with traditional OOP practices and
is faster than events.



0
Comment actions Permalink


"Erwin Derksen" <dachthetniet@onbekend.nl> wrote in message
news:dt56ij$gd9$1@is.intellij.net...

With the AutoEventWireup attribute set to true, the event does get called
without anything referencing it, that is, only the code generated from the
aspx page will reference it, but you won't find that code in your project.
With this attribute you don't have a choice regarding the name of the
event handlers.


You may not see it, but it is in a partial class and is referenced,
regardless, you should delete it, and just override the OnLoad handler
instead, same for init, in fact, for the whole page lifecycle, use
overrides.


0
Comment actions Permalink


"Ramon Leon" <rleon@insario.com> schreef in bericht
news:dt59ap$r07$1@is.intellij.net...
>

"Erwin Derksen" <dachthetniet@onbekend.nl> wrote in message
news:dt56ij$gd9$1@is.intellij.net...

>> With the AutoEventWireup attribute set to true, the event does get called
>> without anything referencing it, that is, only the code generated from
>> the aspx page will reference it, but you won't find that code in your
>> project. With this attribute you don't have a choice regarding the name
>> of the event handlers.
>

You may not see it, but it is in a partial class and is referenced,
regardless, you should delete it, and just override the OnLoad handler
instead, same for init, in fact, for the whole page lifecycle, use
overrides.

Why carry the burden of not forgetting to call the base
int/load/render/etc.?

I prefer to use event handlers, unless I explicitly need order in the
execution of them, but with the extended page life cylce model in asp.net
2.0 this won't happen that often anumore.

Erwin


0
Comment actions Permalink

The problem is that this event handler is automatically bound by the web
engine, not from code and we still do not support it (we use "standard"
analysis for identifying not used methods). The current workaround to remove
the warning is to make the method protected. Unfortunately, I don't think we
would fix the issue soon.

BTW This group is not intended for discussing EAP problems, You'd better use
jetbrains.resharper.eap newsgroup.

--
Sergey V. Coox
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

Erwin,

Anyway, I made a request on this subject and the status of my request has,
this morning, been changed to duplicate. So I guess it will be solved
soon.

Unfortunately it does not. It just means that the same request is in the
tracker already.

--
Sergey V. Coox
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

I have a similar situation where a private method is invoked by reflection. Is it possible to add a comment to the code so that the warning is switched off for the specific method?

0
Comment actions Permalink

I would vote for that too. I don't even mind if I had to do it on every page/place where it happens, just so I could put in a #pragma or comment or something else that told R# "Yeah, I know there aren't any public invokations of this particular method."

It's a very useful warning, and I dont want to turn it off globally, so I live with it, but I'm sure like many other R# users, I'm on an eternal quest for the "green square."

Ian

0

Please sign in to leave a comment.