Peculiar inconsistency in autogenerated event handler code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Larry Lard

    Peculiar inconsistency in autogenerated event handler code


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

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) 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(ByVa l sender As Object, ByVal e As
    System.EventArg s) Handles MyBase.Load

    End Sub

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

    --
    Larry Lard
    Replies to group please

  • Herfried K. Wagner [MVP]

    #2
    Re: Peculiar inconsistency in autogenerated event handler code

    "Larry Lard" <larrylard@hotm ail.com> schrieb:[color=blue]
    > Experiment A:
    > Start a new Windows Forms project. Double click Form1. This is what is
    > generated:
    >
    > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    > System.EventArg s) 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(ByVa l sender As Object, ByVal e As
    > System.EventArg s) Handles MyBase.Load
    >
    > End Sub
    >
    > Note that in A, sender is 'System.Object' , whereas in B it is 'Object'.
    > Weird, huh?[/color]

    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.micros oft.com/productfeedback/>) and
    post the URL to the report for voting here.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • CMM

      #3
      Re: Peculiar inconsistency in autogenerated event handler code

      Looks like Microsoft didn't use good "encapsulat ion" 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.



      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Peculiar inconsistency in autogenerated event handler code

        CMM,
        [color=blue]
        > Looks like Microsoft didn't use good "encapsulat ion" 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.
        >[/color]
        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


        Comment

        • CMM

          #5
          Re: Peculiar inconsistency in autogenerated event handler code

          > 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.)
          [color=blue]
          > It is not Microsoft who does things like this, it are just developers like
          > you.[/color]

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

          Anywayz...


          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Peculiar inconsistency in autogenerated event handler code

            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


            Comment

            Working...