Skip to content

Commit

Permalink
fix nested types
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Mar 7, 2013
1 parent 0df15f4 commit cb5d742
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions AssemblyToProcess/AssemblyToProcess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="AlsoRemoveMe.cs" />
<Compile Include="ClassEndingInMock.cs" />
<Compile Include="ClassEndingInTests.cs" />
<Compile Include="ClassWithNested.cs" />
<Compile Include="ForceReferences.cs" />
<Compile Include="MSpec\AssemblyContext.cs" />
<Compile Include="MSpec\CleanupAfterEveryContextInAssembly.cs" />
Expand Down
7 changes: 7 additions & 0 deletions AssemblyToProcess/ClassWithNested.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class ClassWithNested
{
public class NestedClassEndingInTests
{

}
}
4 changes: 2 additions & 2 deletions CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

[assembly: AssemblyTitle("Scalpel")]
[assembly: AssemblyProduct("Scalpel")]
[assembly: AssemblyVersion("0.7.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")]
[assembly: AssemblyVersion("0.8.0.0")]
[assembly: AssemblyFileVersion("0.8.0.0")]
13 changes: 11 additions & 2 deletions Fody/ModuleWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,21 @@ public void Execute()
}
ReadConfig();

var typeDefinitions = ModuleDefinition.Types.ToList();
var typeDefinitions = ModuleDefinition.GetTypes().ToList();
foreach (var type in typeDefinitions)
{
if (removers.Any(x => x.ShouldRemoveType(type)))
{
ModuleDefinition.Types.Remove(type);
if (type.IsNested)
{
var enclosingType = type.DeclaringType;
enclosingType.NestedTypes.Remove(type);
}
else
{

ModuleDefinition.Types.Remove(type);
}
}
}
var assemblyNameReferences = ModuleDefinition.AssemblyReferences.ToList();
Expand Down
5 changes: 5 additions & 0 deletions Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public void ClassEndingInTestsIsRemoved()
{
Assert.IsFalse(assembly.GetTypes().Any(x => x.Name == "ClassEndingInTests"));
}
[Test]
public void NestedClassEndingInTests()
{
Assert.IsFalse(assembly.GetTypes().Any(x => x.Name == "NestedClassEndingInTests"));
}


[Test]
Expand Down

0 comments on commit cb5d742

Please sign in to comment.