diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs
index dc3838d8..e6c8dc8b 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs
@@ -87,6 +87,7 @@ partial class D2DPixelShaderDescriptorGenerator
structDeclarationSymbol,
discoveredTypes,
constantDefinitions,
+ token,
out bool fieldsNeedD2D1RequiresScenePosition);
token.ThrowIfCancellationRequested();
@@ -234,6 +235,7 @@ partial class D2DPixelShaderDescriptorGenerator
/// The type symbol for the shader type.
/// The collection of currently discovered types.
/// The collection of discovered constant definitions.
+ /// The used to cancel the operation, if needed.
/// Whether or not the shader needs the [D2DRequiresScenePosition] annotation.
/// A sequence of static constant fields in .
private static ImmutableArray<(string Name, string TypeDeclaration, string? Assignment)> GetStaticFields(
@@ -242,6 +244,7 @@ partial class D2DPixelShaderDescriptorGenerator
INamedTypeSymbol structDeclarationSymbol,
ICollection discoveredTypes,
IDictionary constantDefinitions,
+ CancellationToken token,
out bool needsD2D1RequiresScenePosition)
{
using ImmutableArrayBuilder<(string, string, string?)> builder = new();
@@ -251,12 +254,12 @@ partial class D2DPixelShaderDescriptorGenerator
foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers())
{
// Find all declared static fields in the type
- if (memberSymbol is not IFieldSymbol { IsImplicitlyDeclared: false, IsStatic: true, IsConst: false, DeclaringSyntaxReferences: [SyntaxReference fieldReference, ..] } fieldSymbol)
+ if (memberSymbol is not IFieldSymbol { IsImplicitlyDeclared: false, IsStatic: true, IsConst: false, } fieldSymbol)
{
continue;
}
- if (fieldReference.GetSyntax() is not VariableDeclaratorSyntax variableDeclarator)
+ if (!fieldSymbol.TryGetSyntaxNode(token, out VariableDeclaratorSyntax? variableDeclarator))
{
continue;
}
@@ -326,12 +329,12 @@ partial class D2DPixelShaderDescriptorGenerator
foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers())
{
// Find all declared methods in the type
- if (memberSymbol is not IMethodSymbol { IsImplicitlyDeclared: false, DeclaringSyntaxReferences: [SyntaxReference methodReference, ..] } methodSymbol)
+ if (memberSymbol is not IMethodSymbol { IsImplicitlyDeclared: false, } methodSymbol)
{
continue;
}
- if (methodReference.GetSyntax() is not MethodDeclarationSyntax methodDeclaration)
+ if (!methodSymbol.TryGetSyntaxNode(token, out MethodDeclarationSyntax? methodDeclaration))
{
continue;
}
diff --git a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs
index 1c346c43..0ee84697 100644
--- a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs
+++ b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs
@@ -102,7 +102,8 @@ partial class ComputeShaderDescriptorGenerator
semanticModelProvider,
structDeclarationSymbol,
discoveredTypes,
- constantDefinitions);
+ constantDefinitions,
+ token);
token.ThrowIfCancellationRequested();
@@ -247,25 +248,27 @@ partial class ComputeShaderDescriptorGenerator
/// The type symbol for the shader type.
/// The collection of currently discovered types.
/// The collection of discovered constant definitions.
+ /// The used to cancel the operation, if needed.
/// A sequence of static constant fields in .
private static ImmutableArray<(string Name, string TypeDeclaration, string? Assignment)> GetStaticFields(
ImmutableArrayBuilder diagnostics,
SemanticModelProvider semanticModel,
INamedTypeSymbol structDeclarationSymbol,
ICollection discoveredTypes,
- IDictionary constantDefinitions)
+ IDictionary constantDefinitions,
+ CancellationToken token)
{
using ImmutableArrayBuilder<(string, string, string?)> builder = new();
foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers())
{
// Find all declared static fields in the type
- if (memberSymbol is not IFieldSymbol { IsImplicitlyDeclared: false, IsStatic: true, IsConst: false, DeclaringSyntaxReferences: [SyntaxReference fieldReference, ..] } fieldSymbol)
+ if (memberSymbol is not IFieldSymbol { IsImplicitlyDeclared: false, IsStatic: true, IsConst: false, } fieldSymbol)
{
continue;
}
- if (fieldReference.GetSyntax() is not VariableDeclaratorSyntax variableDeclarator)
+ if (!fieldSymbol.TryGetSyntaxNode(token, out VariableDeclaratorSyntax? variableDeclarator))
{
continue;
}
@@ -379,12 +382,12 @@ partial class ComputeShaderDescriptorGenerator
foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers())
{
// Find all declared methods in the type
- if (memberSymbol is not IMethodSymbol { IsImplicitlyDeclared: false, DeclaringSyntaxReferences: [SyntaxReference methodReference, ..] } methodSymbol)
+ if (memberSymbol is not IMethodSymbol { IsImplicitlyDeclared: false, } methodSymbol)
{
continue;
}
- if (methodReference.GetSyntax() is not MethodDeclarationSyntax methodDeclaration)
+ if (!methodSymbol.TryGetSyntaxNode(token, out MethodDeclarationSyntax? methodDeclaration))
{
continue;
}