Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: Brightspace/third-party-actions@actions/setup-dotnet
with:
dotnet-version: |
7.0.x
9.0.x
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update for new C# 12 syntax


- name: Build
run: dotnet build -c Release
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Deterministic>true</Deterministic>
<LangVersion>10.0</LangVersion>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.300",
"version": "9.0.101",
"rollForward": "latestFeature"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ private ExpressionSyntax Transform( ExpressionSyntax expr )
.WithLeft( Transform( binExpr.Left ) )
.WithRight( Transform( binExpr.Right ) ),

CollectionExpressionSyntax collectionExpr =>
collectionExpr.WithElements( Transform( collectionExpr.Elements ) ),

ConditionalExpressionSyntax condExpr => condExpr
.WithCondition( Transform( condExpr.Condition ) )
.WithWhenTrue( Transform( condExpr.WhenTrue ) )
Expand Down Expand Up @@ -352,6 +355,17 @@ private VariableDesignationSyntax Transform( VariableDesignationSyntax des )
_ => UnhandledSyntax( des )
};

private SeparatedSyntaxList<CollectionElementSyntax> Transform(
SeparatedSyntaxList<CollectionElementSyntax> original
) => SyntaxFactory.SeparatedList(
original.Select( elem => elem switch {
ExpressionElementSyntax ee => ee.WithExpression( Transform( ee.Expression ) ),
SpreadElementSyntax sp => sp.WithExpression( Transform( sp.Expression ) ),
_ => UnhandledSyntax( elem )
} ),
Comment on lines +361 to +365
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Particular reason this isn't just original.Select( Transform ) or something, with the top-level Dispatch handling Spread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah -- what I have currently on my desktop has that, with the move to TransformAll. I'll get to it.

original.GetSeparators()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not passing the original separators for the other cases in the transformer, so perhaps something to correct later

Copy link
Member Author

@j3parker j3parker May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah -- see note below.

One other reason we're not doing it in the other ones is TransformAll supports the "maybe transform" e.g. so we can delete cancellation token arguments. There needs to be some accounting for that otherwise .GetSeparators() will possibly insert extra separators/commas, so it needs a bit more thought.

);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually part of this is already in place with the TransformAll combinator.
It doesn't do original.GetSeparators(), though.

I'll do a follow-up PR to switch to that, but also add the separators. That will incur some noise because we will have to fix up the whitespace in unrelated tests.


private StatementSyntax Transform( ExpressionStatementSyntax exprStmt ) {
var result = Transform( exprStmt.Expression );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,41 @@ public void ImplicitObjectCreation() {
Assert.AreEqual( "[Blocking] T Hello() { return new( Foo() ); }", actual.Value.ToFullString() );
}

[Test]
public void CollectionSyntax() {
var actual = Transform(
"""
[GenerateSync]
async Task<IEnumerable<int>> HelloAsync()
=> [
await FooAsync(),
3,
..(await BarAsync()),
4,
await XAsync() + await YAsync()
];
"""
);


Assert.IsTrue( actual.Success );
Assert.IsEmpty( actual.Diagnostics );
Assert.AreEqual(
"""
[Blocking]
IEnumerable<int> Hello()
=> [
Foo(),
3,
..(Bar()),
4,
X() + Y()
];
""",
actual.Value.ToFullString()
);

}

// loosly assert that the right sorts of diagnostics came out
private static void AssertDiagnostics( IEnumerable<Diagnostic> actual, params DiagnosticDescriptor[] expected ) {
Expand Down
Loading