From 659c27c0d15899d10198862655dbadb13899739b Mon Sep 17 00:00:00 2001 From: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com> Date: Tue, 14 Mar 2023 08:34:41 +0100 Subject: [PATCH] SE - Non-nullable value types: Add SizeOf tests (#6906) --- .../Roslyn/RoslynSymbolicExecutionTest.Operations.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Operations.cs b/analyzers/tests/SonarAnalyzer.UnitTest/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Operations.cs index 0d986b3572b..9c48d4f3a8b 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Operations.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Operations.cs @@ -595,6 +595,17 @@ public void InstanceReference_SetsNotNull_CS() validator.ValidateTag("This", x => x.HasConstraint(ObjectConstraint.NotNull).Should().BeTrue()); } + [TestMethod] + public void SizeOf_SetNotNullconstraint() + { + var code = """ + var size = sizeof(int); + Tag("Size", size); + """; + var validator = SETestContext.CreateCS(code).Validator; + validator.ValidateTag("Size", x => x.Should().HaveOnlyConstraint(ObjectConstraint.NotNull)); + } + [DataTestMethod] [DataRow("[ValidatedNotNull]")] [DataRow("[ValidatedNotNullAttribute]")]