Peculiar inconsistency in autogenerated event handler code

L

Larry Lard

Experiment A:
Start a new Windows Forms project. Double click Form1. This is what is
generated:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Experiment B:
Start a new Windows Forms project. Go to the code window for Form1.
Choose 'Form 1 events' from the left combo, then choose 'Load' from the
right combo. This is what is generated:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Note that in A, sender is 'System.Object', whereas in B it is 'Object'.
Weird, huh?
 
H

Herfried K. Wagner [MVP]

Larry Lard said:
Experiment A:
Start a new Windows Forms project. Double click Form1. This is what is
generated:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Experiment B:
Start a new Windows Forms project. Go to the code window for Form1.
Choose 'Form 1 events' from the left combo, then choose 'Load' from the
right combo. This is what is generated:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Note that in A, sender is 'System.Object', whereas in B it is 'Object'.
Weird, huh?

Yep. Unfortunately automatically generated code is rather inconsistent in
its look. You may want to file a suggestion or bug report in MSDN Product
Feedback Center (<URL:http://lab.msdn.microsoft.com/productfeedback/>) and
post the URL to the report for voting here.
 
C

CMM

Looks like Microsoft didn't use good "encapsulation" practices even in their
own code. Sounds like two different (internal) functions are generating the
stub... when there's no reason it should be one.
 
C

Cor Ligthert [MVP]

CMM,
Looks like Microsoft didn't use good "encapsulation" practices even in
their own code. Sounds like two different (internal) functions are
generating the stub... when there's no reason it should be one.
Withouth knowing what it is about.

It is not Microsoft who does things like this, it are just developers like
you.

Keep that in mind when you write things like this.

They don't do that express, in the same way as you don't do that.

Cor
 
C

CMM

They don't do that express, in the same way as you don't do that.

You mean they didn't do it on purpose? Well, likely not. I was just trying
to "conceive" why this very minor but curious bug occurs. That's all.

But, hey if it works it works right? Isn't that your motto? (screw
standards, consistency, needless superflous encapsulation, and all that
burdonsome stuff... 300 "" emptystrings in your code vs 1 String.Empty???
Eh, what does it matter? You like the way "" looks, right?). Years from now
if a bug occurs someone else will figure out the code in the same exact way
they can figure out your English sentences, right? (i.e. that sentence up
there you wrote in NO WAY AT ALL makes any sense in English.)
It is not Microsoft who does things like this, it are just developers like
you.

Are you trying to offend me? Just because you need to use use hungarian
notation and I don't (anymore)? :)

Anywayz...
 
C

Cor Ligthert [MVP]

CMM,

Not all of that, I try to protect those Microsoft developers.

It can be that they made a mistake, that is not hilarious, what I did read a
little bit in your message.

I would only write it in that way, as it is sure that it is an official
behaviour of Microsoft.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top