VB.Net ByRef Code Inspection Option

I'm working with a legacy code base.

At some point in its history, developers working on the code eschewed the use of functions returning objects in favour of using extremely long sub signatures with multiple ByRef arguments as a way of providing multiple return values. The result is extremely difficult to read and reason about.

I'd like it if ReSharper were able to highlight ByRef arguments as a warning item. It would make it easier for me to find the offending code and remove it, and for the rest of the team it would hopefully provide a clear and present reminder of the dangers that ByRef poses.

Is this something that might make it into ReSharper?

If not, does anyone no of a straight forward way for me to add this behaviour?

1 comment
Comment actions Permalink

Unfortunately, there isn't anything built in to ReSharper to do this. You can create a custom plugin to do this, though. You'd need to implement a daemon stage process, as described here: http://confluence.jetbrains.com/display/NETCOM/2.04+Daemons+and+Daemon+Stages+%28R8%29

You need to look for IMethodDeclaration in the PSI source tree. From there, you can loop over the ParameterDeclarations property to give you each property declaration. Checking the parameter kind should tell you if it's value, reference or output.

0

Please sign in to leave a comment.