Add leading trivia to all generated sources
// <auto-generated/>
このコミットが含まれているのは:
1 親
579e9786e9
コミット
fa03a6e612
4ファイル変更
+29
-16
検索条件に一致するファイルはありません
@@ -1,4 +1,6 @@
|
||||
global using bool2 = global::ComputeSharp.Bool2;
|
||||
// <auto-generated/>
|
||||
#pragma warning disable
|
||||
global using bool2 = global::ComputeSharp.Bool2;
|
||||
global using bool3 = global::ComputeSharp.Bool3;
|
||||
global using bool4 = global::ComputeSharp.Bool4;
|
||||
global using bool1x1 = global::ComputeSharp.Bool1x1;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,11 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator
|
||||
/// <param name="methodSourceInfo">The input <see cref="HlslMethodSourceInfo"/> instance to use.</param>
|
||||
public static CompilationUnitSyntax GetSyntax(HlslMethodSourceInfo methodSourceInfo)
|
||||
{
|
||||
// This produces an assembly attribute declaration as follows:
|
||||
//
|
||||
// // <auto-generated/>
|
||||
// #pragma warning disable
|
||||
// [assembly: global::ComputeSharp.ShaderMethodSourceAttribute(<ARGUMENTS>)]
|
||||
return
|
||||
CompilationUnit().AddAttributeLists(
|
||||
AttributeList(SingletonSeparatedList(
|
||||
@@ -184,6 +189,11 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator
|
||||
AttributeArgument(NestedArrayExpression(methodSourceInfo.DependentMethods)),
|
||||
AttributeArgument(NestedArrayExpression(methodSourceInfo.DefinedConstants)))))
|
||||
.WithOpenBracketToken(Token(TriviaList(Trivia(PragmaWarningDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true))), SyntaxKind.OpenBracketToken, TriviaList()))
|
||||
.WithOpenBracketToken(Token(TriviaList(
|
||||
Comment("// <auto-generated/>"),
|
||||
Trivia(PragmaWarningDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true))),
|
||||
SyntaxKind.OpenBracketToken,
|
||||
TriviaList()))
|
||||
.WithTarget(AttributeTargetSpecifier(Token(SyntaxKind.AssemblyKeyword))))
|
||||
.NormalizeWhitespace(eol: "\n");
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class AutoConstructorGeneratorTests
|
||||
}";
|
||||
|
||||
string expected = $@"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable
|
||||
namespace MyFancyApp.Sample;
|
||||
partial class IFoo<T>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする