Add unit tests for new analyzer diagnostics

このコミットが含まれているのは:
Sergio Pedri committed 2024-10-17 21:41:43 -07:00
1 親 0bb328f14b
コミット afe8e1d93a
4ファイル変更
+127 -4

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

@@ -37,6 +37,12 @@ public sealed class InvalidGeneratedCanvasEffectPropertyAccessorsAnalyzer : Diag
return;
}
// Skip implementation parts to avoid duplicate errors
if (context.Symbol is IPropertySymbol { PartialDefinitionPart: not null })
{
return;
}
// If the property is using [GeneratedCanvasEffectProperty], emit the diagnostic
if (context.Symbol.TryGetAttributeWithType(generatedCanvasEffectPropertyAttributeSymbol, out AttributeData? generatedCanvasEffectPropertyAttribute))
{
@@ -32,8 +32,8 @@ public sealed class InvalidGeneratedCanvasEffectPropertyContainingTypeAnalyzer :
context.RegisterSymbolAction(context =>
{
// Validate that we have a valid containing type
if (context.Symbol is not IPropertySymbol { ContainingType: { } containingTypeSymbol })
// Validate that we have a valid containing type (also skip implementation parts)
if (context.Symbol is not IPropertySymbol { ContainingType: { } containingTypeSymbol, PartialDefinitionPart: null })
{
return;
}
@@ -37,8 +37,8 @@ public sealed class InvalidGeneratedCanvasEffectPropertyDeclarationAnalyzer : Di
context.RegisterSymbolAction(context =>
{
// Ensure that we have some target property to analyze
if (context.Symbol is not IPropertySymbol propertySymbol)
// Ensure that we have some target property to analyze (also skip implementation parts)
if (context.Symbol is not IPropertySymbol { PartialDefinitionPart: null } propertySymbol)
{
return;
}