@@ -143,15 +143,7 @@ public void Minimize()
143143 // show dependencies
144144 if ( _verbose )
145145 {
146- try
147- {
148- ShowDependencies ( t , set , setTmp ) ;
149- }
150- catch ( Exception )
151- {
152- Console . WriteLine ( $ "Exception listing dependencies of token { t . ToInt32 ( ) . ToString ( "x8" ) } { TokenToString ( t ) } ") ;
153- throw ;
154- }
146+ ShowDependencies ( t , set , setTmp ) ;
155147 }
156148
157149 // copy type def
@@ -252,7 +244,14 @@ private void ShowDependencies(MetadataToken token, HashSet<MetadataToken> set, H
252244 {
253245 if ( ! set . Contains ( m ) )
254246 {
255- System . Console . WriteLine ( $ "{ tokenFrom } -> { TokenToString ( m ) } ") ;
247+ try
248+ {
249+ Console . WriteLine ( $ "{ tokenFrom } -> { TokenToString ( m ) } ") ;
250+ }
251+ catch ( Exception )
252+ {
253+ throw new ArgumentException ( $ "Exception listing token dependencies. Problematic token is 0x{ m . ToInt32 ( ) . ToString ( "x8" ) } .") ;
254+ }
256255 }
257256 }
258257 }
@@ -364,9 +363,9 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
364363 }
365364 else
366365 {
367- if ( mr . ReturnType . GetElementType ( ) . FullName != "System.Void" &&
368- mr . ReturnType . GetElementType ( ) . FullName != "System.String" &&
369- mr . ReturnType . GetElementType ( ) . FullName != "System.Object" &&
366+ if ( mr . ReturnType . GetElementType ( ) . FullName != "System.Void" &&
367+ mr . ReturnType . GetElementType ( ) . FullName != "System.String" &&
368+ mr . ReturnType . GetElementType ( ) . FullName != "System.Object" &&
370369 ! mr . ReturnType . GetElementType ( ) . IsPrimitive )
371370 {
372371 set . Add ( mr . ReturnType . GetElementType ( ) . MetadataToken ) ;
@@ -377,9 +376,9 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
377376 {
378377 if ( mr . ReturnType . MetadataType == MetadataType . ValueType )
379378 {
380- if ( mr . ReturnType . FullName != "System.Void" &&
381- mr . ReturnType . FullName != "System.String" &&
382- mr . ReturnType . FullName != "System.Object" &&
379+ if ( mr . ReturnType . FullName != "System.Void" &&
380+ mr . ReturnType . FullName != "System.String" &&
381+ mr . ReturnType . FullName != "System.Object" &&
383382 ! mr . ReturnType . IsPrimitive )
384383 {
385384 set . Add ( mr . ReturnType . MetadataToken ) ;
@@ -446,11 +445,11 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
446445 set . Add ( fr . DeclaringType . MetadataToken ) ;
447446 }
448447 }
449- else if ( fr . FieldType . FullName != "System.Void" &&
450- fr . FieldType . FullName != "System.String" &&
451- fr . FieldType . FullName != "System.Object " &&
452- fr . FieldType . IsValueType &&
453- ! fr . FieldType . IsPrimitive )
448+ else if ( ! fr . FieldType . IsPrimitive &&
449+ fr . FieldType . IsValueType &&
450+ fr . FieldType . FullName != "System.Void " &&
451+ fr . FieldType . FullName != "System.String" &&
452+ fr . FieldType . FullName != "System.Object" )
454453 {
455454 set . Add ( fr . FieldType . MetadataToken ) ;
456455 }
@@ -551,12 +550,12 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
551550 }
552551 }
553552 else if ( ! fd . FieldType . IsValueType &&
554- ! fd . FieldType . IsPrimitive &&
555- fd . FieldType . FullName != "System.Void" &&
556- fd . FieldType . FullName != "System.String" &&
557- fd . FieldType . FullName != "System.Object" )
553+ ! fd . FieldType . IsPrimitive &&
554+ fd . FieldType . FullName != "System.Void" &&
555+ fd . FieldType . FullName != "System.String" &&
556+ fd . FieldType . FullName != "System.Object" )
558557 {
559- set . Add ( fd . FieldType . MetadataToken ) ;
558+ set . Add ( fd . FieldType . MetadataToken ) ;
560559 }
561560
562561 // attributes
@@ -575,8 +574,8 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
575574 var md = _tablesContext . MethodDefinitionTable . Items . FirstOrDefault ( i => i . MetadataToken == token ) ;
576575
577576 // return value
578- if ( md . ReturnType . IsValueType &&
579- ! md . ReturnType . IsPrimitive )
577+ if ( md . ReturnType . IsValueType &&
578+ ! md . ReturnType . IsPrimitive )
580579 {
581580 set . Add ( md . ReturnType . MetadataToken ) ;
582581 }
@@ -592,10 +591,10 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
592591 }
593592 }
594593 else if ( ! md . ReturnType . IsValueType &&
595- ! md . ReturnType . IsPrimitive &&
596- md . ReturnType . FullName != "System.Void" &&
597- md . ReturnType . FullName != "System.String" &&
598- md . ReturnType . FullName != "System.Object" )
594+ ! md . ReturnType . IsPrimitive &&
595+ md . ReturnType . FullName != "System.Void" &&
596+ md . ReturnType . FullName != "System.String" &&
597+ md . ReturnType . FullName != "System.Object" )
599598 {
600599 set . Add ( md . ReturnType . MetadataToken ) ;
601600 }
@@ -646,7 +645,8 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
646645 {
647646 if ( v . VariableType . GetElementType ( ) . FullName != "System.Void" &&
648647 v . VariableType . GetElementType ( ) . FullName != "System.String" &&
649- v . VariableType . GetElementType ( ) . FullName != "System.Object" )
648+ v . VariableType . GetElementType ( ) . FullName != "System.Object" &&
649+ ! v . VariableType . GetElementType ( ) . IsPrimitive )
650650 {
651651 set . Add ( v . VariableType . GetElementType ( ) . MetadataToken ) ;
652652 }
0 commit comments