Automatic annotations?

I'm evaluating how effective ReSharper is at finding potential NullReferenceExceptions in our managed code base. I've installed the 'implicit nullability' extension and disabled most code analysis options and focusing on a single file at a time. My approach thus far has been to analyze a single file, locate all of the "Annotate property ... with [CanBeNull] attribute" and "Possible 'null' assignment to entity marked with 'NotNull' attribute" violations and manually adding the [CanBeNull] attribute to the method/property.

I'll then re-run analysis to find new cases where annotations need to be added, rinse and repeat. This is a very repetitive, time-consuming process that seems ripe for automation. Before I invest time writing my own tool to help with this I'm curious if it might already exist. I'm not looking for a 100% automated solution but something that could help with the obvious cases ("This method returns null - it must need a [CanBeNull] attribute!") would represent a HUGE time savings.

 

Please sign in to leave a comment.