-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathMemberTests.cs
More file actions
1667 lines (1492 loc) · 40.3 KB
/
MemberTests.cs
File metadata and controls
1667 lines (1492 loc) · 40.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System.Threading.Tasks;
using ICSharpCode.CodeConverter.Tests.TestRunners;
using Xunit;
namespace ICSharpCode.CodeConverter.Tests.CSharp.MemberTests;
public class MemberTests : ConverterTestBase
{
[Fact]
public async Task TestFieldAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Const answer As Integer = 42
Private value As Integer = 10
ReadOnly v As Integer = 15
End Class", @"
internal partial class TestClass
{
private const int answer = 42;
private int value = 10;
private readonly int v = 15;
}");
}
[Fact]
public async Task TestMultiArrayFieldAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Dim Parts(), Taxes(), Deposits()(), Prepaid()(), FromDate, ToDate As String
End Class", @"
internal partial class TestClass
{
private string[] Parts, Taxes;
private string[][] Deposits, Prepaid;
private string FromDate, ToDate;
}");
}
[Fact]
public async Task TestConstantFieldInModuleAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Module TestModule
Const answer As Integer = 42
End Module", @"
internal static partial class TestModule
{
private const int answer = 42;
}");
}
[Fact]
public async Task TestDeclareMethodVisibilityInModuleAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Module Module1
Declare Sub External Lib ""lib.dll"" ()
End Module", @"using System.Runtime.InteropServices;
internal static partial class Module1
{
[DllImport(""lib.dll"")]
public static extern void External();
}");
}
[Fact]
public async Task TestDeclareMethodVisibilityInClassAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Class Class1
Declare Sub External Lib ""lib.dll"" ()
End Class", @"using System.Runtime.InteropServices;
internal partial class Class1
{
[DllImport(""lib.dll"")]
public static extern void External();
}");
}
[Fact]
public async Task TestTypeInferredConstAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Const someConstField = 42
Sub TestMethod()
Const someConst = System.DateTimeKind.Local
End Sub
End Class", @"using System;
internal partial class TestClass
{
private const int someConstField = 42;
public void TestMethod()
{
const DateTimeKind someConst = DateTimeKind.Local;
}
}");
}
[Fact]
public async Task TestTypeInferredVarAsync()
{
// VB doesn't infer the type of EnumVariable like you'd think, it just uses object
// VB compiler uses Conversions rather than any plainer casting
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Enum TestEnum As Integer
Test1
End Enum
Dim EnumVariable = TestEnum.Test1
Public Sub AMethod()
Dim t1 As Integer = EnumVariable
End Sub
End Class", @"using Microsoft.VisualBasic.CompilerServices; // Install-Package Microsoft.VisualBasic
internal partial class TestClass
{
public enum TestEnum : int
{
Test1
}
private object EnumVariable = TestEnum.Test1;
public void AMethod()
{
int t1 = Conversions.ToInteger(EnumVariable);
}
}");
}
[Fact]
public async Task TestMethodAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
argument = Nothing
argument2 = Nothing
argument3 = Nothing
Console.WriteLine(Enumerable.Empty(Of String))
End Sub
End Class", @"using System;
using System.Linq;
internal partial class TestClass
{
public void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
where T : class, new()
where T2 : struct
{
argument = null;
argument2 = default;
argument3 = default;
Console.WriteLine(Enumerable.Empty<string>());
}
}");
}
[Fact]
public async Task TestMethodAssignmentReturnAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class Class1
Function TestMethod(x As Integer) As Integer
If x = 1 Then
TestMethod = 1
ElseIf x = 2 Then
TestMethod = 2
Exit Function
ElseIf x = 3 Then
TestMethod = TestMethod(1)
End If
End Function
End Class", @"
internal partial class Class1
{
public int TestMethod(int x)
{
int TestMethodRet = default;
if (x == 1)
{
TestMethodRet = 1;
}
else if (x == 2)
{
TestMethodRet = 2;
return TestMethodRet;
}
else if (x == 3)
{
TestMethodRet = TestMethod(1);
}
return TestMethodRet;
}
}");
}
[Fact]
public async Task TestMethodAssignmentReturn293Async()
{
await TestConversionVisualBasicToCSharpAsync(
@"Public Class Class1
Public Event MyEvent As EventHandler
Protected Overrides Function Foo() As String
AddHandler MyEvent, AddressOf Foo
Foo = Foo & """"
Foo += NameOf(Foo)
End Function
End Class", @"using System;
public partial class Class1
{
public event EventHandler MyEvent;
protected override string Foo()
{
string FooRet = default;
MyEvent += (_, __) => Foo();
FooRet = FooRet + """";
FooRet += nameof(Foo);
return FooRet;
}
}
1 source compilation errors:
BC30284: function 'Foo' cannot be declared 'Overrides' because it does not override a function in a base class.
1 target compilation errors:
CS0115: 'Class1.Foo()': no suitable method found to override");
}
[Fact]
public async Task TestMethodAssignmentAdditionReturnAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class Class1
Function TestMethod(x As Integer) As Integer
If x = 1 Then
TestMethod += 1
ElseIf x = 2 Then
TestMethod -= 2
Exit Function
ElseIf x = 3 Then
TestMethod *= TestMethod(1)
End If
End Function
End Class", @"
internal partial class Class1
{
public int TestMethod(int x)
{
int TestMethodRet = default;
if (x == 1)
{
TestMethodRet += 1;
}
else if (x == 2)
{
TestMethodRet -= 2;
return TestMethodRet;
}
else if (x == 3)
{
TestMethodRet *= TestMethod(1);
}
return TestMethodRet;
}
}");
}
[Fact]
public async Task TestMethodMissingReturnAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class Class1
Function TestMethod() As Integer
End Function
End Class", @"
internal partial class Class1
{
public int TestMethod()
{
return default;
}
}");
}
[Fact]
public async Task TestMethodWithOutParameterAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Function TryGet(<System.Runtime.InteropServices.Out> ByRef strs As List(Of String)) As Boolean
strs = New List(Of String)
Return False
End Function
End Class", @"using System.Collections.Generic;
internal partial class TestClass
{
public bool TryGet(out List<string> strs)
{
strs = new List<string>();
return false;
}
}");
}
[Fact]
public async Task TestMethodWithReturnTypeAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Function TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3) As Integer
Return 0
End Function
End Class", @"
internal partial class TestClass
{
public int TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
where T : class, new()
where T2 : struct
{
return 0;
}
}
1 target compilation errors:
CS0177: The out parameter 'argument' must be assigned to before control leaves the current method");
}
[Fact]
public async Task TestFunctionWithNoReturnTypeSpecifiedAsync()
{
// Note: "Inferred" type is always object except with local variables
// https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/variables/local-type-inference
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Private Function TurnFirstToUp(ByVal Text As String)
Dim firstCharacter = Text.Substring(0, 1).ToUpper()
Return firstCharacter + Text.Substring(1)
End Function
End Class", @"
internal partial class TestClass
{
private object TurnFirstToUp(string Text)
{
string firstCharacter = Text.Substring(0, 1).ToUpper();
return firstCharacter + Text.Substring(1);
}
}");
}
[Fact]
public async Task TestFunctionReturningTypeRequiringConversionAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Function Four() As String
Return 4
End Function
End Class", @"
internal partial class TestClass
{
public string Four()
{
return 4.ToString();
}
}");
}
[Fact]
public async Task TestStaticMethodAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Shared Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
argument = Nothing
argument2 = Nothing
argument3 = Nothing
End Sub
End Class", @"
internal partial class TestClass
{
public static void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
where T : class, new()
where T2 : struct
{
argument = null;
argument2 = default;
argument3 = default;
}
}");
}
[Fact]
public async Task TestAbstractMethodAndPropertyAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"MustInherit Class TestClass
Public MustOverride Sub TestMethod()
Public MustOverride ReadOnly Property AbstractProperty As String
End Class", @"
internal abstract partial class TestClass
{
public abstract void TestMethod();
public abstract string AbstractProperty { get; }
}");
}
[Fact]
public async Task TestAbstractReadOnlyAndWriteOnlyPropertyAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"MustInherit Class TestClass
Public MustOverride ReadOnly Property ReadOnlyProp As String
Public MustOverride WriteOnly Property WriteOnlyProp As String
End Class
Class ChildClass
Inherits TestClass
Public Overrides ReadOnly Property ReadOnlyProp As String
Public Overrides WriteOnly Property WriteOnlyProp As String
Set
End Set
End Property
End Class
", @"
internal abstract partial class TestClass
{
public abstract string ReadOnlyProp { get; }
public abstract string WriteOnlyProp { set; }
}
internal partial class ChildClass : TestClass
{
public override string ReadOnlyProp { get; }
public override string WriteOnlyProp
{
set
{
}
}
}");
}
[Fact]
public async Task SetterProperty1053Async()
{
await TestConversionVisualBasicToCSharpAsync(
@"
Public Property Prop(ByVal i As Integer) As String
Get
Static bGet As Boolean
bGet = False
End Get
Set(ByVal s As String)
Static bSet As Boolean
bSet = False
End Set
End Property
", @"
internal partial class SurroundingClass
{
private bool _Prop_bGet;
private bool _Prop_bSet;
public string get_Prop(int i)
{
_Prop_bGet = false;
return default;
}
public void set_Prop(int i, string value)
{
_Prop_bSet = false;
}
}");
}
[Fact]
public async Task StaticLocalsInPropertyGetterAndSetterAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"
Public Property Prop As String
Get
Static b As Boolean
b = True
End Get
Set(ByVal s As String)
Static b As Boolean
b = False
End Set
End Property
", @"
internal partial class SurroundingClass
{
private bool _Prop_b;
private bool _Prop_b1;
public string Prop
{
get
{
_Prop_b = true;
return default;
}
set
{
_Prop_b1 = false;
}
}
}");
}
[Fact]
public async Task TestSealedMethodAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public NotOverridable Sub TestMethod(Of T As {Class, New}, T2 As Structure, T3)(<Out> ByRef argument As T, ByRef argument2 As T2, ByVal argument3 As T3)
argument = Nothing
argument2 = Nothing
argument3 = Nothing
End Sub
End Class", @"
internal partial class TestClass
{
public sealed void TestMethod<T, T2, T3>(out T argument, ref T2 argument2, T3 argument3)
where T : class, new()
where T2 : struct
{
argument = null;
argument2 = default;
argument3 = default;
}
}
1 source compilation errors:
BC31088: 'NotOverridable' cannot be specified for methods that do not override another method.
1 target compilation errors:
CS0238: 'TestClass.TestMethod<T, T2, T3>(out T, ref T2, T3)' cannot be sealed because it is not an override");
}
[Fact]
public async Task TestShadowedMethodAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Sub TestMethod()
End Sub
Public Sub TestMethod(i as Integer)
End Sub
End Class
Class TestSubclass
Inherits TestClass
Public Shadows Sub TestMethod()
' Not possible: TestMethod(3)
System.Console.WriteLine(""New implementation"")
End Sub
End Class", @"using System;
internal partial class TestClass
{
public void TestMethod()
{
}
public void TestMethod(int i)
{
}
}
internal partial class TestSubclass : TestClass
{
public new void TestMethod()
{
// Not possible: TestMethod(3)
Console.WriteLine(""New implementation"");
}
}");
}
[Fact]
public async Task TestDestructorAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Protected Overrides Sub Finalize()
End Sub
End Class", @"
internal partial class TestClass
{
~TestClass()
{
}
}");
}
[Fact]
public async Task Issue681_OverloadsOverridesPropertyAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Public Class C
Inherits B
Public ReadOnly Overloads Overrides Property X()
Get
Return Nothing
End Get
End Property
End Class
Public Class B
Public ReadOnly Overridable Property X()
Get
Return Nothing
End Get
End Property
End Class", @"public partial class C : B
{
public override object X
{
get
{
return null;
}
}
}
public partial class B
{
public virtual object X
{
get
{
return null;
}
}
}");
}
[Fact]
public async Task PartialFriendClassWithOverloadsAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Partial Friend MustInherit Class TestClass1
Public Shared Sub CreateStatic()
End Sub
Public Overloads Sub CreateInstance()
End Sub
Public Overloads Sub CreateInstance(o As Object)
End Sub
Public MustOverride Sub CreateAbstractInstance()
Public Overridable Sub CreateVirtualInstance()
End Sub
End Class
Friend Class TestClass2
Inherits TestClass1
Public Overloads Shared Sub CreateStatic()
End Sub
Public Overloads Sub CreateInstance()
End Sub
Public Overrides Sub CreateAbstractInstance()
End Sub
Public Overloads Sub CreateVirtualInstance(o As Object)
End Sub
End Class",
@"
internal abstract partial class TestClass1
{
public static void CreateStatic()
{
}
public void CreateInstance()
{
}
public void CreateInstance(object o)
{
}
public abstract void CreateAbstractInstance();
public virtual void CreateVirtualInstance()
{
}
}
internal partial class TestClass2 : TestClass1
{
public new static void CreateStatic()
{
}
public new void CreateInstance()
{
}
public override void CreateAbstractInstance()
{
}
public void CreateVirtualInstance(object o)
{
}
}");
}
[Fact]
public async Task ClassWithGloballyQualifiedAttributeAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"<Global.System.Diagnostics.DebuggerDisplay(""Hello World"")>
Class TestClass
End Class", @"using System.Diagnostics;
[DebuggerDisplay(""Hello World"")]
internal partial class TestClass
{
}");
}
[Fact]
public async Task FieldWithAttributeAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Class TestClass
<ThreadStatic>
Private Shared First As Integer
End Class", @"using System;
internal partial class TestClass
{
[ThreadStatic]
private static int First;
}");
}
[Fact]
public async Task FieldWithNonStaticInitializerAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Public Class A
Private x As Integer = 2
Private y(x) As Integer
End Class", @"
public partial class A
{
private int x = 2;
private int[] y;
public A()
{
y = new int[x + 1];
}
}");
}
[Fact]
public async Task FieldWithInstanceOperationOfDifferingTypeAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Public Class DoesNotNeedConstructor
Private ReadOnly ClassVariable1 As New ParallelOptions With {.MaxDegreeOfParallelism = 5}
End Class", @"using System.Threading.Tasks;
public partial class DoesNotNeedConstructor
{
private readonly ParallelOptions ClassVariable1 = new ParallelOptions() { MaxDegreeOfParallelism = 5 };
}");
}
[Fact]
public async Task Issue281FieldWithNonStaticLambdaInitializerAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Imports System.IO
Public Class Issue281
Private lambda As System.Delegate = New ErrorEventHandler(Sub(a, b) Len(0))
Private nonShared As System.Delegate = New ErrorEventHandler(AddressOf OnError)
Sub OnError(s As Object, e As ErrorEventArgs)
End Sub
End Class", @"using System;
using System.IO;
using Microsoft.VisualBasic; // Install-Package Microsoft.VisualBasic
public partial class Issue281
{
private Delegate lambda = new ErrorEventHandler((a, b) => Strings.Len(0));
private Delegate nonShared;
public Issue281()
{
nonShared = new ErrorEventHandler(OnError);
}
public void OnError(object s, ErrorEventArgs e)
{
}
}");
}
[Fact]
public async Task ParamArrayAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Class TestClass
Private Sub SomeBools(ParamArray anyName As Boolean())
End Sub
End Class", @"
internal partial class TestClass
{
private void SomeBools(params bool[] anyName)
{
}
}");
}
[Fact]
public async Task ParamNamedBoolAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Class TestClass
Private Sub SomeBools(ParamArray bool As Boolean())
End Sub
End Class", @"
internal partial class TestClass
{
private void SomeBools(params bool[] @bool)
{
}
}");
}
[Fact]
public async Task MethodWithNameArrayParameterAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Sub DoNothing(ByVal strs() As String)
Dim moreStrs() As String
End Sub
End Class",
@"
internal partial class TestClass
{
public void DoNothing(string[] strs)
{
string[] moreStrs;
}
}");
}
[Fact]
public async Task UntypedParametersAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Public Sub DoNothing(obj, objs())
End Sub
End Class",
@"
internal partial class TestClass
{
public void DoNothing(object obj, object[] objs)
{
}
}");
}
[Fact]
public async Task PartialClassAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Public Partial Class TestClass
Private Sub DoNothing()
Console.WriteLine(""Hello"")
End Sub
End Class
Class TestClass ' VB doesn't require partial here (when just a single class omits it)
Partial Private Sub DoNothing()
End Sub
End Class",
@"using System;
public partial class TestClass
{
partial void DoNothing()
{
Console.WriteLine(""Hello"");
}
}
public partial class TestClass // VB doesn't require partial here (when just a single class omits it)
{
partial void DoNothing();
}");
}
[Fact]
public async Task Issue1097_PartialMethodAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Partial Private Sub DummyMethod()
End Sub", @"partial void DummyMethod();");
}
[Fact]
public async Task NestedClassAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Class ClA
Public Shared Sub MA()
ClA.ClassB.MB()
MyClassC.MC()
End Sub
Public Class ClassB
Public Shared Function MB() as ClassB
ClA.MA()
MyClassC.MC()
Return ClA.ClassB.MB()
End Function
End Class
End Class
Class MyClassC
Public Shared Sub MC()
ClA.MA()
ClA.ClassB.MB()
End Sub
End Class", @"
internal partial class ClA
{
public static void MA()
{
ClassB.MB();
MyClassC.MC();
}
public partial class ClassB
{
public static ClassB MB()
{
MA();
MyClassC.MC();
return MB();
}
}
}
internal partial class MyClassC
{
public static void MC()
{
ClA.MA();
ClA.ClassB.MB();
}
}");
}
[Fact]
public async Task LessQualifiedNestedClassAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"Class ClA
Public Shared Sub MA()
ClassB.MB()
MyClassC.MC()
End Sub
Public Class ClassB
Public Shared Function MB() as ClassB
MA()
MyClassC.MC()
Return MB()
End Function
End Class
End Class