@@ -19,7 +19,7 @@ public void TestBinary()
19
19
public int Main(int a, int b)
20
20
{
21
21
return a + b;
22
- }"
22
+ }" . Trim ( )
23
23
, str ) ;
24
24
}
25
25
@@ -40,7 +40,7 @@ public void TestBinary_ArrayIndex()
40
40
public int Main(int[] a)
41
41
{
42
42
return a[0];
43
- }"
43
+ }" . Trim ( )
44
44
, str ) ;
45
45
}
46
46
@@ -53,7 +53,7 @@ public void TestBlock()
53
53
Assert . AreEqual ( @"
54
54
int p1;
55
55
56
- p1 + p1;" , str ) ;
56
+ p1 + p1;" . Trim ( ) , str ) ;
57
57
}
58
58
59
59
[ TestMethod ]
@@ -65,7 +65,7 @@ public void Test_Conditional()
65
65
public int Main(int a)
66
66
{
67
67
return a < 0 ? a - 1 : a + 1;
68
- }"
68
+ }" . Trim ( )
69
69
, str ) ;
70
70
}
71
71
@@ -86,7 +86,7 @@ public void TestConditional_Block()
86
86
else
87
87
{
88
88
3;
89
- }"
89
+ }" . Trim ( )
90
90
, str ) ;
91
91
}
92
92
@@ -115,7 +115,7 @@ public void TestConditional_Block_Chain()
115
115
else
116
116
{
117
117
2;
118
- }"
118
+ }" . Trim ( )
119
119
, str ) ;
120
120
}
121
121
@@ -128,7 +128,7 @@ public void TestConstants()
128
128
public char Main(string s)
129
129
{
130
130
return s == ""x"" || s == @""\"" || s == null || s.IsNormalized() == false || s.GetType() == typeof(string) ? 'x' : s[0];
131
- }"
131
+ }" . Trim ( )
132
132
, str ) ;
133
133
134
134
Expression < Func < string > > fn2 = ( ) => 1f . ToString ( ) + 2m . ToString ( ) + ( ( byte ) 1 ) . ToString ( ) + DayOfWeek . Friday . ToString ( ) + default ( DateTime ) . ToString ( ) ;
@@ -137,7 +137,7 @@ public char Main(string s)
137
137
public string Main()
138
138
{
139
139
return 1f.ToString() + 2m.ToString() + ((byte)1).ToString() + DayOfWeek.Friday.ToString() + default(DateTime).ToString();
140
- }"
140
+ }" . Trim ( )
141
141
, str2 ) ;
142
142
}
143
143
@@ -149,7 +149,7 @@ public void TestConstant_DateTime()
149
149
var script = expr . ToScript ( ) ;
150
150
Assert . AreEqual ( @"
151
151
private DateTime DateTime1;
152
- DateTime1" , script ) ;
152
+ DateTime1" . Trim ( ) , script ) ;
153
153
}
154
154
155
155
// [TestMethod]
@@ -224,7 +224,7 @@ public void TestDefault()
224
224
{
225
225
var exp = Expression . Default ( typeof ( int ) ) ;
226
226
var str = exp . ToScript ( ) ;
227
- Assert . AreEqual ( @ "default(int)", str ) ;
227
+ Assert . AreEqual ( "default(int)" , str ) ;
228
228
}
229
229
230
230
[ TestMethod ]
@@ -236,7 +236,7 @@ public void TestGroup()
236
236
public int Main(int x)
237
237
{
238
238
return -(-x) + 1 + x - (1 - x);
239
- }"
239
+ }" . Trim ( )
240
240
, str ) ;
241
241
}
242
242
@@ -287,7 +287,7 @@ public void TestLambda()
287
287
private int func1(int p1)
288
288
{
289
289
return p1 + 1;
290
- }"
290
+ }" . Trim ( )
291
291
, str ) ;
292
292
}
293
293
@@ -300,7 +300,7 @@ public void TestLambda_Inline()
300
300
public IQueryable<int> Main(IQueryable<int> q)
301
301
{
302
302
return q.Where<int>(it => it > 0);
303
- }"
303
+ }" . Trim ( )
304
304
, str ) ;
305
305
}
306
306
@@ -313,7 +313,7 @@ public void TestListInit()
313
313
public List<int> Main()
314
314
{
315
315
return new List<int>() {1, 2, 3};
316
- }"
316
+ }" . Trim ( )
317
317
, str ) ;
318
318
}
319
319
@@ -330,7 +330,7 @@ public void TestListInit_Dictionary()
330
330
public Dictionary<int, int> Main()
331
331
{
332
332
return new Dictionary<int, int>() {{1, 2}, {3, 4}};
333
- }"
333
+ }" . Trim ( )
334
334
, str ) ;
335
335
}
336
336
@@ -367,7 +367,7 @@ public void TestLoop()
367
367
p1--;
368
368
continue;
369
369
}
370
- }"
370
+ }" . Trim ( )
371
371
, str ) ;
372
372
}
373
373
@@ -384,7 +384,7 @@ public void TestLoop2()
384
384
{
385
385
goto label1;
386
386
}
387
- label1:"
387
+ label1:" . Trim ( )
388
388
, str ) ;
389
389
}
390
390
@@ -397,7 +397,7 @@ public void TestMemberAccess()
397
397
public int Main()
398
398
{
399
399
return DateTime.Now.Day;
400
- }"
400
+ }" . Trim ( )
401
401
, str ) ;
402
402
}
403
403
@@ -427,7 +427,7 @@ public DebugInfoInjectorTest.Poco Main()
427
427
Parent = {Name = ""2""},
428
428
Children = {new DebugInfoInjectorTest.Poco(), new DebugInfoInjectorTest.Poco()}
429
429
};
430
- }"
430
+ }" . Trim ( )
431
431
, str ) ;
432
432
}
433
433
@@ -440,7 +440,7 @@ public void TestMethodCall_Default()
440
440
public int Main(Dictionary<int, int> dict)
441
441
{
442
442
return dict[0];
443
- }"
443
+ }" . Trim ( )
444
444
, str ) ;
445
445
}
446
446
@@ -453,7 +453,7 @@ public void TestMethodCall()
453
453
public string Main(List<int> list)
454
454
{
455
455
return list.ToString();
456
- }"
456
+ }" . Trim ( )
457
457
, str ) ;
458
458
}
459
459
@@ -466,7 +466,7 @@ public void TestMethodCall_Static()
466
466
public int Main(int a, int b)
467
467
{
468
468
return Math.Max(a, b);
469
- }"
469
+ }" . Trim ( )
470
470
, str ) ;
471
471
}
472
472
@@ -479,7 +479,7 @@ public void TestNewArray()
479
479
public int[] Main(int i)
480
480
{
481
481
return new int[] {i};
482
- }"
482
+ }" . Trim ( )
483
483
, str ) ;
484
484
}
485
485
@@ -492,7 +492,7 @@ public void TestNewArray_Bound()
492
492
public int[] Main(int i)
493
493
{
494
494
return new int[i];
495
- }"
495
+ }" . Trim ( )
496
496
, str ) ;
497
497
}
498
498
@@ -505,7 +505,7 @@ public void TestParameter_Reserved()
505
505
public int Main(int? @null)
506
506
{
507
507
return @null.Value;
508
- }"
508
+ }" . Trim ( )
509
509
, str ) ;
510
510
}
511
511
@@ -527,7 +527,7 @@ public void TestSwitch()
527
527
default:
528
528
0;
529
529
break;
530
- }"
530
+ }" . Trim ( )
531
531
, str ) ;
532
532
}
533
533
@@ -559,7 +559,7 @@ public void TestTryCatch()
559
559
finally
560
560
{
561
561
throw new NotSupportedException();
562
- }"
562
+ }" . Trim ( )
563
563
, str ) ;
564
564
}
565
565
@@ -583,7 +583,7 @@ public void TestTryFault()
583
583
{
584
584
""blah"";
585
585
}
586
- }"
586
+ }" . Trim ( )
587
587
, str ) ;
588
588
}
589
589
@@ -596,7 +596,7 @@ public void TestTypeBinary()
596
596
public bool Main(object o)
597
597
{
598
598
return o is Array;
599
- }"
599
+ }" . Trim ( )
600
600
, str ) ;
601
601
}
602
602
@@ -609,7 +609,7 @@ public void TestUnary_Convert()
609
609
public int Main(double d)
610
610
{
611
611
return (int)d;
612
- }"
612
+ }" . Trim ( )
613
613
, str ) ;
614
614
}
615
615
@@ -622,7 +622,7 @@ public void TestUnary_ArrayLength()
622
622
public int Main(int[] a)
623
623
{
624
624
return a.Length;
625
- }"
625
+ }" . Trim ( )
626
626
, str ) ;
627
627
}
628
628
@@ -635,7 +635,7 @@ public void TestUnary_As()
635
635
public Expression Main(Expression expr)
636
636
{
637
637
return expr as UnaryExpression;
638
- }"
638
+ }" . Trim ( )
639
639
, str ) ;
640
640
}
641
641
@@ -659,7 +659,6 @@ public void TestToString()
659
659
Assert . AreEqual ( @"
660
660
using System;
661
661
662
-
663
662
namespace ExpressionDebugger.Tests
664
663
{
665
664
public static partial class MockClass
@@ -671,7 +670,7 @@ public static int Main()
671
670
return GetInternal1.Invoke();
672
671
}
673
672
}
674
- }"
673
+ }" . Trim ( )
675
674
, str ) ;
676
675
}
677
676
@@ -685,7 +684,73 @@ public void TestExpression()
685
684
{
686
685
Id = data.Id + ""1"",
687
686
Records = data.Records.Select<int, int>(it => it + 1)
688
- };" , str ) ;
687
+ };" . Trim ( ) , str ) ;
688
+ }
689
+
690
+ [ TestMethod ]
691
+ public void TestExtensionMethod ( )
692
+ {
693
+ var p1 = Expression . Parameter ( typeof ( int ) ) ;
694
+ var p2 = Expression . Parameter ( typeof ( int ) ) ;
695
+ var lambda = Expression . Lambda < Func < int , int , int > > (
696
+ Expression . Add ( p1 , p2 ) ,
697
+ p1 , p2 ) ;
698
+ var translator = new ExpressionTranslator ( new TypeDefinitions
699
+ {
700
+ IsStatic = true ,
701
+ Namespace = "ExpressionDebugger.Tests" ,
702
+ TypeName = "MockClass"
703
+ } ) ;
704
+ translator . VisitLambda ( lambda , ExpressionTranslator . LambdaType . ExtensionMethod , "Add" ) ;
705
+ var str = translator . ToString ( ) ;
706
+ Assert . AreEqual ( @"
707
+ namespace ExpressionDebugger.Tests
708
+ {
709
+ public static partial class MockClass
710
+ {
711
+ public static int Add(this int p1, int p2)
712
+ {
713
+ return p1 + p2;
714
+ }
715
+ }
716
+ }" . Trim ( ) , str ) ;
717
+ }
718
+
719
+ [ TestMethod ]
720
+ public void TestProperties ( )
721
+ {
722
+ var translator = new ExpressionTranslator ( new TypeDefinitions
723
+ {
724
+ IsStatic = false ,
725
+ Namespace = "ExpressionDebugger.Tests" ,
726
+ TypeName = "MockClass"
727
+ } ) ;
728
+ translator . Properties . Add ( new PropertyDefinitions
729
+ {
730
+ Name = "Prop1" ,
731
+ Type = typeof ( string )
732
+ } ) ;
733
+ translator . Properties . Add ( new PropertyDefinitions
734
+ {
735
+ Name = "Prop2" ,
736
+ Type = typeof ( string ) ,
737
+ IsReadOnly = true
738
+ } ) ;
739
+ var str = translator . ToString ( ) ;
740
+ Assert . AreEqual ( @"
741
+ namespace ExpressionDebugger.Tests
742
+ {
743
+ public partial class MockClass
744
+ {
745
+ public string Prop1 { get; set; }
746
+ public string Prop2 { get; }
747
+
748
+ public MockClass(string prop2)
749
+ {
750
+ this.Prop2 = prop2;
751
+ }
752
+ }
753
+ }" . Trim ( ) , str ) ;
689
754
}
690
755
691
756
public class Data
0 commit comments