Skip to content

Commit

Permalink
Fix S1104 FP: Should be ignored on classes and structs marked as [Ser…
Browse files Browse the repository at this point in the history
…ializable] (#8521)
  • Loading branch information
Tim-Pohlmann authored Jan 5, 2024
1 parent 2a9584d commit 53626ac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@
"endColumn": 73
}
}
},
{
"id": "S1104",
"message": "Make this field 'private' and encapsulate it in a 'public' property.",
"location": {
"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Persistence/SnapshotProtocol.cs#L62",
"region": {
"startLine": 62,
"startColumn": 32,
"endLine": 62,
"endColumn": 73
}
}
}
]
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ protected override void Initialize(SonarAnalysisContext context) =>
}

var parentSymbol = c.SemanticModel.GetDeclaredSymbol(fieldDeclaration.Parent);
if (parentSymbol.HasAttribute(KnownType.System_Runtime_InteropServices_StructLayoutAttribute))
if (parentSymbol.HasAttribute(KnownType.System_Runtime_InteropServices_StructLayoutAttribute)
|| parentSymbol.HasAttribute(KnownType.System_SerializableAttribute))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,12 @@ public class InteropClass
public string value; // Compliant - for interop code
}

// https://github.com/SonarSource/sonar-dotnet/issues/8504
[Serializable]
public class Repro_8504
{
public string type; // Compliant
public string key; // Compliant
public string value; // Compliant
}
}

0 comments on commit 53626ac

Please # to comment.