[Proposal] Make Member Names Optional when Handles or Implements is Present
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
# Summary
If a member definition has a Handles or Implements clause, the name can be omitted from the definition.
# Motivation
For the Handles clause:
```
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles ApplyButton.Click
```
- Some programmers do not take the time to update the names of their event handlers when they update the names of the objects whose events are being handled, and, to my knowledge, the rename refactoring does not account for this.
- Even when the names of the event handlers are kept up to date, they are kind of redundant with the Handles clause in terms of informing the person reading the code what the method is used for.
- Really, though, how often do programmers directly call their event handlers? Most of the time, these methods are only accessed through the compiler-generated code that makes the Handles clause work.
- These event handlers, which may never be accessed by user code, still appear in Intellisense, adding clutter to that list. (And on too many occasions I have tried to access some text box's .Text property only for the dot to autocomplete to a _TextChanged event handler instead of the text box. Maybe VS2017's refinements to Intellisense have mitigated this, though.)
- Omitting the method name makes the method definition shorter.
```
Sub (sender As Object, e As EventArgs) Handles ApplyButton.Click
```
For the Implements clause, it's partly to be consistent with Handles, and it also provides something close to C#'s explicit interface implementation.
# Details/Questions
- Should the compiler-generated names be accessible and well-defined, like the backing fields for auto-properties, or "unpronounceable"?
- If the compiler-generated name is "unpronounceable", that would make the member inaccessible. Should the visibility modifier then be optional, required to be Private, or required to not be there?
- Would there be issues with analyzers, etc. if there are valid members without names?
- Are there any syntactic ambiguities? I think that both Handles and Implements are reserved words, so that should reduce the possible ambiguities.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.