@@ -12,9 +12,11 @@ public async Task InvokeIndexerOnPropertyValueAsync()
1212 // Chances of having an unknown delegate stored as a field/property/local seem lower than having an unknown non-delegate
1313 // type with an indexer stored, so for a standalone identifier err on the side of assuming it's an indexer
1414 await TestConversionVisualBasicToCSharpAsync ( @"Class TestClass
15- Public Property SomeProperty As System.Some.UnknownType
15+ Public Property SomeProperty As System.Some.UnknownType
1616 Private Sub TestMethod()
17- Dim value = SomeProperty(0)
17+ Dim num = 0
18+ Dim value = SomeProperty(num)
19+ value = SomeProperty(0)
1820 End Sub
1921End Class" , @"
2022internal partial class TestClass
@@ -23,7 +25,9 @@ internal partial class TestClass
2325
2426 private void TestMethod()
2527 {
26- var value = SomeProperty[0];
28+ int num = 0;
29+ var value = SomeProperty[num];
30+ value = SomeProperty[0];
2731 }
2832}
29332 source compilation errors:
@@ -32,6 +36,33 @@ private void TestMethod()
32361 target compilation errors:
3337CS0234: The type or namespace name 'Some' does not exist in the namespace 'System' (are you missing an assembly reference?)" ) ;
3438 }
39+ [ Fact ]
40+ public async Task InvokeMethodOnPropertyValueAsync ( )
41+ {
42+ // Chances of having an unknown delegate stored as a field/property/local seem lower than having an unknown non-delegate
43+ // type with an indexer stored, so for a standalone identifier err on the side of assuming it's an indexer
44+ await TestConversionVisualBasicToCSharpAsync ( @"Class TestClass
45+ Public Property SomeProperty As System.Some.UnknownType
46+ Private Sub TestMethod()
47+ Dim value = SomeProperty(New Object())
48+ End Sub
49+ End Class" , @"
50+ internal partial class TestClass
51+ {
52+ public System.Some.UnknownType SomeProperty { get; set; }
53+
54+ private void TestMethod()
55+ {
56+ var value = SomeProperty(new object());
57+ }
58+ }
59+ 2 source compilation errors:
60+ BC30002: Type 'System.Some.UnknownType' is not defined.
61+ BC32016: 'Public Property SomeProperty As System.Some.UnknownType' has no parameters and its return type cannot be indexed.
62+ 2 target compilation errors:
63+ CS0234: The type or namespace name 'Some' does not exist in the namespace 'System' (are you missing an assembly reference?)
64+ CS1955: Non-invocable member 'TestClass.SomeProperty' cannot be used like a method." ) ;
65+ }
3566
3667 [ Fact ]
3768 public async Task InvokeMethodWithUnknownReturnTypeAsync ( )
@@ -310,14 +341,15 @@ internal partial class TestClass
310341
311342 private void TestMethod()
312343 {
313- var a = DefaultDate.Blawer(1, 2, 3);
344+ var a = DefaultDate(1, 2, 3) .Blawer(1, 2, 3);
314345 }
315346}
3163472 source compilation errors:
317348BC30002: Type 'System.SomeUnknownType' is not defined.
318349BC32016: 'Private Property DefaultDate As System.SomeUnknownType' has no parameters and its return type cannot be indexed.
319- 1 target compilation errors:
320- CS0234: The type or namespace name 'SomeUnknownType' does not exist in the namespace 'System' (are you missing an assembly reference?)" ) ;
350+ 2 target compilation errors:
351+ CS0234: The type or namespace name 'SomeUnknownType' does not exist in the namespace 'System' (are you missing an assembly reference?)
352+ CS1955: Non-invocable member 'TestClass.DefaultDate' cannot be used like a method." ) ;
321353 }
322354
323355 [ Fact ]
0 commit comments