Suggested features

It would be great if R# could generate checks on parameters passed into public functions. For instance, looking at the screen-shot there are 3 numbered items.
One could right click at point 1 and have R# generate the following for the 'input1' parameter:

if( input1 == null || input1.Length == 0 )
throw new ArgumentNullException( @"input1",
@"The parameters passed was null or empty." );

... and similar for input2:
if( input2== null )
throw new ArgumentNullException( @"input2,
@"The parameters passed was null." );

..and for the return value:
if( s== null || s.Length == 0 )
throw new ArgumentNullException( @"s",
@"The parameter being returned is null which breaks the contract[1]." );
or something similar, if indeed it does break the contract.



Attachment(s):
r# suggestion.png
1 comment
Comment actions Permalink

Hello Steve,

This looks like a good idea for a context action. Please, submit it to the
tracker.

It would be great if R# could generate checks on parameters passed
into public functions. For instance, looking at the screen-shot there
are 3 numbered items.

One could right click at point 1 and have R# generate the following
for the 'input1' parameter:

if( input1 == null || input1.Length == 0 )
throw new ArgumentNullException( @"input1",
@"The parameters passed was null or empty." );
.. and similar for input2:
if( input2== null )
throw new ArgumentNullException( @"input2,
@"The parameters passed was null." );
.and for the return value:
if( s== null || s.Length == 0 )
throw new ArgumentNullException( @"s",
@"The parameter being returned is null which breaks the
contract[1]." );
or something similar, if indeed it does break the contract.

Thanks,
Andrey Simanovsky


0

Please sign in to leave a comment.