Skip to content

Issue/892 enter multiple scope and null#893

Merged
manfred-brands merged 2 commits intomasterfrom
issue/892_EnterMultipleScopeAndNull
Jun 15, 2025
Merged

Issue/892 enter multiple scope and null#893
manfred-brands merged 2 commits intomasterfrom
issue/892_EnterMultipleScopeAndNull

Conversation

@manfred-brands
Copy link
Copy Markdown
Member

Fixes #892

Doubled all Assert.Multiple tests to also test Assert.EnterMultipleScope by converting them to parameterized tests.
One test failed because a using statement was not traversed.
Updated code to check the statements of the using.
Added new tests where null suppressing asserts where done inside the using statement.

Copy link
Copy Markdown
Member

@mikkelbu mikkelbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @manfred-brands 👍. I've only a single question, but I'm happy to merge this when you are

ExpectedDiagnostic.Create(DereferencePossiblyNullReferenceSuppressor.SuppressionDescriptors["CS8602"]),
testCode);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we added test for "UsingBlock" and "UsingStatement" should we also add a case for "UsingDeclearation" ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The using declaration is covered by the LocalDeclarationStatementSyntax.
But the use cases there (Assert.Throw etc) are not IDisposable.

I'm not covering the Assert.EnterMultipleScope outside of a using statement.
See the conversation in #816

@manfred-brands manfred-brands merged commit 8bce842 into master Jun 15, 2025
7 checks passed
@manfred-brands manfred-brands deleted the issue/892_EnterMultipleScopeAndNull branch June 15, 2025 01:57
@mikkelbu mikkelbu added this to the Release 4.9.2 milestone Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assert.EnterMultipleScope not detecting nullability properly

2 participants