Skip to content

Commit 5db0884

Browse files
committed
Merge pull request #1 from MehdiK/master
Fixed a bug in GetTypesToTest
2 parents 964d474 + 66b56fb commit 5db0884

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,13 @@ bin
33
obj
44

55
# mstest test results
6-
TestResults
6+
TestResults
7+
8+
# Misc
9+
_ReSharper.*
10+
*.user
11+
*.suo
12+
*.crunchproject.local.xml
13+
*.crunchsolution.local.xml
14+
*.ncrunchsolution
15+
*.ncrunchproject

ConventionTests/ConventionTests.NUnit.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,22 @@ protected virtual Assembly[] GetAssembliesToScan(ConventionData data)
147147
protected virtual Type[] GetTypesToTest(ConventionData data)
148148
{
149149
return
150-
GetAssembliesToScan(data).SelectMany(a => a.GetTypes()).Where(data.Types.Invoke).OrderBy(t => t.FullName)
151-
.ToArray();
152-
}
153-
}
150+
GetAssembliesToScan(data).SelectMany(GetTypesSafely).Where(data.Types.Invoke).OrderBy(t => t.FullName)
151+
.ToArray();
152+
}
153+
154+
private static IEnumerable<Type> GetTypesSafely(Assembly assembly)
155+
{
156+
try
157+
{
158+
return assembly.GetTypes();
159+
}
160+
catch (ReflectionTypeLoadException ex)
161+
{
162+
return ex.Types.Where(x => x != null);
163+
}
164+
}
165+
}
154166

155167
public abstract class WindsorConventionTest<TDiagnostic> : WindsorConventionTest<TDiagnostic, IHandler>
156168
where TDiagnostic : class, IDiagnostic<IEnumerable<IHandler>>, IDiagnostic<object>

0 commit comments

Comments
 (0)