Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
"Uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/CSharpLatest/CSharpLatest/CSharp9Features/Records.cs#L109",
"Location": "Line 109 Position 15-16"
},
{
"Id": "S2094",
"Message": "Remove this empty record, write its code or make it an \u0022interface\u0022.",
"Uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/CSharpLatest/CSharpLatest/CSharp9Features/Records.cs#L130",
"Location": "Line 130 Position 15-16"
},
{
"Id": "S2094",
"Message": "Remove this empty record, write its code or make it an \u0022interface\u0022.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override bool IsEmptyAndNotPartial(SyntaxNode node) =>
&& (node is ClassDeclarationSyntax || IsParameterlessRecord(node));

protected override BaseTypeDeclarationSyntax GetIfHasDeclaredBaseClassOrInterface(SyntaxNode node) =>
node is ClassDeclarationSyntax { BaseList: not null } declaration
node is TypeDeclarationSyntax { BaseList: not null } declaration
? declaration
: null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ private static bool ShouldIgnoreType(TDeclarationSyntax node, SemanticModel mode
model.GetDeclaredSymbol(node) is INamedTypeSymbol classSymbol
&& (classSymbol.BaseType is { IsAbstract: true }
|| classSymbol.DerivesFromAny(BaseClassesToIgnore)
|| classSymbol.Interfaces.Any());
|| classSymbol.Interfaces.Any(x => !x.Is(KnownType.System_IEquatable_T))); // every record type implicitly implements System.IEquatable<T>
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ namespace Ignore
partial record EmptyPartialRecord(); // Compliant - partial classes are ignored, so partial record classes are ignored as well
}

// https://github.com/SonarSource/sonar-dotnet/issues/7709
namespace Repro_7709
{
interface IMarker { }
record ImplementsMarker : IMarker { }
record ImplementsEmptyRecordAndMarker : Noncompliant.EmptyRecord, IMarker { }
}