Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change generated code for 'Check if parameter is null'

Is there any way to change the code generated by resharper for the context action 'check if parameter is null'. I want to change it from

if (item == null) throw new ArgumentNullException("item");

to

Contract.Requires(item != null)
like image 206
Jim Avatar asked Dec 08 '11 10:12

Jim


1 Answers

I found the Reference "Add_Edit_Highlighting_Pattern". It seems to be the only way it can be done. You generate the default code, and then add a new pattern rule to change that code into an assert. You cannot actually change the original generated code - or so it seems.

The procedure described in another article "From ArgumentException to CodeContracts using Resharper"

like image 95
Jim Avatar answered Oct 22 '22 16:10

Jim