Minor bug fixes to source generator body rewrite
このコミットが含まれているのは:
1 親
9a220c1ada
コミット
6548d1acb3
3ファイル変更
+38
-15
検索条件に一致するファイルはありません
@@ -11,6 +11,9 @@ namespace ComputeSharp.SourceGenerators.Extensions
|
||||
/// </summary>
|
||||
internal static class SyntaxNodeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom <see cref="SymbolDisplayFormat"/> instance with fully qualified style, without global::.
|
||||
/// </summary>
|
||||
private static readonly SymbolDisplayFormat FullyQualifiedWithoutGlobalFormat = new(
|
||||
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
|
||||
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
|
||||
@@ -60,5 +63,21 @@ namespace ComputeSharp.SourceGenerators.Extensions
|
||||
|
||||
return ParseTypeName(typeName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="MethodDeclarationSyntax"/> with a block body.
|
||||
/// </summary>
|
||||
/// <param name="node">The input <see cref="MethodDeclarationSyntax"/> node.</param>
|
||||
/// <returns>A node like the one in input, but always with a block body.</returns>
|
||||
[Pure]
|
||||
public static MethodDeclarationSyntax WithBlockBody(this MethodDeclarationSyntax node)
|
||||
{
|
||||
return node.WithBody((node.Body, node.ExpressionBody) switch
|
||||
{
|
||||
(BlockSyntax block, _) => block,
|
||||
(_, ArrowExpressionClauseSyntax arrow) => Block(ExpressionStatement(arrow.Expression)),
|
||||
_ => Block()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする