New analyzer:
An if statement that tests an expression for null and assigns the value to a variable if not null and assigns some other value if the the expression is null can be replaced by the null coalescing operator
Before:
If A IsNot Nothing Then
C = A
Else
C = B
End If
If A IsNot Nothing Then
Return A
Else
Return B
End If
If A Is Nothing Then
C = B
Else
C = A
End If
If A Is Nothing Then
Return B
Else
Return A
End If
After:
C = If(A, B)
return If(A, B)
C = If(A, B)
return If(A, B)
Diagnostic Id: CC0119
Category: Style
Severity: Info
New analyzer:
An if statement that tests an expression for null and assigns the value to a variable if not null and assigns some other value if the the expression is null can be replaced by the null coalescing operator
Before:
After:
Diagnostic Id:
CC0119Category:
StyleSeverity:
Info