VS 2010 SP1 changing “ByVal” VB.NET code editor experience

Apart from these ones, other thing that I dislike a lot of SP1 of Visual Studio is that it has changed the editing experience of “ByVal” in the VB.NET code editor.

While in “classic” VB6 “ByRef” was the default and “ByVal” was required to pass parameters by value, in VB.NET it’s the opposite: “ByVal” is the default and “ByRef” is required to pass parameters by reference. However, until VS 2010 SP1, the VB.NET code editor always added “ByVal” when typing or when generating code (like in the parameters of event handlers).

My first alarm sign was reading:

Visual Basic Editor

in the Description of Visual Studio 2010 Service Pack 1. And indeed, after installing SP1, “ByVal” was not inserted when typing parameters in VB.NET. I tried to find some setting in the Options window to get back the old behavior, to no avail. I e-mailed the program managers who changed this behavior, which in turn introduced me the developer, and they confirmed that there is no setting (and no plans) to get the old behavior in the VB.NET code editor. So, after applying SP1:

1) If you like the old style, you have to type “ByVal” on your own.

2) Likely you will end with inconsistent styles in your VB.NET code, sometimes using “ByVal” (old code) and sometimes missing it (new code).

These irreversible changes of behavior is not what I expect from a service pack (I expect it to fix bugs, not to introduce issues). This should deserve a setting (opt-in) for those people who want to get rid of “ByVal”, and let the people who want the old behavior as they are.

4 thoughts on “VS 2010 SP1 changing “ByVal” VB.NET code editor experience”

  1. Having worked with a variety of programming languages over the years it always bugged me that VB6 defaulted to ByRef and I was equally annoyed at having to explicitly use ByVal to avoid the default. So I’m quite happy about this change, though I agree it would have been nice to include an option to reinstate the old behavious for those who prefer it.

  2. Thanks for this post. I love removing the ByVal as it’s the default and therefore redundant and this post reminded me to re-install SP1 which I forgot.

    However I agree it should be an option (the way strict vs non-strict is an option)

    Thx,
    Matt

  3. Thanks for that info Carlos. I totally agree with you. Many people like supplying the default values because it assists in assuring that if a vendor decides to alter how the default works, than you know what you have. Giving us the option is best.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.