Skip to content

Instantly share code, notes, and snippets.

@rdingwall
Created October 26, 2011 15:01
Show Gist options
  • Save rdingwall/1316612 to your computer and use it in GitHub Desktop.
Save rdingwall/1316612 to your computer and use it in GitHub Desktop.
Visual Studio Regex to remove Code Contracts and replace with standard if/throw
Find / replace
Contract.Requires\<ArgumentNullException\>\(!String.IsNullOr(Empty|WhiteSpace)\({:i}\)\);
if (String.IsNullOrWhiteSpace(\1)) throw new ArgumentException("\1 was null or empty.", "\1");
Contract\.Requires\<ArgumentNullException\>\({:i} \!\= null, .+\)\;
if (\1 == null) throw new ArgumentNullException("\1");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment