dotnet / dotnet/vblang

Allow overridable and overriding events

Open
#63 2 comments 1 reaction 0 assignees View on GitHub
Approved-in-Principle Proposal
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Given the following base class definition (in C#, since VB doesn't allow declaring virtual/overridable events, AFAICT):

```
public class Calculator
{
public virtual event EventHandler TurnedOn;
}
```

The following is perfectly valid in C#:

```
public class CalculatorProxy : Calculator
{
public override event EventHandler TurnedOn
{
add => // do something
remove => // do something
}
}
```

Yet the same cannot be achieved with VB, neither with an `Overrides Event...` nor a `Overrides Custom Event` or the like.

Even if declaring the `Overridable` event isn't allowed, for parity at least the `Overrides` custom event could look something like:

```
Public Class CalculatorProxy
Inherits Calculator

Public Overrides Custom Event TurnedOn As EventHandler
AddHandler(value As EventHandler)
` do something
End AddHandler

RemoveHandler(value As EventHandler)
` do something
End RemoveHandler

RaiseEvent(sender As Object, args As EventArgs)
` do something
End RaiseEvent
End Event
End Class
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.