Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature, VisualBasic With Keyword Syntax for property mapping #433

Open
xieguigang opened this issue Dec 6, 2016 · 2 comments
Open

Comments

@xieguigang
Copy link

Hi, currently, if we want to get or set property value to another object, 7 lines of code must be used,

Current:

Dim _value As <Value>

Public Property Value As String
Get
    Return _value.Label
End Get
Set
    _value.Label = value
End Set

This is not so convenient and not a brief code, and I think this situation can be simplify with the VisualBasic With keyword

Dim _value As <Value>

' maps both get and set
Public Property Value As String With _value.Label
' maps readonly
Public ReadOnly Property Value2 As String With _value.Label
' maps writeonly
Public WriteOnly Property Value3 As String With _value.Label

Or with two lines of code syntax

Dim _value As <Value>

' maps both get and set
Public Property Value As String 
    With _value.Label

' maps readonly
Public ReadOnly Property Value2 As String 
    With _value.Label

' maps writeonly
Public WriteOnly Property Value3 As String 
    With _value.Label

Which it means the Value property its value was mapped to the property of another object _value.Label, this will makes the code more beautiful and briefly.

@xieguigang xieguigang changed the title With Keyword Syntax for property mapping New Feature, VisualBasic With Keyword Syntax for property mapping Dec 6, 2016
@gafter gafter transferred this issue from dotnet/roslyn May 6, 2019
@VBAndCs
Copy link

VBAndCs commented May 8, 2019

This can compined with #403 to bind an expression or block of code:

Public ReadOnly Property Sum() string With {
   Dim _sum = 0
   For each .....
      _sum+= .......
   Next 
   Return _sum}
End Property

@VBAndCs
Copy link

VBAndCs commented May 8, 2019

Or it can compined with #422 :

Public ReadOnly Property Sum() string With <(
   Dim _sum = 0
   For each .....
      _sum+= .......
   Next 
   Return _sum)>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants