FXCop Rule for “If X = Nothing” when X is a nullable integer
Question
1 Dim x as Integer? = Nothing
2 If x = Nothing Then
3 'this is what I think will happen
4 Else
5 'this is what really happens
6 End If
The proper way to write that is "If x Is Nothing".
Is there a FXCop rule that checks for this? Or better yet, can someone show me how to write my own?
Jonathan
Solution
Another good resource for writing custom FxCop rules can be found here: binarycoder
OTHER TIPS
Your best bet to learn to write custom rules for FXCop is the forum here It involves writing an custom assembly to parse the code and check it.
Specifically you want to write a rule that says "Instead of using = nothing for a nullable type make sure you use hasvalue.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow