dotnet / dotnet/vblang

VB can't split long lines at .

Open
#489 28 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

In the following code I want to split long lines at "." like I can in c#. If I split the lines the same way they are split in C# I get Error BC30157 Leading '.' or '!' can only appear inside a 'With' statement.

```
Private Shared Iterator Function GenerateNewScript(ifBlock As MultiLineIfBlockSyntax) As IEnumerable(Of SyntaxNode)
Dim ifStatement As IfStatementSyntax = GenerateInvertedIfStatement(ifBlock.IfStatement)
Yield SyntaxFactory.MultiLineIfBlock(ifStatement).WithStatements(GenerateNewTrueStatement(ifBlock.ElseBlock.Statements)).WithLeadingTrivia(ifBlock.GetLeadingTrivia()).WithTrailingTrivia(ifBlock.GetTrailingTrivia()).WithAdditionalAnnotations(Formatter.Annotation)

For Each stmt As StatementSyntax In ifBlock.Statements
Yield stmt.WithAdditionalAnnotations(Formatter.Annotation)
Next
End Function
```

Desired code formatted like in C# below.

```
static IEnumerable GenerateNewScript(MultiLineIfBlockSyntax ifBlock)
{
var ifStatement = GenerateInvertedIfStatement(ifBlock.IfStatement);
yield return SyntaxFactory.MultiLineIfBlock(ifStatement)
.WithStatements(GenerateNewTrueStatement(ifBlock.ElseBlock.Statements))
.WithLeadingTrivia(ifBlock.GetLeadingTrivia())
.WithTrailingTrivia(ifBlock.GetTrailingTrivia())
.WithAdditionalAnnotations(Formatter.Annotation);

foreach (var stmt in ifBlock.Statements)
{
yield return stmt.WithAdditionalAnnotations(Formatter.Annotation);
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.