Port MissingAllowUnsafeBlocksCompilationOptionAnalyzer to ComputeSharp

このコミットが含まれているのは:
Sergio Pedri committed 2023-10-10 23:27:33 +02:00
1 親 0804b66ca2
コミット 6fc3c0d971
5ファイル変更
+63 -2

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

+6
ファイルの表示
@@ -34,6 +34,12 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
static (node, _) => node.IsTypeDeclarationWithOrPotentiallyWithBaseTypes<StructDeclarationSyntax>(),
static (context, token) =>
{
// The source generator requires unsafe blocks to be enabled (eg. for pointers, [SkipLocalsInit], etc.)
if (!context.SemanticModel.Compilation.IsAllowUnsafeBlocksEnabled())
{
return default;
}
StructDeclarationSyntax typeDeclaration = (StructDeclarationSyntax)context.Node;
// If the type symbol doesn't have at least one interface, it can't possibly be a shader type