/// <inheritdoc/> public override SyntaxNode?VisitLiteralExpression(LiteralExpressionSyntax node) { var updatedNode = (LiteralExpressionSyntax)base.VisitLiteralExpression(node) !; if (updatedNode.IsKind(SyntaxKind.DefaultLiteralExpression)) { TypeSyntax type = node.TrackType(SemanticModel.For(node), DiscoveredTypes); // 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 && operation.Type is INamedTypeSymbol type) { // If the expression is a literal floating point value, we need to ensure the proper suffixes are // used in the HLSL representation. Floating point values accept either f or F, but they don't work // when the literal doesn't contain a decimal point. Since 32 bit floating point values are the default // in HLSL, we can remove the suffix entirely. As for 64 bit values, we simply use the 'L' suffix. if (type.GetFullMetadataName().Equals(typeof(float).FullName)) { string literal = updatedNode.Token.ValueText; if (!literal.Contains('.')) { literal += ".0"; } return(updatedNode.WithToken(Literal(literal, 0f))); } else if (type.GetFullMetadataName().Equals(typeof(double).FullName)) { return(updatedNode.WithToken(Literal(updatedNode.Token.ValueText + "L", 0d))); } }