@@ -138,21 +138,21 @@ public async Task ForEachStatementWithExplicitTypeAsync()
138138 {
139139 await TestConversionVisualBasicToCSharpAsync ( @"Class TestClass
140140 Private Sub TestMethod(ByVal values As Integer())
141- For Each val As Integer In values
142- If val = 2 Then Continue For
143- If val = 3 Then Exit For
141+ For Each v As Integer In values
142+ If v = 2 Then Continue For
143+ If v = 3 Then Exit For
144144 Next
145145 End Sub
146146End Class" , @"
147147internal partial class TestClass
148148{
149149 private void TestMethod(int[] values)
150150 {
151- foreach (int val in values)
151+ foreach (int v in values)
152152 {
153- if (val == 2)
153+ if (v == 2)
154154 continue;
155- if (val == 3)
155+ if (v == 3)
156156 break;
157157 }
158158 }
@@ -164,6 +164,33 @@ public async Task ForEachStatementWithVarAsync()
164164 {
165165 await TestConversionVisualBasicToCSharpAsync ( @"Class TestClass
166166 Private Sub TestMethod(ByVal values As Integer())
167+ For Each v In values
168+ If v = 2 Then Continue For
169+ If v = 3 Then Exit For
170+ Next
171+ End Sub
172+ End Class" , @"
173+ internal partial class TestClass
174+ {
175+ private void TestMethod(int[] values)
176+ {
177+ foreach (var v in values)
178+ {
179+ if (v == 2)
180+ continue;
181+ if (v == 3)
182+ break;
183+ }
184+ }
185+ }" ) ;
186+ }
187+
188+ [ Fact ]
189+ public async Task ForEachStatementWithOuterDeclarationAsync ( )
190+ {
191+ await TestConversionVisualBasicToCSharpAsync ( @"Class TestClass
192+ Private Sub TestMethod(ByVal values As Integer())
193+ Dim val As Integer
167194 For Each val In values
168195 If val = 2 Then Continue For
169196 If val = 3 Then Exit For
@@ -174,17 +201,17 @@ internal partial class TestClass
174201{
175202 private void TestMethod(int[] values)
176203 {
177- foreach (var val in values)
204+ int val;
205+ foreach (int currentVal in values)
178206 {
207+ val = currentVal;
179208 if (val == 2)
180209 continue;
181210 if (val == 3)
182211 break;
183212 }
184213 }
185- }
186- 1 source compilation errors:
187- BC30516: Overload resolution failed because no accessible 'Val' accepts this number of arguments." ) ;
214+ }" ) ;
188215 }
189216
190217 [ Fact ]
0 commit comments