Fix interface detection in descriptor interface analyzers
このコミットが含まれているのは:
1 親
87e7b01f7c
コミット
28a458630e
2ファイル変更
+40
-2
検索条件に一致するファイルはありません
+20
-1
@@ -47,7 +47,7 @@ public sealed class MissingPixelShaderDescriptorOnPixelShaderAnalyzer : Diagnost
|
||||
}
|
||||
|
||||
// Emit a diagnostic if the descriptor is missing for the shader type
|
||||
if (!typeSymbol.HasInterfaceWithType(d2D1PixelShaderDescriptorSymbol) &&
|
||||
if (!HasD2D1PixelShaderDescriptorInterface(typeSymbol, d2D1PixelShaderDescriptorSymbol) &&
|
||||
!typeSymbol.HasAttributeWithType(d2DGeneratedPixelShaderDescriptorAttributeSymbol))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
@@ -58,4 +58,23 @@ public sealed class MissingPixelShaderDescriptorOnPixelShaderAnalyzer : Diagnost
|
||||
}, SymbolKind.NamedType);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a given type implements the shader descriptor interface.
|
||||
/// </summary>
|
||||
/// <param name="typeSymbol">The type to check.</param>
|
||||
/// <param name="d2D1PixelShaderDescriptorSymbol">The type symbol for <c>ID2D1PixelShaderDescriptor<T></c>.</param>
|
||||
/// <returns></returns>
|
||||
private static bool HasD2D1PixelShaderDescriptorInterface(INamedTypeSymbol typeSymbol, INamedTypeSymbol d2D1PixelShaderDescriptorSymbol)
|
||||
{
|
||||
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces)
|
||||
{
|
||||
if (SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, d2D1PixelShaderDescriptorSymbol))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+20
-1
@@ -48,7 +48,7 @@ public sealed class MissingComputeShaderDescriptorOnComputeShaderAnalyzer : Diag
|
||||
}
|
||||
|
||||
// Emit a diagnostic if the descriptor is missing for the shader type
|
||||
if (!typeSymbol.HasInterfaceWithType(computeShaderDescriptorSymbol) &&
|
||||
if (!HasComputeShaderDescriptorInterface(typeSymbol, computeShaderDescriptorSymbol) &&
|
||||
!typeSymbol.HasAttributeWithType(generatedComputeShaderDescriptorAttributeSymbol))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
@@ -83,4 +83,23 @@ public sealed class MissingComputeShaderDescriptorOnComputeShaderAnalyzer : Diag
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a given type implements the shader descriptor interface.
|
||||
/// </summary>
|
||||
/// <param name="typeSymbol">The type to check.</param>
|
||||
/// <param name="computeShaderDescriptorSymbol">The type symbol for <c>IComputeShaderDescriptor<T></c>.</param>
|
||||
/// <returns></returns>
|
||||
private static bool HasComputeShaderDescriptorInterface(INamedTypeSymbol typeSymbol, INamedTypeSymbol computeShaderDescriptorSymbol)
|
||||
{
|
||||
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces)
|
||||
{
|
||||
if (SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, computeShaderDescriptorSymbol))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする