Added error for string literal expressions

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-18 20:48:32 +01:00
1 親 01623476ff
コミット 6653cba24f
4ファイル変更
+46 -1

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

+2 -1
ファイルの表示
@@ -39,4 +39,5 @@ CMPS0031 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator,
CMPS0032 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0033 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0034 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0035 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0035 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0036 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
+13
ファイルの表示
@@ -494,5 +494,18 @@ namespace ComputeSharp.SourceGenerators.Diagnostics
isEnabledByDefault: true,
description: "The unsafe modifier cannot be used in methods or functions used in a compute shader.",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
/// <summary>
/// Gets a <see cref="DiagnosticDescriptor"/> for a string literal.
/// </summary>
public static DiagnosticDescriptor StringLiteralExpression { get; } = new(
id: "CMPS0036",
title: "String literal expression",
messageFormat: "String literal expressions cannot be used in a compute shader",
category: typeof(IComputeShader).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "String literal expressions cannot be used in a compute shader.",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
}
}
+4
ファイルの表示
@@ -316,6 +316,10 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
return updatedNode.WithToken(Literal(updatedNode.Token.ValueText + "L", 0d));
}
}
else if (updatedNode.IsKind(SyntaxKind.StringLiteralExpression))
{
this.context.ReportDiagnostic(StringLiteralExpression, node);
}
return updatedNode;
}