Added support for static methods in shaders

このコミットが含まれているのは:
Sergio Pedri committed 2020-11-30 22:42:16 +01:00
1 親 44d854117d
コミット e57d7a9354
3ファイル変更
+68 -9

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

+19
ファイルの表示
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using ComputeSharp.SourceGenerators.Mappings;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@@ -144,5 +145,23 @@ namespace ComputeSharp.SourceGenerators.Extensions
return node;
}
/// <summary>
/// Returns a <see cref="MethodDeclarationSyntax"/> instance with no accessibility modifiers.
/// </summary>
/// <param name="node">The input <see cref="MethodDeclarationSyntax"/> node.</param>
/// <returns>A node just like <paramref name="node"/> but with no accessibility modifiers.</returns>
[Pure]
public static MethodDeclarationSyntax WithoutAccessibilityModifiers(this MethodDeclarationSyntax node)
{
return node.WithModifiers(TokenList(node.Modifiers.Where(static modifier => modifier.Kind() switch
{
SyntaxKind.PublicKeyword => false,
SyntaxKind.PrivateKeyword => false,
SyntaxKind.ProtectedKeyword => false,
SyntaxKind.InternalKeyword => false,
_ => true
}).ToArray()));
}
}
}