@@ -5610,4 +5610,192 @@ public RenderFragment RenderFoo()
5610
5610
}
5611
5611
""" ) ;
5612
5612
}
5613
+
5614
+ [ FormattingTestFact ( SkipOldFormattingEngine = true ) ]
5615
+ [ WorkItem ( "https://github.com/dotnet/razor/issues/9254" ) ]
5616
+ public async Task RenderFragmentPresent ( )
5617
+ {
5618
+ await RunFormattingTestAsync (
5619
+ input : """
5620
+ @page "/"
5621
+ @code
5622
+ {
5623
+ void T()
5624
+ {
5625
+ S("first"
5626
+ + "second"
5627
+ + "third");
5628
+ }
5629
+
5630
+ string[] S(string s) =>
5631
+ s.Split(',')
5632
+ . Select(s => s.Trim())
5633
+ . ToArray();
5634
+
5635
+ RenderFragment R => @<div></div>;
5636
+ }
5637
+ """ ,
5638
+ expected : """
5639
+ @page "/"
5640
+ @code
5641
+ {
5642
+ void T()
5643
+ {
5644
+ S("first"
5645
+ + "second"
5646
+ + "third");
5647
+ }
5648
+
5649
+ string[] S(string s) =>
5650
+ s.Split(',')
5651
+ .Select(s => s.Trim())
5652
+ .ToArray();
5653
+
5654
+ RenderFragment R => @<div></div>;
5655
+ }
5656
+ """ ) ;
5657
+ }
5658
+
5659
+ [ FormattingTestFact ( SkipOldFormattingEngine = true ) ]
5660
+ [ WorkItem ( "https://github.com/dotnet/razor/issues/6150" ) ]
5661
+ public async Task RenderFragment_InLambda ( )
5662
+ {
5663
+ // Formatting result here is not necessarily perfect, but in the new engine is stable
5664
+ await RunFormattingTestAsync (
5665
+ input : """
5666
+ @page "/"
5667
+ @using RazorClassLibrary2.Models
5668
+
5669
+ @code{
5670
+ private DateTime? date1;
5671
+
5672
+ Gopt<int> gopt = new Gopt<int>()
5673
+ {
5674
+ Name = "hi"
5675
+ }
5676
+ .Editor(m =>
5677
+ {
5678
+ return
5679
+ @<text>hi</text>
5680
+ ; }
5681
+ );
5682
+ }
5683
+ """ ,
5684
+ expected : """
5685
+ @page "/"
5686
+ @using RazorClassLibrary2.Models
5687
+
5688
+ @code {
5689
+ private DateTime? date1;
5690
+
5691
+ Gopt<int> gopt = new Gopt<int>()
5692
+ {
5693
+ Name = "hi"
5694
+ }
5695
+ .Editor(m =>
5696
+ {
5697
+ return
5698
+ @<text>hi</text>
5699
+ ;
5700
+ }
5701
+ );
5702
+ }
5703
+ """ ) ;
5704
+ }
5705
+
5706
+ [ FormattingTestFact ]
5707
+ [ WorkItem ( "https://github.com/dotnet/razor/issues/9119" ) ]
5708
+ public async Task CollectionInitializers ( )
5709
+ {
5710
+ await RunFormattingTestAsync (
5711
+ input : """
5712
+ @{
5713
+ // Stable
5714
+ var formatMe = new string[] {
5715
+ "One",
5716
+ "Two",
5717
+ "Three",
5718
+ };
5719
+
5720
+ // Closing brace advances to the right
5721
+ var formatMeTwo = new string[]
5722
+ {
5723
+ "One",
5724
+ "Two",
5725
+ "Three",
5726
+ };
5727
+
5728
+ // Stable
5729
+ var formatMeThree = new List<string> {
5730
+ "One",
5731
+ "Two",
5732
+ "Three",
5733
+ };
5734
+
5735
+ // Opening brace advances to the right
5736
+ var formatMeFour = new List<string>
5737
+ {
5738
+ "One",
5739
+ "Two",
5740
+ "Three",
5741
+ };
5742
+ }
5743
+ """ ,
5744
+ expected : """
5745
+ @{
5746
+ // Stable
5747
+ var formatMe = new string[] {
5748
+ "One",
5749
+ "Two",
5750
+ "Three",
5751
+ };
5752
+
5753
+ // Closing brace advances to the right
5754
+ var formatMeTwo = new string[]
5755
+ {
5756
+ "One",
5757
+ "Two",
5758
+ "Three",
5759
+ };
5760
+
5761
+ // Stable
5762
+ var formatMeThree = new List<string> {
5763
+ "One",
5764
+ "Two",
5765
+ "Three",
5766
+ };
5767
+
5768
+ // Opening brace advances to the right
5769
+ var formatMeFour = new List<string>
5770
+ {
5771
+ "One",
5772
+ "Two",
5773
+ "Three",
5774
+ };
5775
+ }
5776
+ """ ) ;
5777
+ }
5778
+
5779
+ [ FormattingTestFact ( SkipOldFormattingEngine = true ) ]
5780
+ [ WorkItem ( "https://github.com/dotnet/razor/issues/9711" ) ]
5781
+ public async Task Directives ( )
5782
+ {
5783
+ await RunFormattingTestAsync (
5784
+ input : """
5785
+ @page "/"
5786
+
5787
+ @using System
5788
+ @inject object Foo
5789
+
5790
+
5791
+ """ ,
5792
+ expected : """
5793
+ @page "/"
5794
+
5795
+ @using System
5796
+ @inject object Foo
5797
+
5798
+
5799
+ """ ) ;
5800
+ }
5613
5801
}
0 commit comments