Skip to content

Commit 1aeafbc

Browse files
Add test cases
1 parent e8cd756 commit 1aeafbc

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

Tests/CSharp/MemberTests/MemberTests.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,29 @@ public async static Task<T> Then<T>(this Task task, Func<Task<T>> f)
11251125
11261126
public async static Task Then(this Task task, Func<Task> f)
11271127
{
1128+
1129+
[Fact]
1130+
public async Task TestAsyncFunctionExitReturnsDefaultAsync()
1131+
{
1132+
await TestConversionVisualBasicToCSharpAsync(
1133+
@"Imports System.Threading.Tasks
1134+
1135+
Class AsyncExit
1136+
Public Async Function AsyncFuncExit() As Task(Of Integer)
1137+
Await Task.Delay(1)
1138+
Exit Function
1139+
End Function
1140+
End Class", @"using System.Threading.Tasks;
1141+
1142+
internal partial class AsyncExit
1143+
{
1144+
public async Task<int> AsyncFuncExit()
1145+
{
1146+
await Task.Delay(1);
1147+
return default;
1148+
}
1149+
}");
1150+
}
11281151
await task;
11291152
await f();
11301153
}
@@ -1147,6 +1170,27 @@ public async static Task ThenExit<T>(this Task<T> task, Func<T, Task> f)
11471170
}");
11481171
}
11491172

1173+
[Fact]
1174+
public async Task TestAsyncTaskFunctionNoImplicitReturnAsync()
1175+
{
1176+
await TestConversionVisualBasicToCSharpAsync(
1177+
@"Imports System.Threading.Tasks
1178+
1179+
Class AsyncNoReturn
1180+
Public Async Function DoAsync() As Task
1181+
Await Task.Delay(1)
1182+
End Function
1183+
End Class", @"using System.Threading.Tasks;
1184+
1185+
internal partial class AsyncNoReturn
1186+
{
1187+
public async Task DoAsync()
1188+
{
1189+
await Task.Delay(1);
1190+
}
1191+
}");
1192+
}
1193+
11501194
[Fact]
11511195
public async Task TestExternDllImportAsync()
11521196
{

Tests/CSharp/MemberTests/PropertyMemberTests.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,63 @@ public int Test3
6868
BC30124: Property without a 'ReadOnly' or 'WriteOnly' specifier must provide both a 'Get' and a 'Set'.");
6969
}
7070

71+
[Fact]
72+
public async Task TestWriteOnlyPropertyExitAsync()
73+
{
74+
await TestConversionVisualBasicToCSharpAsync(
75+
@"Class TestClass
76+
Private m_value As Integer
77+
78+
Public WriteOnly Property Value As Integer
79+
Set(ByVal value As Integer)
80+
If value = 0 Then Exit Property
81+
m_value = value
82+
End Set
83+
End Property
84+
End Class", @"
85+
internal partial class TestClass
86+
{
87+
private int m_value;
88+
89+
public int Value
90+
{
91+
set
92+
{
93+
if (value == 0)
94+
return;
95+
m_value = value;
96+
}
97+
}
98+
}");
99+
}
100+
101+
[Fact]
102+
public async Task TestExitPropertyInTaskReturningGetterAsync()
103+
{
104+
await TestConversionVisualBasicToCSharpAsync(
105+
@"Imports System.Threading.Tasks
106+
107+
Class TestClass
108+
Public ReadOnly Property Value As Task(Of Integer)
109+
Get
110+
Exit Property
111+
End Get
112+
End Property
113+
End Class", @"
114+
using System.Threading.Tasks;
115+
116+
internal partial class TestClass
117+
{
118+
public Task<int> Value
119+
{
120+
get
121+
{
122+
return default;
123+
}
124+
}
125+
}");
126+
}
127+
71128
[Fact]
72129
public async Task TestParameterizedPropertyAsync()
73130
{

0 commit comments

Comments
 (0)