Add leading trivia to all generated sources

// <auto-generated/>
このコミットが含まれているのは:
Sergio Pedri committed 2022-09-06 08:38:59 +02:00
1 親 579e9786e9
コミット fa03a6e612
4ファイル変更
+29 -16

検索条件に一致するファイルはありません

+15 -15
ファイルの表示
@@ -74,40 +74,40 @@ internal sealed partial record HierarchyInfo(string FilenameHint, string FullyQu
.AddMembers(typeDeclarationSyntax);
}
// Prepare the leading trivia for the generated compilation unit.
// This will produce code as follows:
//
// // <auto-generated/>
// #pragma warning disable
SyntaxTriviaList syntaxTriviaList = TriviaList(
Comment("// <auto-generated/>"),
Trivia(PragmaWarningDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true)));
if (Namespace is "")
{
// If there is no namespace, attach the pragma directly to the declared type,
// and skip the namespace declaration. This will produce code as follows:
//
// #pragma warning disable
//
// <SYNTAX_TRIVIA>
// <TYPE_HIERARCHY>
return
CompilationUnit().AddMembers(
typeDeclarationSyntax
.WithModifiers(TokenList(Token(
TriviaList(Trivia(PragmaWarningDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true))),
SyntaxKind.PartialKeyword,
TriviaList()))))
CompilationUnit()
.AddMembers(typeDeclarationSyntax.WithLeadingTrivia(syntaxTriviaList))
.NormalizeWhitespace(eol: "\n");
}
// Create the compilation unit with disabled warnings, target namespace and generated type.
// This will produce code as follows:
//
// #pragma warning disable
//
// <SYNTAX_TRIVIA>
// namespace <NAMESPACE>;
//
// <TYPE_HIERARCHY>
return
CompilationUnit().AddMembers(
FileScopedNamespaceDeclaration(IdentifierName(Namespace))
.AddMembers(typeDeclarationSyntax)
.WithNamespaceKeyword(Token(TriviaList(
Trivia(PragmaWarningDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true))),
SyntaxKind.NamespaceKeyword,
TriviaList())))
.WithLeadingTrivia(syntaxTriviaList)
.AddMembers(typeDeclarationSyntax))
.NormalizeWhitespace(eol: "\n");
}