Default NotNull or CanBeNull
In order to improve my static checking of code I would like to require that all methods, properties, and parameters be decorated with either a NotNull or CanBeNull attribute. Along those lines is there a way to either:
- Flag any item that doesn't have one or the other so that I can see them when working with Code Issues.
- Have one or other be assumed when neither one is applied. This would make the code cleaner when most items are one or the other as it would remove a lot of [NotNull] lines in the code. The "Assume entity value can be null:" option gets part way there, but I would like always assume NotNull instead of CanBeNull.
- Have a code format option that always adds one or the other when not present, like the option that adds "this" or "var" qualifiers.
I think that for item 1 there may be a way to do it with a custom pattern, but I couldn't quite see how to do it.
Thanks for any ideas!
Please sign in to leave a comment.
The Resharper plugin Agent Johnson supports this.
Check it out at: http://code.google.com/p/agentjohnsonplugin/
Thanks, I'll give that a try.
It doesn't do exactly what you want, but it is definitely helpful handling [NotNull] and [CanBeNull].
See also http://devnet.jetbrains.net/message/5466472#5466472
Perhaps you can post some features suggestions on Agent Johnsons forum.
For item 1, sounds like https://github.com/bkoelman/ResharperCodeContractNullability is what would help you.