I suggest you ...

Unused procedures vanish automatically on compile.

When I compile or debug the program I want all unused procedures to vanish automatically. (example: Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub should vanish when debug/compile if no code is inside it.)
This worked in VB6.

20 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Torbjörn Görtz shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

Thanks for taking the time to share this suggestion. This item has been around for a couple of versions of Visual Studio and we haven’t acted on it. Looking at the VS “15” plans, we’re not going to take action on this item, so we’re going to close it. If the suggestion is still relevant, please either take a look to see if there’s another suggestion that’s similar that you can vote on, or open a new suggestion.

- The Visual Studio Team


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • David Nuttall commented  ·   ·  Flag as inappropriate

    I like this feature of VB6 and I would support it in VB.Net, but I would want it as an option set in the Project properties, probably under Compile options, and set to off when the Project is created.

    Delete Unused Procedures: [check-box, default off]

    If a Sub or Function is empty (definition, chunk of white-space, End Sub) it qualifies for removal. Putting a comment in it (or anything else) will keep it from getting removed during compile.

  • Lucian Wischik commented  ·   ·  Flag as inappropriate

    If you use ProjectN, then this "dead-code-removal" happens automatically.

    But in general it's a scary thought because it would break reflection. In general the compiler has no way of knowing whether a member will be invoked by reflection or not. (ProjectN works by making a guess at where you will want to use reflection, but letting you tweak it further).

  • Mr. VB6 commented  ·   ·  Flag as inappropriate

    In VB6, default unused procedures do that, and that is smart! if you rename the default procedure, then it does not disappear :)

  • Torbjörn Görtz commented  ·   ·  Flag as inappropriate

    To Draco - Wy on earth do you want to keep empty procedures - which was created automatically by the IDE? If you dont use them by putting code inte them - why keep them?

  • Torbjörn Görtz commented  ·   ·  Flag as inappropriate

    Only empty sub procedures which are automatically created by the IDE should vanish (just like in VB6). If you doubleclick on control but don't put any code into the new procedure it should vanish automatically on compile.

  • Nick Roberts commented  ·   ·  Flag as inappropriate

    Maybe it should be a specific refactoring option, which can be applied to a whole project as well as to a specific class (or file)?

    It could be counteracted in a specific procedure by putting a comment in it? (E.g. a TODO.)

  • Torbjörn Görtz commented  ·   ·  Flag as inappropriate

    My intention is thas only empty sub procedures which are automatically created by the IDE, when you double click on a control, are going to be removed. On VB6 this type of sub procedures vanish when you run a full debug - and manually created sub procedures are left unchanged. This is exactly the way I want it.

  • Paul commented  ·   ·  Flag as inappropriate

    As long as it's optional! Are we talking about deleting such out of source, or simply not including it in compile/debug? I can't be the only one who often has empty procedure stubs here and there, waiting to get either fleshed out or [manually] deleted.

Feedback and Knowledge Base