diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems b/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems
index 377f6561..b3e8892c 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems
@@ -30,6 +30,7 @@
+
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/SyntaxNodeExtensions.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/SyntaxNodeExtensions.cs
index 8ce10059..fa7b4db0 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/SyntaxNodeExtensions.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/SyntaxNodeExtensions.cs
@@ -1,6 +1,4 @@
-using System.Collections.Generic;
using System.Linq;
-using ComputeSharp.SourceGeneration.Mappings;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -39,91 +37,6 @@ internal static class SyntaxNodeExtensions
return typeDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword);
}
- ///
- /// Checks a value and replaces the value type to be HLSL compatible, if needed.
- ///
- /// The type of the input instance.
- /// The input to check and modify if needed.
- /// The source to use to get type into from .
- /// The instance with info on the input tree.
- /// The collection of currently discovered types.
- /// A instance that represents a type compatible with HLSL.
- public static TRoot ReplaceAndTrackType(this TRoot node, SyntaxNode sourceType, SemanticModel semanticModel, ICollection discoveredTypes)
- where TRoot : TypeSyntax
- {
- return node.ReplaceAndTrackType(node, sourceType, semanticModel, discoveredTypes);
- }
-
- ///
- /// Checks a value and replaces the value type to be HLSL compatible, if needed.
- ///
- /// The type of the input instance.
- /// The input to check and modify if needed.
- /// The target node to replace.
- /// The source to use to get type into from .
- /// The instance with info on the input tree.
- /// The collection of currently discovered types.
- /// A instance that represents a type compatible with HLSL.
- public static TRoot ReplaceAndTrackType(this TRoot node, TypeSyntax targetType, SyntaxNode sourceType, SemanticModel semanticModel, ICollection discoveredTypes)
- where TRoot : SyntaxNode
- {
- // Skip immediately for function pointers
- if (sourceType is FunctionPointerTypeSyntax)
- {
- return node.ReplaceNode(targetType, ParseTypeName("void*"));
- }
-
- // Handle the various possible type kinds
- ITypeSymbol typeSymbol = sourceType switch
- {
- RefTypeSyntax refType => semanticModel.GetTypeInfo(refType.Type).Type!,
- PointerTypeSyntax pointerType => semanticModel.GetTypeInfo(pointerType.ElementType).Type!,
- ArrayTypeSyntax arrayType => semanticModel.GetTypeInfo(arrayType.ElementType).Type!,
- _ => semanticModel.GetTypeInfo(sourceType).Type!
- };
-
- // Do nothing if the type is just void
- if (typeSymbol.SpecialType == SpecialType.System_Void)
- {
- return node;
- }
-
- string typeName = typeSymbol.GetFullyQualifiedName();
-
- discoveredTypes.Add((INamedTypeSymbol)typeSymbol);
-
- if (HlslKnownTypes.TryGetMappedName(typeName, out string? mappedName))
- {
- TypeSyntax newType = ParseTypeName(mappedName!);
-
- return node.ReplaceNode(targetType, newType);
- }
-
- return node.ReplaceNode(targetType, ParseTypeName(typeName.ToHlslIdentifierName()));
- }
-
- ///
- /// Tracks the associated type for a value and returns the HLSL compatible .
- ///
- /// The input to check.
- /// The instance with info on the input tree.
- /// The collection of currently discovered types.
- /// A instance that represents a type compatible with HLSL.
- public static TypeSyntax TrackType(this SyntaxNode node, SemanticModel semanticModel, ICollection discoveredTypes)
- {
- ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(node).Type!;
- string typeName = typeSymbol.GetFullyQualifiedName();
-
- discoveredTypes.Add((INamedTypeSymbol)typeSymbol);
-
- if (HlslKnownTypes.TryGetMappedName(typeName, out string? mappedName))
- {
- return ParseTypeName(mappedName!);
- }
-
- return ParseTypeName(typeName.ToHlslIdentifierName());
- }
-
///
/// Returns a with a block body.
///
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Tracking.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Tracking.cs
new file mode 100644
index 00000000..1c197f57
--- /dev/null
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Tracking.cs
@@ -0,0 +1,93 @@
+using ComputeSharp.SourceGeneration.Extensions;
+using ComputeSharp.SourceGeneration.Mappings;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
+
+namespace ComputeSharp.SourceGeneration.SyntaxRewriters;
+
+///
+partial class HlslSourceRewriter
+{
+ ///
+ /// Tracks the associated type for a value and returns the HLSL compatible .
+ ///
+ /// The input to check.
+ /// The instance with info on the input tree.
+ /// A instance that represents a type compatible with HLSL.
+ protected TypeSyntax TrackType(SyntaxNode node, SemanticModel semanticModel)
+ {
+ ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(node, CancellationToken).Type!;
+ string typeName = typeSymbol.GetFullyQualifiedName();
+
+ DiscoveredTypes.Add((INamedTypeSymbol)typeSymbol);
+
+ if (HlslKnownTypes.TryGetMappedName(typeName, out string? mappedName))
+ {
+ return ParseTypeName(mappedName!);
+ }
+
+ return ParseTypeName(typeName.ToHlslIdentifierName());
+ }
+
+ ///
+ /// Checks a value and replaces the value type to be HLSL compatible, if needed.
+ ///
+ /// The type of the input instance.
+ /// The input to check and modify if needed.
+ /// The source to use to get type into from .
+ /// The instance with info on the input tree.
+ /// A instance that represents a type compatible with HLSL.
+ protected TRoot ReplaceAndTrackType(TRoot node, SyntaxNode sourceType, SemanticModel semanticModel)
+ where TRoot : TypeSyntax
+ {
+ return ReplaceAndTrackType(node, node, sourceType, semanticModel);
+ }
+
+ ///
+ /// Checks a value and replaces the value type to be HLSL compatible, if needed.
+ ///
+ /// The type of the input instance.
+ /// The input to check and modify if needed.
+ /// The target node to replace.
+ /// The source to use to get type into from .
+ /// The instance with info on the input tree.
+ /// A instance that represents a type compatible with HLSL.
+ protected TRoot ReplaceAndTrackType(TRoot node, TypeSyntax targetType, SyntaxNode sourceType, SemanticModel semanticModel)
+ where TRoot : SyntaxNode
+ {
+ // Skip immediately for function pointers
+ if (sourceType is FunctionPointerTypeSyntax)
+ {
+ return node.ReplaceNode(targetType, ParseTypeName("void*"));
+ }
+
+ // Handle the various possible type kinds
+ ITypeSymbol typeSymbol = sourceType switch
+ {
+ RefTypeSyntax refType => semanticModel.GetTypeInfo(refType.Type, CancellationToken).Type!,
+ PointerTypeSyntax pointerType => semanticModel.GetTypeInfo(pointerType.ElementType, CancellationToken).Type!,
+ ArrayTypeSyntax arrayType => semanticModel.GetTypeInfo(arrayType.ElementType, CancellationToken).Type!,
+ _ => semanticModel.GetTypeInfo(sourceType, CancellationToken).Type!
+ };
+
+ // Do nothing if the type is just void
+ if (typeSymbol.SpecialType == SpecialType.System_Void)
+ {
+ return node;
+ }
+
+ string typeName = typeSymbol.GetFullyQualifiedName();
+
+ DiscoveredTypes.Add((INamedTypeSymbol)typeSymbol);
+
+ if (HlslKnownTypes.TryGetMappedName(typeName, out string? mappedName))
+ {
+ TypeSyntax newType = ParseTypeName(mappedName!);
+
+ return node.ReplaceNode(targetType, newType);
+ }
+
+ return node.ReplaceNode(targetType, ParseTypeName(typeName.ToHlslIdentifierName()));
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
index e035e44a..f1248359 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
@@ -87,7 +87,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
CastExpressionSyntax updatedNode = (CastExpressionSyntax)base.VisitCastExpression(node)!;
- return updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
+ return ReplaceAndTrackType(updatedNode, updatedNode.Type, node.Type, SemanticModel.For(node));
}
///
@@ -95,7 +95,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
VariableDeclarationSyntax updatedNode = (VariableDeclarationSyntax)base.VisitVariableDeclaration(node)!;
- if (SemanticModel.For(node).GetTypeInfo(node.Type).Type is ITypeSymbol { IsUnmanagedType: false } type)
+ if (SemanticModel.For(node).GetTypeInfo(node.Type, CancellationToken).Type is ITypeSymbol { IsUnmanagedType: false } type)
{
Diagnostics.Add(InvalidObjectDeclaration, node, type);
}
@@ -103,7 +103,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
// If var is used, replace it with the explicit type
if (updatedNode.Type is IdentifierNameSyntax { IsVar: true })
{
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.Type, node.Type, SemanticModel.For(node));
}
return updatedNode;
@@ -114,7 +114,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
ObjectCreationExpressionSyntax updatedNode = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node)!;
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.Type, node, SemanticModel.For(node));
return VisitObjectCreationExpression(node, updatedNode, updatedNode.Type);
}
@@ -123,7 +123,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
public sealed override SyntaxNode VisitImplicitObjectCreationExpression(ImplicitObjectCreationExpressionSyntax node)
{
ImplicitObjectCreationExpressionSyntax updatedNode = (ImplicitObjectCreationExpressionSyntax)base.VisitImplicitObjectCreationExpression(node)!;
- TypeSyntax explicitType = IdentifierName("").ReplaceAndTrackType(node, SemanticModel.For(node), DiscoveredTypes);
+ TypeSyntax explicitType = ReplaceAndTrackType(IdentifierName(""), node, SemanticModel.For(node));
return VisitObjectCreationExpression(node, updatedNode, explicitType);
}
@@ -137,7 +137,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
CancellationToken.ThrowIfCancellationRequested();
- ITypeSymbol? typeSymbol = SemanticModel.For(node).GetTypeInfo(node).Type;
+ ITypeSymbol? typeSymbol = SemanticModel.For(node).GetTypeInfo(node, CancellationToken).Type;
// Handle the edge case of the type being null (shouldn't really happen)
if (typeSymbol is null)
@@ -180,7 +180,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
for (int i = 0; i < node.ArgumentList!.Arguments.Count; i++)
{
- IArgumentOperation argumentOperation = (IArgumentOperation)SemanticModel.For(node).GetOperation(node.ArgumentList.Arguments[i])!;
+ IArgumentOperation argumentOperation = (IArgumentOperation)SemanticModel.For(node).GetOperation(node.ArgumentList.Arguments[i], CancellationToken)!;
INamedTypeSymbol elementType = (INamedTypeSymbol)argumentOperation.Parameter!.Type;
updatedNode = updatedNode.ReplaceNode(
@@ -202,7 +202,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
DefaultExpressionSyntax updatedNode = (DefaultExpressionSyntax)base.VisitDefaultExpression(node)!;
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.Type, node.Type, SemanticModel.For(node));
// A default expression becomes (T)0 in HLSL
return CastExpression(updatedNode.Type, LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)));
@@ -217,13 +217,13 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
if (updatedNode.IsKind(SyntaxKind.DefaultLiteralExpression))
{
- TypeSyntax type = node.TrackType(SemanticModel.For(node), DiscoveredTypes);
+ TypeSyntax type = TrackType(node, SemanticModel.For(node));
// Same HLSL-style expression in the form (T)0
return CastExpression(type, LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)));
}
else if (updatedNode.IsKind(SyntaxKind.NumericLiteralExpression) &&
- SemanticModel.For(node).GetOperation(node) is ILiteralOperation operation &&
+ SemanticModel.For(node).GetOperation(node, CancellationToken) is ILiteralOperation operation &&
operation.Type is INamedTypeSymbol type)
{
// If the expression is a literal floating point value, we need to ensure the proper suffixes are
@@ -275,7 +275,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
ElementAccessExpressionSyntax updatedNode = (ElementAccessExpressionSyntax)base.VisitElementAccessExpression(node)!;
- if (SemanticModel.For(node).GetOperation(node) is IPropertyReferenceOperation operation)
+ if (SemanticModel.For(node).GetOperation(node, CancellationToken) is IPropertyReferenceOperation operation)
{
string propertyName = operation.Property.GetFullyQualifiedMetadataName();
@@ -298,7 +298,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
// This prepares all the individual parts to combine into the HLSL property name when rewriting.
foreach (ArgumentSyntax argument in node.ArgumentList.Arguments)
{
- if (SemanticModel.For(node).GetOperation(argument.Expression) is not IFieldReferenceOperation fieldReference ||
+ if (SemanticModel.For(node).GetOperation(argument.Expression, CancellationToken) is not IFieldReferenceOperation fieldReference ||
!HlslKnownProperties.IsKnownMatrixIndex(fieldReference.Field.GetFullyQualifiedMetadataName()))
{
Diagnostics.Add(NonConstantMatrixSwizzledIndex, argument);
@@ -340,7 +340,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
AssignmentExpressionSyntax updatedNode = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(node)!;
- if (SemanticModel.For(node).GetOperation(node) is ICompoundAssignmentOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
+ if (SemanticModel.For(node).GetOperation(node, CancellationToken) is ICompoundAssignmentOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
{
// If the compound assignment is using an HLSL operator, replace the expression with an invocation and assignment.
// That is, do the following transformation:
@@ -370,7 +370,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
BinaryExpressionSyntax updatedNode = (BinaryExpressionSyntax)base.VisitBinaryExpression(node)!;
// Process binary operations to see if the target operator method is an intrinsic
- if (SemanticModel.For(node).GetOperation(node) is IBinaryOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
+ if (SemanticModel.For(node).GetOperation(node, CancellationToken) is IBinaryOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
{
// If the operator is indeed an HLSL overload, replace the expression with an invocation.
// That is, do the following transformation:
@@ -398,7 +398,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
// and member access expressions, as those will be handled separately. Doing so avoids unnecessarily
// retrieving semantic information for every identifier, which would otherwise be fairly expensive.
if (node.Parent is not (InvocationExpressionSyntax or MemberAccessExpressionSyntax) &&
- SemanticModel.For(node).GetOperation(node) is IFieldReferenceOperation operation &&
+ SemanticModel.For(node).GetOperation(node, CancellationToken) is IFieldReferenceOperation operation &&
operation.Field.IsConst &&
operation.Type!.TypeKind != TypeKind.Enum)
{
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs
index 30ccf728..d0e378ad 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs
@@ -140,7 +140,7 @@ internal sealed partial class ShaderSourceRewriter(
MethodDeclarationSyntax? updatedNode = (MethodDeclarationSyntax?)base.Visit(node)!;
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node));
if (node!.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)))
{
@@ -175,7 +175,7 @@ internal sealed partial class ShaderSourceRewriter(
LocalFunctionStatementSyntax? updatedNode = (LocalFunctionStatementSyntax?)base.Visit(node)!;
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node));
if (node!.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)))
{
@@ -229,10 +229,10 @@ internal sealed partial class ShaderSourceRewriter(
ExitLoop:
- return updatedNode
- .WithAttributeLists(default)
- .ReplaceAndTrackType(updatedNode.Type!, node.Type!, SemanticModel.For(node), DiscoveredTypes)
- .WithModifiers(TokenList(modifier));
+ updatedNode = updatedNode.WithAttributeLists(default);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.Type!, node.Type!, SemanticModel.For(node));
+
+ return updatedNode.WithModifiers(TokenList(modifier));
}
///
@@ -240,12 +240,12 @@ internal sealed partial class ShaderSourceRewriter(
{
LocalDeclarationStatementSyntax updatedNode = (LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!;
- if (SemanticModel.For(node).GetOperation(node) is IOperation { Kind: OperationKind.UsingDeclaration })
+ if (SemanticModel.For(node).GetOperation(node, CancellationToken) is IOperation { Kind: OperationKind.UsingDeclaration })
{
Diagnostics.Add(UsingStatementOrDeclaration, node);
}
- return updatedNode.ReplaceAndTrackType(updatedNode.Declaration.Type, node.Declaration.Type, SemanticModel.For(node), DiscoveredTypes);
+ return ReplaceAndTrackType(updatedNode, updatedNode.Declaration.Type, node.Declaration.Type, SemanticModel.For(node));
}
///
@@ -253,7 +253,7 @@ internal sealed partial class ShaderSourceRewriter(
{
DeclarationExpressionSyntax updatedNode = (DeclarationExpressionSyntax)base.VisitDeclarationExpression(node)!;
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.Type, node.Type, SemanticModel.For(node));
// Add the variable to the list of implicit declarations
this.implicitVariables.Add(VariableDeclaration(updatedNode.Type).AddVariables(VariableDeclarator(updatedNode.Designation.ToString())));
@@ -286,7 +286,7 @@ internal sealed partial class ShaderSourceRewriter(
.WithBlockBody()
.WithAttributeLists(List());
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node));
if (node.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)))
{
@@ -310,7 +310,7 @@ internal sealed partial class ShaderSourceRewriter(
.WithAttributeLists(List())
.WithIdentifier(Identifier($"__{this.currentMethodIdentifier.Text}__{node.Identifier.Text}"));
- updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes);
+ updatedNode = ReplaceAndTrackType(updatedNode, updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node));
if (node.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)))
{
@@ -345,7 +345,7 @@ internal sealed partial class ShaderSourceRewriter(
// We also only process fields from external types, as those in shader types don't need handling here.
// This is because they're lowered to the same identifier name, without fully qualified names to rewrite.
if (node.Parent is not (InvocationExpressionSyntax or MemberAccessExpressionSyntax) &&
- SemanticModel.For(node).GetOperation(node) is IFieldReferenceOperation { Field.IsStatic: true } operation &&
+ SemanticModel.For(node).GetOperation(node, CancellationToken) is IFieldReferenceOperation { Field.IsStatic: true } operation &&
!SymbolEqualityComparer.Default.Equals(operation.Field.ContainingType, this.shaderType))
{
return VisitExternalStaticFieldAccess(null, operation.Field) ?? base.VisitIdentifierName(node);
@@ -362,7 +362,7 @@ internal sealed partial class ShaderSourceRewriter(
MemberAccessExpressionSyntax updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!;
if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression) &&
- SemanticModel.For(node).GetOperation(node) is IMemberReferenceOperation operation)
+ SemanticModel.For(node).GetOperation(node, CancellationToken) is IMemberReferenceOperation operation)
{
if (operation is IFieldReferenceOperation fieldOperation)
{
@@ -438,7 +438,7 @@ internal sealed partial class ShaderSourceRewriter(
if (!this.staticMethods.TryGetValue(key, out MethodDeclarationSyntax? methodSyntax))
{
- INamedTypeSymbol resourceType = (INamedTypeSymbol)SemanticModel.For(node).GetTypeInfo(node.Expression).Type!;
+ INamedTypeSymbol resourceType = (INamedTypeSymbol)SemanticModel.For(node).GetTypeInfo(node.Expression, CancellationToken).Type!;
string resourceName = HlslKnownTypes.GetMappedName(resourceType);
// Create a static method to get a specified dimension for a target resource type.
@@ -488,7 +488,7 @@ internal sealed partial class ShaderSourceRewriter(
InvocationExpressionSyntax updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!;
- if (SemanticModel.For(node).GetOperation(node) is IInvocationOperation { TargetMethod: IMethodSymbol method } operation)
+ if (SemanticModel.For(node).GetOperation(node, CancellationToken) is IInvocationOperation { TargetMethod: IMethodSymbol method } operation)
{
if (method.IsStatic)
{
@@ -625,7 +625,7 @@ internal sealed partial class ShaderSourceRewriter(
updatedNode = updatedNode.WithRefKindKeyword(Token(SyntaxKind.None));
// Track and rewrite the discarded declaration
- if (SemanticModel.For(node).GetOperation(node.Expression) is IDiscardOperation operation)
+ if (SemanticModel.For(node).GetOperation(node.Expression, CancellationToken) is IDiscardOperation operation)
{
TypeSyntax typeSyntax = ParseTypeName(HlslKnownTypes.TrackType(operation.Type!, DiscoveredTypes));
string identifier = $"__implicit{this.implicitVariables.Count}";
@@ -645,7 +645,7 @@ internal sealed partial class ShaderSourceRewriter(
BaseObjectCreationExpressionSyntax updatedNode,
TypeSyntax targetType)
{
- if (SemanticModel.For(node).GetOperation(node) is IObjectCreationOperation { Constructor: IMethodSymbol constructor, Type: INamedTypeSymbol { TypeKind: TypeKind.Struct } typeSymbol })
+ if (SemanticModel.For(node).GetOperation(node, CancellationToken) is IObjectCreationOperation { Constructor: IMethodSymbol constructor, Type: INamedTypeSymbol { TypeKind: TypeKind.Struct } typeSymbol })
{
DiscoveredTypes.Add(typeSymbol);
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs
index 11b3cc55..a9515f21 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs
@@ -54,7 +54,7 @@ internal sealed partial class StaticFieldRewriter(
MemberAccessExpressionSyntax updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!;
if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression) &&
- SemanticModel.For(node).GetOperation(node) is IMemberReferenceOperation operation)
+ SemanticModel.For(node).GetOperation(node, CancellationToken) is IMemberReferenceOperation operation)
{
// Track and replace constants
if (operation is IFieldReferenceOperation fieldOperation &&
@@ -96,7 +96,7 @@ internal sealed partial class StaticFieldRewriter(
{
InvocationExpressionSyntax updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!;
- if (SemanticModel.For(node).GetOperation(node) is IInvocationOperation operation &&
+ if (SemanticModel.For(node).GetOperation(node, CancellationToken) is IInvocationOperation operation &&
operation.TargetMethod is IMethodSymbol method &&
method.IsStatic)
{