提交 21ca5b72 编写于 作者: V vsadov

Added a test with parameterized property

上级 bbcc6165
......@@ -8056,6 +8056,82 @@ aa
]]>).VerifyDiagnostics()
End Sub
<Fact, WorkItem(4524, "https://github.com/dotnet/roslyn/issues/4524")>
Public Sub PropertyAssignmentParameterized()
Dim source = <compilation>
<file name="a.vb"><![CDATA[
Imports System
Imports System.Linq.Expressions
Module Module1
Public Interface IAddress
Property City(i As Integer) As String
End Interface
Public Class Address
Implements IAddress
Private c As String
Public Property City(i As Integer) As String Implements IAddress.City
Get
Return c & i
End Get
Set(value As String)
c = value & i
End Set
End Property
Public Field As String
Public Sub Verify(expression As Expression(Of Action(Of Address)))
Console.WriteLine(expression.ToString())
expression.Compile()(Me)
End Sub
End Class
Public Class Customer
Public Property Address As IAddress
Public Sub DoWork(newValue As String)
Address.City(0) = newValue
End Sub
End Class
Public Function ItIs(Of TValue)(match As Expression(Of Func(Of TValue, Boolean))) As TValue
End Function
Sub Main()
Dim a As New Address
a.Verify(Sub(x) x.City(1) = ItIs(Of String)(Function(s) String.IsNullOrEmpty(s)))
Dim i As Integer = 2
a.Verify(Sub(x) x.City(i) = "aa")
System.Console.WriteLine(a.City(3))
End Sub
End Module
]]></file>
</compilation>
CompileAndVerify(source,
additionalRefs:={SystemCoreRef},
options:=TestOptions.ReleaseExe,
expectedOutput:=<![CDATA[
x => x.set_City(1, ItIs(s => IsNullOrEmpty(s)))
x => x.set_City(value(Module1+_Closure$__4-0).$VB$Local_i, "aa")
aa23
]]>).VerifyDiagnostics()
End Sub
<Fact, WorkItem(4524, "https://github.com/dotnet/roslyn/issues/4524")>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册