diff --git a/analyzers/tests/SonarAnalyzer.Test/Rules/FieldsShouldBeEncapsulatedInPropertiesTest.cs b/analyzers/tests/SonarAnalyzer.Test/Rules/FieldsShouldBeEncapsulatedInPropertiesTest.cs index 2ea5343b4e6..cd3d09c5130 100644 --- a/analyzers/tests/SonarAnalyzer.Test/Rules/FieldsShouldBeEncapsulatedInPropertiesTest.cs +++ b/analyzers/tests/SonarAnalyzer.Test/Rules/FieldsShouldBeEncapsulatedInPropertiesTest.cs @@ -36,7 +36,7 @@ public void FieldsShouldBeEncapsulatedInProperties_Unity3D_Ignored() => builder.AddPaths("FieldsShouldBeEncapsulatedInProperties.Unity3D.cs") // Concurrent analysis puts fake Unity3D class into the Concurrent namespace .WithConcurrentAnalysis(false) - .VerifyNoIssues(); + .Verify(); #if NET diff --git a/analyzers/tests/SonarAnalyzer.Test/TestCases/FieldsShouldBeEncapsulatedInProperties.Unity3D.cs b/analyzers/tests/SonarAnalyzer.Test/TestCases/FieldsShouldBeEncapsulatedInProperties.Unity3D.cs index 16643e10c11..4d1d0544c48 100644 --- a/analyzers/tests/SonarAnalyzer.Test/TestCases/FieldsShouldBeEncapsulatedInProperties.Unity3D.cs +++ b/analyzers/tests/SonarAnalyzer.Test/TestCases/FieldsShouldBeEncapsulatedInProperties.Unity3D.cs @@ -1,4 +1,6 @@ -// https://github.com/SonarSource/sonar-dotnet/issues/7522 +using System; + +// https://github.com/SonarSource/sonar-dotnet/issues/7522 public class UnityMonoBehaviour : UnityEngine.MonoBehaviour { public int Field1; // Compliant @@ -9,10 +11,22 @@ public class UnityScriptableObject : UnityEngine.ScriptableObject public int Field1; // Compliant } +public class InvalidCustomSerializableClass1 : UnityEngine.Object +{ + public int Field1; // Noncompliant +} + +[Serializable] +public class ValidCustomSerializableClass : UnityEngine.Object +{ + public int Field1; // Compliant +} + // Unity3D does not seem to be available as a nuget package and we cannot use the original classes // Cannot run this test case in Concurrent mode because of the Concurrent namespace namespace UnityEngine { public class MonoBehaviour { } public class ScriptableObject { } + public class Object { } }