Add NotAccessibleGeneratedShaderDescriptorAttributeTargetAnalyzerBase
このコミットが含まれているのは:
1 親
d5ddf8bf1e
コミット
e85c8f870a
14ファイル変更
+182
-5
検索条件に一致するファイルはありません
@@ -60,3 +60,4 @@ CMPS0051 | ComputeSharp | Error | [Documentation](https://github.com/Sergio0694/
|
||||
CMPS0052 | ComputeSharp.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0053 | ComputeSharp.Shaders | Warning | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0054 | ComputeSharp.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0055 | ComputeSharp.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
@@ -43,6 +43,12 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener
|
||||
return default;
|
||||
}
|
||||
|
||||
// Immediately bail if the target type doesn't have internal accessibility
|
||||
if (!typeSymbol.IsAccessibleFromContainingAssembly(context.SemanticModel.Compilation))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
// Check whether type is a compute shader, and if so, if it's pixel shader like
|
||||
if (!TryGetIsPixelShaderLike(typeSymbol, context.SemanticModel.Compilation, out bool isPixelShaderLike))
|
||||
{
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ namespace ComputeSharp.SourceGenerators;
|
||||
public sealed class InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(InvalidGeneratedPixelShaderDescriptorAttributeTarget);
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(InvalidGeneratedComputeShaderDescriptorAttributeTarget);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize(AnalysisContext context)
|
||||
@@ -49,7 +49,7 @@ public sealed class InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyz
|
||||
if (!MissingComputeShaderDescriptorOnComputeShaderAnalyzer.IsComputeShaderType(typeSymbol, computeShaderSymbol, pixelShaderSymbol))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
InvalidGeneratedPixelShaderDescriptorAttributeTarget,
|
||||
InvalidGeneratedComputeShaderDescriptorAttributeTarget,
|
||||
attribute.GetLocation(),
|
||||
typeSymbol));
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using ComputeSharp.SourceGeneration.Diagnostics;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public sealed class NotAccessibleGeneratedComputeShaderDescriptorAttributeTargetAnalyzer : NotAccessibleGeneratedShaderDescriptorAttributeTargetAnalyzerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="NotAccessibleGeneratedComputeShaderDescriptorAttributeTargetAnalyzer"/> instance.
|
||||
/// </summary>
|
||||
public NotAccessibleGeneratedComputeShaderDescriptorAttributeTargetAnalyzer()
|
||||
: base(NotAccessibleTargetTypeForGeneratedComputeShaderDescriptorAttribute, "ComputeSharp.GeneratedComputeShaderDescriptorAttribute")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -759,7 +759,7 @@ partial class DiagnosticDescriptors
|
||||
/// Format: <c>"The type {0} is not a valid target for the [GeneratedComputeShaderDescriptor] attribute (only types implementing the IComputeShader or IComputeShader<TPixel> interface are valid)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidGeneratedPixelShaderDescriptorAttributeTarget = new DiagnosticDescriptor(
|
||||
public static readonly DiagnosticDescriptor InvalidGeneratedComputeShaderDescriptorAttributeTarget = new DiagnosticDescriptor(
|
||||
id: "CMPS0054",
|
||||
title: "Invalid [GeneratedComputeShaderDescriptor] attribute target",
|
||||
messageFormat: "The type {0} is not a valid target for the [GeneratedComputeShaderDescriptor] attribute (only types implementing the IComputeShader or IComputeShader<TPixel> interface are valid)",
|
||||
@@ -768,4 +768,20 @@ partial class DiagnosticDescriptors
|
||||
isEnabledByDefault: true,
|
||||
description: "The [GeneratedComputeShaderDescriptor] attribute must be used on types that implement the IComputeShader or IComputeShader<TPixel> interfaces.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for when the <c>[GeneratedComputeShaderDescriptor]</c> attribute is being used on a type that is not accessible from its containing assembly.
|
||||
/// <para>
|
||||
/// Format: <c>"The [GeneratedComputeShaderDescriptor] attribute requires target types to be accessible from their containing assembly (type {0} has less effective accessibility than internal)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor NotAccessibleTargetTypeForGeneratedComputeShaderDescriptorAttribute = new DiagnosticDescriptor(
|
||||
id: "CMPS0055",
|
||||
title: "Invalid [GeneratedComputeShaderDescriptor] attribute target",
|
||||
messageFormat: "The [GeneratedComputeShaderDescriptor] attribute requires target types to be accessible from their containing assembly (type {0} has less effective accessibility than internal)",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The [GeneratedComputeShaderDescriptor] attribute requires target types to be accessible from their containing assembly.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする