Skip to content

Commit

Permalink
Fix analyzers triggering on unrelated partial methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jan 6, 2024
1 parent 40874d5 commit 09b2288
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
using ComputeSharp.SourceGeneration.Extensions;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
Expand Down Expand Up @@ -42,6 +43,12 @@ public override void Initialize(AnalysisContext context)
return;
}
// Ignore methods without [D2DPixelShaderSource]
if (!methodSymbol.HasAttributeWithType(d2DPixelShaderSourceAttributeSymbol))
{
return;
}
// Emit a diagnostic if the return type is not ReadOnlySpan<byte>
if (!SymbolEqualityComparer.Default.Equals(methodSymbol.ReturnType, readOnlySpanOfByteSymbol))
{
Expand Down
Expand Up @@ -39,6 +39,12 @@ public override void Initialize(AnalysisContext context)
return;
}
// Ignore methods without [D2DPixelShaderSource]
if (!methodSymbol.HasAttributeWithType(d2DPixelShaderSourceAttributeSymbol))
{
return;
}
// Emit a diagnostic if there is no compile options available at any level
if (!methodSymbol.HasAttributeWithType(d2DCompileOptionsAttributeSymbol) &&
!methodSymbol.ContainingAssembly.HasAttributeWithType(d2DCompileOptionsAttributeSymbol))
Expand Down
Expand Up @@ -39,6 +39,12 @@ public override void Initialize(AnalysisContext context)
return;
}
// Ignore methods without [D2DPixelShaderSource]
if (!methodSymbol.HasAttributeWithType(d2DPixelShaderSourceAttributeSymbol))
{
return;
}
// Emit a diagnostic if there is no shader profile available at any level
if (!methodSymbol.HasAttributeWithType(d2DShaderProfileAttributeSymbol) &&
!methodSymbol.ContainingAssembly.HasAttributeWithType(d2DShaderProfileAttributeSymbol))
Expand Down

0 comments on commit 09b2288

Please sign in to comment.