[2015.07.25] Useful ReSharper snippets for WPF C# MVVM Development

2015-07-26 - C#, General Programming, WPF

I have put together a few ReSharper code snippets to autogenerate code I would have to write by hand. These have been very handy in my day-to-day coding.
			if ($parameter$ == null) throw new ArgumentNullException("$parameter$");


iftnan: Checks if an argument passed to a method is null and if so, throw the ArugmentNullException.

Note that you don’t really need this from what I have learned recently. If you just do Alt + Enter on the parameter you wish to check, R# will give you the option to throw.

private $TYPE$  $propertyName$;
public $TYPE$ $PropertyName$
	get { return $propertyName$; }
		if($propertyName$ == value) return;
		$propertyName$ = value;


pprop: Used in view model properties to raise change notifications assuming you have implemented INotifyPropertyChanged and your event handler is named RaisePropertyChanged();

public class $ClassName$()



tf: Creates a TestFixture class for NUnit.

public void $MethodName$()
    // arrange

    // act

    var unit = null;

    // assert
    Assert.That(unit, Is.Not.Null);


tf: Stubs out a Test method for NUnit with Arrange, Act, Assert sections marked.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>