Skip to content

Trailing newlines #935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2022
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
5 changes: 3 additions & 2 deletions src/generators/Silk.NET.SilkTouch.Emitter/CSharpEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected override StructSymbol VisitStruct(StructSymbol structSymbol)
)
.WithKeyword(Token(SyntaxTriviaList.Empty, SyntaxKind.StructKeyword, TriviaList(Space)))
.WithOpenBraceToken(Token(TriviaList(LineFeed), SyntaxKind.OpenBraceToken, SyntaxTriviaList.Empty))
.WithCloseBraceToken(Token(TriviaList(LineFeed), SyntaxKind.CloseBraceToken, SyntaxTriviaList.Empty));
.WithCloseBraceToken(Token(TriviaList(LineFeed), SyntaxKind.CloseBraceToken, TriviaList(LineFeed)));
return structSymbol;
}

Expand Down Expand Up @@ -202,7 +202,8 @@ protected override NamespaceSymbol VisitNamespace(NamespaceSymbol namespaceSymbo
List<ExternAliasDirectiveSyntax>(), List<UsingDirectiveSyntax>(), List<MemberDeclarationSyntax>(types)
)
.WithNamespaceKeyword(Token(SyntaxTriviaList.Empty, SyntaxKind.NamespaceKeyword, TriviaList(Space)))
.WithOpenBraceToken(Token(SyntaxTriviaList.Empty, SyntaxKind.OpenBraceToken, TriviaList(LineFeed)));
.WithOpenBraceToken(Token(SyntaxTriviaList.Empty, SyntaxKind.OpenBraceToken, TriviaList(LineFeed)))
.WithCloseBraceToken(Token(SyntaxTriviaList.Empty, SyntaxKind.CloseBraceToken, TriviaList(LineFeed)));
return namespaceSymbol;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public void NamespaceIntegration()
}).ToImmutableArray()));

var result = syntax.ToFullString();
Assert.Equal("namespace Test\n{\n[StructLayout(LayoutKind.Explicit)]\npublic struct Test2\n{\n}}", result);
Assert.Equal("namespace Test\n{\n[StructLayout(LayoutKind.Explicit)]\npublic struct Test2\n{\n}\n}\n", result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void NamespaceIntegration()
var syntax = Transform(new NamespaceSymbol(new IdentifierSymbol("Test"), ImmutableArray<TypeSymbol>.Empty));

var result = syntax.ToFullString();
Assert.Equal("namespace Test\n{\n}", result);
Assert.Equal("namespace Test\n{\n}\n", result);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public struct Test
{
[FieldOffset(0)]
public int F1;
}", node.ToFullString()
}
", node.ToFullString()
);
}

Expand Down Expand Up @@ -77,7 +78,8 @@ public struct Test
public int F2;
[FieldOffset(12)]
public int F3;
}", node.ToFullString()
}
", node.ToFullString()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void IntegrationEmptyStruct()
Assert.Equal(@"[StructLayout(LayoutKind.Explicit)]
public struct Test
{
}", Transform(new StructSymbol(new IdentifierSymbol("Test"), StructLayout.Empty)).ToFullString());
}
", Transform(new StructSymbol(new IdentifierSymbol("Test"), StructLayout.Empty)).ToFullString());
}
}