[Proposal] Lets shrink full-body properties
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
Looking at this property, which I had to write a full body just to deal with a property of some internal object in my control:
```VB.NET
Public Property IsReadOnly As Boolean
Get
Return Me.TexTBox.IsReadOnly
End Get
Set(value As Boolean)
Me.TexTBox.IsReadOnly = value
End Set
End Property
```
I suggest to simplify it to:
```VB.NET
Public Property IsReadOnly As Boolean
Get Me.TexTBox.IsReadOnly
Set Me.TexTBox.IsReadOnly = value
End Property
```
The Get keword have the same meaning of Return, so, when we just deal with a one line body, we can shorten it to `Get [the return val]`
The `Set [assignment statement]` also makes a readable English statement, and is similar to Let statement in LinQ and old VB syntax.
Furthermore, in cases where the property is jst a wrapper of another one, I suggest a more compact form. You can choose between these:
```VB.NET
Public Property IsReadOnly As Boolean On Me.TexTBox.IsReadOnly
```
``` VB.NET
Public Property IsReadOnly As Boolean Of Me.TexTBox.IsReadOnly
```
``` VB.NET
Public Property IsReadOnly As Boolean With Me.TexTBox.IsReadOnly
```
``` VB.NET
Public Property IsReadOnly As Boolean From Me.TexTBox.IsReadOnly
```
``` VB.NET
Public Property IsReadOnly As Boolean For Me.TexTBox.IsReadOnly
```
I previously suggested another compact form for multiline Readonly Properties in #403
This new suggestion offers a compact form fro single-line readonly properties too:
```VB.NET
Public ReadOnly Property Foo As Boolean On Dictionary("Foo")
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.