vc3/Afterthought — pull request #49 by Reanmachine (2013-08-09 08:15:51+00:00)
Title: Fix for Nested Type Amendments where the Parent Type is not Amended

Back Story
----

I ran into this issue while using Afterthought in my project where I went to test my recently created amendment and in my unit test I was creating a test class nested inside the test fixture:

[TestFixture]
public class MyTests
{
[MyAmendment]
public class AmendTarget
{
// Snip ...
}

[Test]
public void TestMyAmendment()
{
var amended = new AmendTarget();

// Snip ...
}
}

The goal was to isolate the classes involved for this unit test by nesting them. Once I ran my test class through the amender I found that the `MyTests.AmendTarget` class was un-amended. I inspected the resulting assembly with dotPeek to double check it wasn't just a problem with my logic.

I decided to pull the class out to the namespace level and *bam* it amended just fine.

Aproach
----

It took me most of the evening to track this one down with minimal knowledge of Afterthought's internals, I ended up finding out the root cause was the interception of `Mutate(NamespaceTypeDefinition)` and `Mutate(NestedTypeDefinition)` on the `AssemblyAmender` class.

The base visitor implementation from `Microsoft.CCI` ends traversing the `.NestedTypes` property and visiting them, so what was happening is when the type wasn't amended, the result was being sent back without giving the visitor the chance to visit the nested types. This means that nested types would only be amended if the parent type was amended.

The result is simple, I just simply ran the `base.Mutate(...)` regardless of the result of `AmendType` and then used the return value from `AmendType` to simply select the return value.

**Now, I've looked around and I cannot see a negative impact that's obvious but because I am new to this codebase I'd like to see what you guys think.**

Notes
----

* All pre-existing unit tests pass with flying colors after the change
* I fixed my original implementation to confirm to your spacing style (tabs instead of spaces)
* I don't think I have violated any of your coding style guidelines (I couldn't find any officially, but my code looks fairly similar)
* I provided unit tests (isolated from the others) that will provide a failing test case without the fix to `AssemblyAmender` and serve as a simple regression test with the fix in place.
* Please let me know if my pull request doesn't meet your requirements and I will modify it to conform.