Code generation and DRY

I’m generally against code generation for a variety of reasons I’m not going to talk about here. However in some cases, small, targeted code generation is good, as it helps you avoid repetitive typing in verbose languages like C# without creating unmaintainable blob of poor quality code.

In other words, I very much like being able to go from this:

codegen_before

to this:

codegen_after

by just pressing Enter.

Comments

Scott_M says:

What is a "Fact" attribute?

I have the same snippet for NUnit, with the addition of an Assert.Fail() in the body which gets automatically selected. The fail is there for when I write the test name and have to leave it, making it very easy to know where to pick up from.

I also have a few snippets for WPF dependency properties to make them quicker to write because they are a little verbose.