diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index 206870e5..a001c26e 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -690,7 +690,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter // // static __ctor() // { - // __this; + // __this = ()0; // // __this.__ctor__init(); // @@ -702,8 +702,9 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter .WithParameterList(processedMethod.ParameterList) .AddBodyStatements( LocalDeclarationStatement( - VariableDeclaration(IdentifierName(returnTypeHlslIdentifier)) - .AddVariables(VariableDeclarator(Identifier("__this")))), + VariableDeclaration(IdentifierName(returnTypeHlslIdentifier)).AddVariables( + VariableDeclarator(Identifier("__this")).WithInitializer(EqualsValueClause( + CastExpression(targetType, LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))))), ExpressionStatement( InvocationExpression( MemberAccessExpression(