File tree Expand file tree Collapse file tree 5 files changed +52
-3
lines changed
src/D2L.CodeStyle.Analyzers/Async/Generator
tests/D2L.CodeStyle.Analyzers.Test/Async/Generator Expand file tree Collapse file tree 5 files changed +52
-3
lines changed Original file line number Diff line number Diff line change 1717 - uses : Brightspace/third-party-actions@actions/setup-dotnet
1818 with :
1919 dotnet-version : |
20- 7 .0.x
20+ 9 .0.x
2121
2222 - name : Build
2323 run : dotnet build -c Release
Original file line number Diff line number Diff line change 11<Project >
22 <PropertyGroup >
33 <Deterministic >true</Deterministic >
4- <LangVersion >10 .0</LangVersion >
4+ <LangVersion >12 .0</LangVersion >
55 <ImplicitUsings >true</ImplicitUsings >
66 <InvariantGlobalization >true</InvariantGlobalization >
77 <Nullable >enable</Nullable >
Original file line number Diff line number Diff line change 11{
22 "sdk" : {
3- "version" : " 7 .0.300 " ,
3+ "version" : " 9 .0.101 " ,
44 "rollForward" : " latestFeature"
55 }
66}
Original file line number Diff line number Diff line change @@ -258,6 +258,9 @@ private ExpressionSyntax Transform( ExpressionSyntax expr )
258258 . WithLeft ( Transform ( binExpr . Left ) )
259259 . WithRight ( Transform ( binExpr . Right ) ) ,
260260
261+ CollectionExpressionSyntax collectionExpr =>
262+ collectionExpr . WithElements ( Transform ( collectionExpr . Elements ) ) ,
263+
261264 ConditionalExpressionSyntax condExpr => condExpr
262265 . WithCondition ( Transform ( condExpr . Condition ) )
263266 . WithWhenTrue ( Transform ( condExpr . WhenTrue ) )
@@ -352,6 +355,17 @@ private VariableDesignationSyntax Transform( VariableDesignationSyntax des )
352355 _ => UnhandledSyntax ( des )
353356 } ;
354357
358+ private SeparatedSyntaxList < CollectionElementSyntax > Transform (
359+ SeparatedSyntaxList < CollectionElementSyntax > original
360+ ) => SyntaxFactory . SeparatedList (
361+ original . Select ( elem => elem switch {
362+ ExpressionElementSyntax ee => ee . WithExpression ( Transform ( ee . Expression ) ) ,
363+ SpreadElementSyntax sp => sp . WithExpression ( Transform ( sp . Expression ) ) ,
364+ _ => UnhandledSyntax ( elem )
365+ } ) ,
366+ original . GetSeparators ( )
367+ ) ;
368+
355369 private StatementSyntax Transform ( ExpressionStatementSyntax exprStmt ) {
356370 var result = Transform ( exprStmt . Expression ) ;
357371
Original file line number Diff line number Diff line change @@ -633,6 +633,41 @@ public void ImplicitObjectCreation() {
633633 Assert . AreEqual ( "[Blocking] T Hello() { return new( Foo() ); }" , actual . Value . ToFullString ( ) ) ;
634634 }
635635
636+ [ Test ]
637+ public void CollectionSyntax ( ) {
638+ var actual = Transform (
639+ """
640+ [GenerateSync]
641+ async Task<IEnumerable<int>> HelloAsync()
642+ => [
643+ await FooAsync(),
644+ 3,
645+ ..(await BarAsync()),
646+ 4,
647+ await XAsync() + await YAsync()
648+ ];
649+ """
650+ ) ;
651+
652+
653+ Assert . IsTrue ( actual . Success ) ;
654+ Assert . IsEmpty ( actual . Diagnostics ) ;
655+ Assert . AreEqual (
656+ """
657+ [Blocking]
658+ IEnumerable<int> Hello()
659+ => [
660+ Foo(),
661+ 3,
662+ ..(Bar()),
663+ 4,
664+ X() + Y()
665+ ];
666+ """ ,
667+ actual . Value . ToFullString ( )
668+ ) ;
669+
670+ }
636671
637672 // loosly assert that the right sorts of diagnostics came out
638673 private static void AssertDiagnostics ( IEnumerable < Diagnostic > actual , params DiagnosticDescriptor [ ] expected ) {
You can’t perform that action at this time.
0 commit comments