@@ -92,7 +92,7 @@ private static Statistics StartExploration(List<MethodBase> methods, string resu
9292
9393 void HandleInternalFail ( MethodBase method , Exception exception )
9494 {
95- Console . WriteLine ( $ "EXCEPTION | { method . DeclaringType } .{ method . Name } | { exception . GetType ( ) . Name } { exception . Message } ") ;
95+ Logger . printLogString ( Logger . Error , $ "Internal exception | { method . DeclaringType } .{ method . Name } | { exception . GetType ( ) . Name } { exception . Message } ") ;
9696 }
9797
9898 foreach ( var method in methods )
@@ -172,18 +172,52 @@ public static Statistics Cover(Type type, int timeout = -1, string outputDirecto
172172 public static Statistics Cover ( Assembly assembly , int timeout = - 1 , string outputDirectory = "" )
173173 {
174174 AssemblyManager . Load ( assembly ) ;
175- List < MethodBase > methods ;
176175 BindingFlags bindingFlags = BindingFlags . Instance | BindingFlags . Static | BindingFlags . Public |
177176 BindingFlags . DeclaredOnly ;
178- methods = new List < MethodBase > ( ) ;
179177
180- foreach ( var t in assembly . GetTypes ( ) )
178+ var methods = new List < MethodBase > ( ) ;
179+ var types = new List < Type > ( ) ;
180+
181+ try
182+ {
183+ types . AddRange ( assembly . GetTypes ( ) ) ;
184+ }
185+ catch ( ReflectionTypeLoadException e )
186+ {
187+ foreach ( var loaderException in e . LoaderExceptions )
188+ {
189+ Logger . printLogString ( Logger . Error , $ "Cannot load type: { loaderException ? . Message } ") ;
190+ }
191+
192+ foreach ( var type in e . Types )
193+ {
194+ if ( type is not null )
195+ {
196+ types . Add ( type ) ;
197+ }
198+ }
199+ }
200+
201+ foreach ( var t in types )
181202 {
182- if ( t . IsPublic )
203+ if ( t . IsPublic || t . IsNestedPublic )
183204 {
184205 foreach ( var m in t . GetMethods ( bindingFlags ) )
185206 {
186- if ( m . GetMethodBody ( ) != null )
207+ global ::System . Reflection . MethodBody methodBody = null ;
208+ var hasByRefLikes = true ;
209+
210+ try
211+ {
212+ methodBody = m . GetMethodBody ( ) ;
213+ hasByRefLikes = Reflection . hasByRefLikes ( m ) ;
214+ }
215+ catch ( Exception e )
216+ {
217+ Logger . printLogString ( Logger . Error , $ "Cannot get method info: { e . Message } ") ;
218+ }
219+
220+ if ( methodBody is not null && ! hasByRefLikes )
187221 methods . Add ( m ) ;
188222 }
189223 }
0 commit comments