dotnet / dotnet/vblang

[Proposal] Customized Auto Properties

Open
#574 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

I introduced many suggestions to shorten properties syntax, as they are the largest VB blocks. Auto properties are grate, but there are many cases where they can't be used. Here is one of them:
I had to write the full property body, just to call a sub in the Set section:
```VB.NET
Dim _account As Account
Public Property Account As Account
Get
Return _account
End Get
Set(value As Account)
_account = value
Refresh()
End Set
End Property
```

I suggest to allow to append some code to auto implemented properties, as this:
```VB.NET
Public Property Account As Account
On Set
Refresh()
End Set
```

which will be lowered to the first example. and in case of one statement set, it can be reduced to:
```VB.NET
Public Property Account As Account On Set: Refresh()
```

The same can be done with `On Get` if needed. There is no need to use both together, as in this it will be logical to use the normal full property body, and I had [a previous proposal](#567) to make it shorter for
a single-line Get or Set.

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.