Skip to content

Commit

Permalink
Fixing issue with #if being eaten in collection expression (#1120)
Browse files Browse the repository at this point in the history
closes #1119
  • Loading branch information
belav authored Jan 15, 2024
1 parent 207353a commit 102c6e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ CallMethod(
]
);

int[] someArray =
[
1
#if DEBUG
,
2
#endif
];

int[] someArray =
[
1
#if !DEBUG
,
2
#endif
];

class MyClass
{
private readonly List<string> _items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ or ExpressionStatementSyntax
? Doc.HardLine
: Doc.IfBreak(Doc.Line, Doc.Null)
: Doc.Null,
node.CloseBracketToken.LeadingTrivia.Any(o => o.IsComment())
node.CloseBracketToken.LeadingTrivia.Any(o => o.IsComment() || o.IsDirective)
? Doc.Concat(
Doc.Indent(Token.PrintLeadingTrivia(node.CloseBracketToken, context)),
Doc.HardLine
Expand Down

0 comments on commit 102c6e5

Please sign in to comment.