Added more shader constant property diagnostics
このコミットが含まれているのは:
1 親
f8e951dd15
コミット
7c02100df1
3ファイル変更
+45
-2
検索条件に一致するファイルはありません
@@ -48,4 +48,6 @@ CMPS0040 | ComputeSharp.SourceGenerators.IComputeShaderSourceGenerator | Warning
|
||||
CMPS0041 | ComputeSharp.SourceGenerators.ShaderMethodSourceGenerator | Warning | ShaderMethodSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0042 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0043 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0044 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0044 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0045 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0046 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
@@ -620,5 +620,37 @@ namespace ComputeSharp.SourceGenerators.Diagnostics
|
||||
isEnabledByDefault: true,
|
||||
description: "A type representing a compute shader contains a constant property with an invalid declaration.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid shader constant property declaration.
|
||||
/// <para>
|
||||
/// Format: <c>"The compute shader of type {0} contains a mutable property \"{1}\" (only readonly properties are supported)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor NonReadonlyShaderPropertyDeclaration = new(
|
||||
id: "CMPS0045",
|
||||
title: "Invalid shader constant property",
|
||||
messageFormat: "The compute shader of type {0} contains a mutable property \"{1}\" (only readonly properties are supported)",
|
||||
category: typeof(IComputeShader).FullName,
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "A type representing a compute shader contains a non readonly property declaration.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid shader constant property declaration.
|
||||
/// <para>
|
||||
/// Format: <c>"The compute shader of type {0} contains an instance property \"{1}\" (only static properties are supported)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InstanceShaderPropertyDeclaration = new(
|
||||
id: "CMPS0046",
|
||||
title: "Invalid shader constant property",
|
||||
messageFormat: "The compute shader of type {0} contains an instance property \"{1}\" (only static properties are supported)",
|
||||
category: typeof(IComputeShader).FullName,
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "A type representing a compute shader contains an instance property declaration.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
}
|
||||
@@ -196,8 +196,17 @@ namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
IPropertySymbol propertySymbol = semanticModel.GetDeclaredSymbol(propertyDeclaration)!;
|
||||
|
||||
if (!propertySymbol.IsStatic || !propertySymbol.IsReadOnly)
|
||||
if (!propertySymbol.IsStatic)
|
||||
{
|
||||
context.ReportDiagnostic(InstanceShaderPropertyDeclaration, propertyDeclaration, structDeclarationSymbol, propertySymbol.Name);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!propertySymbol.IsReadOnly)
|
||||
{
|
||||
context.ReportDiagnostic(NonReadonlyShaderPropertyDeclaration, propertyDeclaration, structDeclarationSymbol, propertySymbol.Name);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする