Possible 'null' assignment to entity with '[NotNull]' attribute even when null check is explicitly specified (dynamic type)
Consider the following code (this is not production code, just used for demonstration):
Snippet
private void Test()
{
dynamic selection = ExcelApp.Selection;
if (selection != null && Marshal.IsComObject(selection))
Marshal.ReleaseComObject(selection);
}
The selection variable in the last line is flagged for possible null.
I assume the problem is because the variable is a dynamic one. Nonetheless I can't see why R# complains about it.
(R# 2017.1.1, VS2017 Enterprise 15.1 26403.7)
Please sign in to leave a comment.
This behavior will be changed in next release. Details: https://youtrack.jetbrains.com/issue/RSRP-462444