File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed
src/Coderr.Client.Tests/Config/ContextCollections Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change 2
2
using System . Collections . Generic ;
3
3
using System . ComponentModel . DataAnnotations ;
4
4
using System . Globalization ;
5
+ using System . IO ;
5
6
using System . Linq ;
6
7
using System . Reflection ;
7
8
using Coderr . Client . ContextCollections ;
@@ -203,16 +204,22 @@ public void should_be_able_to_serialize_all_types_of_exceptions()
203
204
var sut = new ObjectToContextCollectionConverter ( ) ;
204
205
205
206
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 ( ) )
214
209
{
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
+ }
216
223
}
217
224
218
225
foreach ( var exceptionType in exceptionTypes )
You can’t perform that action at this time.
0 commit comments