@@ -143,15 +143,7 @@ public void Minimize()
143
143
// show dependencies
144
144
if ( _verbose )
145
145
{
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 ) ;
155
147
}
156
148
157
149
// copy type def
@@ -252,7 +244,14 @@ private void ShowDependencies(MetadataToken token, HashSet<MetadataToken> set, H
252
244
{
253
245
if ( ! set . Contains ( m ) )
254
246
{
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
+ }
256
255
}
257
256
}
258
257
}
@@ -364,9 +363,9 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
364
363
}
365
364
else
366
365
{
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" &&
370
369
! mr . ReturnType . GetElementType ( ) . IsPrimitive )
371
370
{
372
371
set . Add ( mr . ReturnType . GetElementType ( ) . MetadataToken ) ;
@@ -377,9 +376,9 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
377
376
{
378
377
if ( mr . ReturnType . MetadataType == MetadataType . ValueType )
379
378
{
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" &&
383
382
! mr . ReturnType . IsPrimitive )
384
383
{
385
384
set . Add ( mr . ReturnType . MetadataToken ) ;
@@ -446,11 +445,11 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
446
445
set . Add ( fr . DeclaringType . MetadataToken ) ;
447
446
}
448
447
}
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" )
454
453
{
455
454
set . Add ( fr . FieldType . MetadataToken ) ;
456
455
}
@@ -551,12 +550,12 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
551
550
}
552
551
}
553
552
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" )
558
557
{
559
- set . Add ( fd . FieldType . MetadataToken ) ;
558
+ set . Add ( fd . FieldType . MetadataToken ) ;
560
559
}
561
560
562
561
// attributes
@@ -575,8 +574,8 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
575
574
var md = _tablesContext . MethodDefinitionTable . Items . FirstOrDefault ( i => i . MetadataToken == token ) ;
576
575
577
576
// return value
578
- if ( md . ReturnType . IsValueType &&
579
- ! md . ReturnType . IsPrimitive )
577
+ if ( md . ReturnType . IsValueType &&
578
+ ! md . ReturnType . IsPrimitive )
580
579
{
581
580
set . Add ( md . ReturnType . MetadataToken ) ;
582
581
}
@@ -592,10 +591,10 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
592
591
}
593
592
}
594
593
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" )
599
598
{
600
599
set . Add ( md . ReturnType . MetadataToken ) ;
601
600
}
@@ -646,7 +645,8 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
646
645
{
647
646
if ( v . VariableType . GetElementType ( ) . FullName != "System.Void" &&
648
647
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 )
650
650
{
651
651
set . Add ( v . VariableType . GetElementType ( ) . MetadataToken ) ;
652
652
}
0 commit comments