@@ -60,7 +60,7 @@ protected LinkContext Context {
60
60
}
61
61
62
62
protected Queue < ( MethodDefinition , DependencyInfo , MessageOrigin ) > _methods ;
63
- protected Dictionary < MethodDefinition , MarkScopeStack . Scope > _virtual_methods ;
63
+ protected Dictionary < MethodDefinition , MarkScopeStack . Scope > _interface_methods ;
64
64
protected Queue < AttributeProviderPair > _assemblyLevelAttributes ;
65
65
protected Queue < ( AttributeProviderPair , DependencyInfo , MarkScopeStack . Scope ) > _lateMarkedAttributes ;
66
66
protected List < ( TypeDefinition , MarkScopeStack . Scope ) > _typesWithInterfaces ;
@@ -219,7 +219,7 @@ internal DynamicallyAccessedMembersTypeHierarchy DynamicallyAccessedMembersTypeH
219
219
public MarkStep ( )
220
220
{
221
221
_methods = new Queue < ( MethodDefinition , DependencyInfo , MessageOrigin ) > ( ) ;
222
- _virtual_methods = new Dictionary < MethodDefinition , MarkScopeStack . Scope > ( ) ;
222
+ _interface_methods = new Dictionary < MethodDefinition , MarkScopeStack . Scope > ( ) ;
223
223
_assemblyLevelAttributes = new Queue < AttributeProviderPair > ( ) ;
224
224
_lateMarkedAttributes = new Queue < ( AttributeProviderPair , DependencyInfo , MarkScopeStack . Scope ) > ( ) ;
225
225
_typesWithInterfaces = new List < ( TypeDefinition , MarkScopeStack . Scope ) > ( ) ;
@@ -437,7 +437,7 @@ bool ProcessPrimaryQueue ()
437
437
438
438
while ( ! QueueIsEmpty ( ) ) {
439
439
ProcessQueue ( ) ;
440
- ProcessVirtualMethods ( ) ;
440
+ ProcessInterfaceMethods ( ) ;
441
441
ProcessMarkedTypesWithInterfaces ( ) ;
442
442
ProcessDynamicCastableImplementationInterfaces ( ) ;
443
443
ProcessPendingBodies ( ) ;
@@ -530,11 +530,11 @@ protected virtual void EnqueueMethod (MethodDefinition method, in DependencyInfo
530
530
_methods . Enqueue ( ( method , reason , origin ) ) ;
531
531
}
532
532
533
- void ProcessVirtualMethods ( )
533
+ void ProcessInterfaceMethods ( )
534
534
{
535
- foreach ( ( var method , var scope ) in _virtual_methods ) {
535
+ foreach ( ( var method , var scope ) in _interface_methods ) {
536
536
using ( ScopeStack . PushLocalScope ( scope ) ) {
537
- ProcessVirtualMethod ( method ) ;
537
+ ProcessInterfaceMethod ( method ) ;
538
538
}
539
539
}
540
540
}
@@ -568,7 +568,7 @@ void ProcessMarkedTypesWithInterfaces ()
568
568
continue ;
569
569
foreach ( var ov in baseMethods ) {
570
570
if ( ov . Base . DeclaringType is not null && ov . Base . DeclaringType . IsInterface && IgnoreScope ( ov . Base . DeclaringType . Scope ) ) {
571
- _virtual_methods . TryAdd ( ov . Base , ScopeStack . CurrentScope ) ;
571
+ MarkMethodAsVirtual ( ov . Base , ScopeStack . CurrentScope ) ;
572
572
}
573
573
}
574
574
}
@@ -651,28 +651,32 @@ void ProcessPendingBodies ()
651
651
}
652
652
}
653
653
}
654
-
655
- void ProcessVirtualMethod ( MethodDefinition method )
654
+ void MarkMethodAsVirtual ( MethodDefinition method , MarkScopeStack . Scope scope )
656
655
{
657
656
Annotations . EnqueueVirtualMethod ( method ) ;
658
-
659
657
if ( method . DeclaringType . IsInterface ) {
660
- var defaultImplementations = Annotations . GetDefaultInterfaceImplementations ( method ) ;
661
- if ( defaultImplementations is not null ) {
662
- foreach ( var dimInfo in defaultImplementations ) {
663
- ProcessDefaultImplementation ( dimInfo ) ;
658
+ _interface_methods . TryAdd ( method , scope ) ;
659
+ }
660
+ }
664
661
665
- if ( IsInterfaceImplementationMethodNeededByTypeDueToInterface ( dimInfo ) )
666
- MarkMethod ( dimInfo . Override , new DependencyInfo ( DependencyKind . Override , dimInfo . Base ) , ScopeStack . CurrentScope . Origin ) ;
667
- }
662
+ void ProcessInterfaceMethod ( MethodDefinition method )
663
+ {
664
+ Debug . Assert ( method . DeclaringType . IsInterface ) ;
665
+ var defaultImplementations = Annotations . GetDefaultInterfaceImplementations ( method ) ;
666
+ if ( defaultImplementations is not null ) {
667
+ foreach ( var dimInfo in defaultImplementations ) {
668
+ ProcessDefaultImplementation ( dimInfo ) ;
669
+
670
+ if ( IsInterfaceImplementationMethodNeededByTypeDueToInterface ( dimInfo ) )
671
+ MarkMethod ( dimInfo . Override , new DependencyInfo ( DependencyKind . Override , dimInfo . Base ) , ScopeStack . CurrentScope . Origin ) ;
668
672
}
669
- List < OverrideInformation > ? overridingMethods = ( List < OverrideInformation > ? ) Annotations . GetOverrides ( method ) ;
670
- if ( overridingMethods is not null ) {
671
- for ( int i = 0 ; i < overridingMethods . Count ; i ++ ) {
672
- OverrideInformation ov = overridingMethods [ i ] ;
673
- if ( IsInterfaceImplementationMethodNeededByTypeDueToInterface ( ov ) )
674
- MarkMethod ( ov . Override , new DependencyInfo ( DependencyKind . Override , ov . Base ) , ScopeStack . CurrentScope . Origin ) ;
675
- }
673
+ }
674
+ List < OverrideInformation > ? overridingMethods = ( List < OverrideInformation > ? ) Annotations . GetOverrides ( method ) ;
675
+ if ( overridingMethods is not null ) {
676
+ for ( int i = 0 ; i < overridingMethods . Count ; i ++ ) {
677
+ OverrideInformation ov = overridingMethods [ i ] ;
678
+ if ( IsInterfaceImplementationMethodNeededByTypeDueToInterface ( ov ) )
679
+ MarkMethod ( ov . Override , new DependencyInfo ( DependencyKind . Override , ov . Base ) , ScopeStack . CurrentScope . Origin ) ;
676
680
}
677
681
}
678
682
}
@@ -3227,7 +3231,7 @@ protected virtual void ProcessMethod (MethodDefinition method, in DependencyInfo
3227
3231
MarkMethodSpecialCustomAttributes ( method ) ;
3228
3232
3229
3233
if ( method . IsVirtual )
3230
- _virtual_methods . TryAdd ( method , ScopeStack . CurrentScope ) ;
3234
+ MarkMethodAsVirtual ( method , ScopeStack . CurrentScope ) ;
3231
3235
3232
3236
MarkNewCodeDependencies ( method ) ;
3233
3237
@@ -3435,7 +3439,7 @@ void MarkBaseMethods (MethodDefinition method)
3435
3439
// This will produce warnings for all interface methods and virtual methods regardless of whether the interface, interface implementation, or interface method is kept or not.
3436
3440
if ( ov . Base . DeclaringType . IsInterface && ! method . DeclaringType . IsInterface ) {
3437
3441
// These are all virtual, no need to check IsVirtual before adding to list
3438
- _virtual_methods . TryAdd ( ov . Base , ScopeStack . CurrentScope ) ;
3442
+ MarkMethodAsVirtual ( ov . Base , ScopeStack . CurrentScope ) ;
3439
3443
continue ;
3440
3444
}
3441
3445
0 commit comments