null
check CS-R1040 74 Foo? f = null;
75 // CS-R1040: Null check can be collapsed and written as `f?.Bar == null`.
76 // https://deepsource.io/directory/analyzers/csharp/issues/CS-R1040.
77 if (f == null || f.Bar == null) 78 {
79 //
80 }
The ?.
operator allows you to access a property or a member only if it is non-null. Consider simplifying the highlighted expression, i.e. the object and its member's null checks via the usage of this ?.
operator.
if (foo == null || foo.bar == null)
{
// ...
}
if (foo?.bar == null)
{
// ...
}