Why does "string.Format" trigger NullReferenceException warning when "String.Format does not?

With recent editions of ReSharper, calling static methods for builtin primitive types may trigger a "Possible System.NullReferenceException" if the "friendly" version of the name is used instead of the CLR version. For example, "string.Format" vs "String.Format", 'int.Parse("0")' vs 'Int32.Parse("0")'.

This seems to be tied to CodeInspection->Settings "Assume entity value can be null: When entity doesn't have explicit NotNull attribute".

I think the proper inspection setting should be "When entity doesn't ...", but either way I don't see how it is valid for changing the setting to change the analysis of "int" vs "Int32" etc.

Andrey Serebryansky

Hello Brian
     Could you please attach a small sample solution demonstrating the code that triggers 'Possible NullReferenceException' warning? Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc


"Develop with pleasure!"


Please sign in to leave a comment.