Skip to content

Commit dfcbb4c

Browse files
committed
as
1 parent 1bef12c commit dfcbb4c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/Coderr.Client.Tests/Config/ContextCollections/ObjectToContextCollectionConverterTests.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.ComponentModel.DataAnnotations;
44
using System.Globalization;
5+
using System.IO;
56
using System.Linq;
67
using System.Reflection;
78
using Coderr.Client.ContextCollections;
@@ -203,16 +204,22 @@ public void should_be_able_to_serialize_all_types_of_exceptions()
203204
var sut = new ObjectToContextCollectionConverter();
204205

205206
var inner = new Exception("hello");
206-
List<Type> exceptionTypes;
207-
try
208-
{
209-
exceptionTypes = AppDomain.CurrentDomain.GetAssemblies()
210-
.SelectMany(assembly => assembly.GetTypes().Where(y => typeof(Exception).IsAssignableFrom(y)))
211-
.ToList();
212-
}
213-
catch (ReflectionTypeLoadException ex)
207+
var exceptionTypes = new List<Type>();
208+
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
214209
{
215-
throw ex.LoaderExceptions[0];
210+
try
211+
{
212+
var myTypes = assembly.GetTypes().Where(y => typeof(Exception).IsAssignableFrom(y));
213+
exceptionTypes.AddRange(myTypes);
214+
} //test assemblies and other dynamically loaded assemblies can mess up for us.
215+
catch (ReflectionTypeLoadException)
216+
{
217+
218+
}
219+
catch (FileLoadException)
220+
{
221+
222+
}
216223
}
217224

218225
foreach (var exceptionType in exceptionTypes)

0 commit comments

Comments
 (0)