From 9ee67d8bb7d389a5b6181ea82e16b545cf27a4d0 Mon Sep 17 00:00:00 2001 From: Stefan Jaud <59165496+pjanck@users.noreply.github.com> Date: Tue, 14 Jul 2026 11:45:10 +0200 Subject: [PATCH] Add check for abstract classes in analyzer rule Skip attribute check for abstract classes in RequireSfgGeneratorAttributeRule. Fixes #70 --- .../Analyzer/Rules/RequireSfgGeneratorAttributeRule.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SourceGenerator.Foundations/Analyzer/Rules/RequireSfgGeneratorAttributeRule.cs b/src/SourceGenerator.Foundations/Analyzer/Rules/RequireSfgGeneratorAttributeRule.cs index d4d7544..7bf32e9 100644 --- a/src/SourceGenerator.Foundations/Analyzer/Rules/RequireSfgGeneratorAttributeRule.cs +++ b/src/SourceGenerator.Foundations/Analyzer/Rules/RequireSfgGeneratorAttributeRule.cs @@ -12,6 +12,13 @@ public RequireSfgGeneratorAttributeRule() : base(CreateDescriptor()) protected override void Analyze(ClassDeclarationSyntax classDeclaration) { + if(classDeclaration.Modifiers.Any(m => m.IsKind(Microsoft.CodeAnalysis.CSharp.SyntaxKind.AbstractKeyword))) + { + // Abstract classes do not need the attribute, so we can skip this check + // Fix: https://github.com/ByronMayne/SourceGenerator.Foundations/issues/70 + return; + } + #pragma warning disable CS0618 // Type or member is obsolete if ( !HasAttribute(classDeclaration, nameof(IncrementalGeneratorAttribute)) && !HasAttribute(classDeclaration, nameof(SgfGeneratorAttribute)))