@@ -297,7 +297,7 @@ bool ProcessInternalsVisibleAttributes ()
297
297
Debug . Assert ( attr . Provider is ModuleDefinition or AssemblyDefinition ) ;
298
298
var assembly = ( provider is ModuleDefinition module ) ? module . Assembly : provider as AssemblyDefinition ;
299
299
300
- using var assemblyScope = ScopeStack . PushScope ( new MessageOrigin ( assembly ) ) ;
300
+ using var assemblyScope = ScopeStack . PushLocalScope ( new MessageOrigin ( assembly ) ) ;
301
301
302
302
if ( ! Annotations . IsMarked ( attr . Attribute ) && IsInternalsVisibleAttributeAssemblyMarked ( attr . Attribute ) ) {
303
303
MarkCustomAttribute ( attr . Attribute , new DependencyInfo ( DependencyKind . AssemblyOrModuleAttribute , attr . Provider ) ) ;
@@ -362,7 +362,7 @@ internal void MarkEntireType (TypeDefinition type, in DependencyInfo reason)
362
362
363
363
// Prevent cases where there's nothing on the stack (can happen when marking entire assemblies)
364
364
// In which case we would generate warnings with no source (hard to debug)
365
- using var _ = ScopeStack . CurrentScope . Origin . Provider == null ? ScopeStack . PushScope ( new MessageOrigin ( type ) ) : null ;
365
+ using MarkScopeStack . LocalScope ? _ = ScopeStack . CurrentScope . Origin . Provider == null ? ScopeStack . PushLocalScope ( new MessageOrigin ( type ) ) : null ;
366
366
367
367
if ( ! _entireTypesMarked . Add ( type ) )
368
368
return ;
@@ -451,7 +451,7 @@ bool MarkFullyPreservedAssemblies ()
451
451
452
452
// Setup empty scope - there has to be some scope setup since we're doing marking below
453
453
// but there's no "origin" right now (command line is the origin really)
454
- using var localScope = ScopeStack . PushScope ( new MessageOrigin ( ( ICustomAttributeProvider ? ) null ) ) ;
454
+ using var localScope = ScopeStack . PushLocalScope ( new MessageOrigin ( ( ICustomAttributeProvider ? ) null ) ) ;
455
455
456
456
// Beware: this works on loaded assemblies, not marked assemblies, so it should not be tied to marking.
457
457
// We could further optimize this to only iterate through assemblies if the last mark iteration loaded
@@ -488,7 +488,7 @@ bool ProcessPrimaryQueue ()
488
488
489
489
bool ProcessMarkedPending ( )
490
490
{
491
- using var emptyScope = ScopeStack . PushScope ( new MessageOrigin ( null as ICustomAttributeProvider ) ) ;
491
+ using var emptyScope = ScopeStack . PushLocalScope ( new MessageOrigin ( null as ICustomAttributeProvider ) ) ;
492
492
493
493
bool marked = false ;
494
494
foreach ( var pending in Annotations . GetMarkedPending ( ) ) {
@@ -498,7 +498,7 @@ bool ProcessMarkedPending ()
498
498
if ( Annotations . IsProcessed ( pending . Key ) )
499
499
continue ;
500
500
501
- using var localScope = ScopeStack . PushScope ( pending . Value ) ;
501
+ using var localScope = ScopeStack . PushLocalScope ( pending . Value ) ;
502
502
503
503
switch ( pending . Key ) {
504
504
case TypeDefinition type :
@@ -572,7 +572,7 @@ protected virtual void EnqueueMethod (MethodDefinition method, in DependencyInfo
572
572
void ProcessVirtualMethods ( )
573
573
{
574
574
foreach ( ( var method , var scope ) in _virtual_methods ) {
575
- using ( ScopeStack . PushScope ( scope ) ) {
575
+ using ( ScopeStack . PushLocalScope ( scope ) ) {
576
576
ProcessVirtualMethod ( method ) ;
577
577
}
578
578
}
@@ -597,7 +597,7 @@ void ProcessMarkedTypesWithInterfaces ()
597
597
// UnusedInterfaces optimization is turned off mark all interface implementations
598
598
bool unusedInterfacesOptimizationEnabled = Context . IsOptimizationEnabled ( CodeOptimizations . UnusedInterfaces , type ) ;
599
599
600
- using ( ScopeStack . PushScope ( scope ) ) {
600
+ using ( ScopeStack . PushLocalScope ( scope ) ) {
601
601
if ( Annotations . IsInstantiated ( type ) || Annotations . IsRelevantToVariantCasting ( type ) ||
602
602
! unusedInterfacesOptimizationEnabled ) {
603
603
MarkInterfaceImplementations ( type ) ;
@@ -685,7 +685,7 @@ void ProcessPendingBodies ()
685
685
for ( int i = 0 ; i < _unreachableBodies . Count ; i ++ ) {
686
686
( var body , var scope ) = _unreachableBodies [ i ] ;
687
687
if ( Annotations . IsInstantiated ( body . Method . DeclaringType ) ) {
688
- using ( ScopeStack . PushScope ( scope ) )
688
+ using ( ScopeStack . PushLocalScope ( scope ) )
689
689
MarkMethodBody ( body ) ;
690
690
691
691
_unreachableBodies . RemoveAt ( i -- ) ;
@@ -874,7 +874,7 @@ void MarkCustomAttributes (ICustomAttributeProvider provider, in DependencyInfo
874
874
return ;
875
875
876
876
IMemberDefinition providerMember = ( IMemberDefinition ) provider ; ;
877
- using ( ScopeStack . PushScope ( new MessageOrigin ( providerMember ) ) )
877
+ using ( ScopeStack . PushLocalScope ( new MessageOrigin ( providerMember ) ) )
878
878
foreach ( var dynamicDependency in Annotations . GetLinkerAttributes < DynamicDependency > ( providerMember ) )
879
879
MarkDynamicDependency ( dynamicDependency , providerMember ) ;
880
880
}
@@ -1407,7 +1407,7 @@ protected virtual void MarkAssembly (AssemblyDefinition assembly, DependencyInfo
1407
1407
if ( CheckProcessed ( assembly ) )
1408
1408
return ;
1409
1409
1410
- using var assemblyScope = ScopeStack . PushScope ( new MessageOrigin ( assembly ) ) ;
1410
+ using var assemblyScope = ScopeStack . PushLocalScope ( new MessageOrigin ( assembly ) ) ;
1411
1411
1412
1412
EmbeddedXmlInfo . ProcessDescriptors ( assembly , Context ) ;
1413
1413
@@ -1537,7 +1537,7 @@ bool ProcessLazyAttributes ()
1537
1537
Debug . Assert ( provider is ModuleDefinition or AssemblyDefinition ) ;
1538
1538
var assembly = ( provider is ModuleDefinition module ) ? module . Assembly : provider as AssemblyDefinition ;
1539
1539
1540
- using var assemblyScope = ScopeStack . PushScope ( new MessageOrigin ( assembly ) ) ;
1540
+ using var assemblyScope = ScopeStack . PushLocalScope ( new MessageOrigin ( assembly ) ) ;
1541
1541
1542
1542
var resolved = Context . Resolve ( customAttribute . Constructor ) ;
1543
1543
if ( resolved == null ) {
@@ -1607,7 +1607,7 @@ bool ProcessLateMarkedAttributes ()
1607
1607
}
1608
1608
1609
1609
markOccurred = true ;
1610
- using ( ScopeStack . PushScope ( scope ) ) {
1610
+ using ( ScopeStack . PushLocalScope ( scope ) ) {
1611
1611
MarkCustomAttribute ( customAttribute , reason ) ;
1612
1612
}
1613
1613
}
@@ -1788,7 +1788,7 @@ void MarkField (FieldDefinition field, in DependencyInfo reason, in MessageOrigi
1788
1788
// Use the original scope for marking the declaring type - it provides better warning message location
1789
1789
MarkType ( field . DeclaringType , new DependencyInfo ( DependencyKind . DeclaringType , field ) ) ;
1790
1790
1791
- using var fieldScope = ScopeStack . PushScope ( new MessageOrigin ( field ) ) ;
1791
+ using var fieldScope = ScopeStack . PushLocalScope ( new MessageOrigin ( field ) ) ;
1792
1792
MarkType ( field . FieldType , new DependencyInfo ( DependencyKind . FieldType , field ) ) ;
1793
1793
MarkCustomAttributes ( field , new DependencyInfo ( DependencyKind . CustomAttribute , field ) ) ;
1794
1794
MarkMarshalSpec ( field , new DependencyInfo ( DependencyKind . FieldMarshalSpec , field ) ) ;
@@ -2007,7 +2007,7 @@ internal void MarkStaticConstructorVisibleToReflection (TypeDefinition type, in
2007
2007
if ( reference == null )
2008
2008
return null ;
2009
2009
2010
- using var localScope = origin . HasValue ? ScopeStack . PushScope ( origin . Value ) : null ;
2010
+ using MarkScopeStack . LocalScope ? localScope = origin . HasValue ? ScopeStack . PushLocalScope ( origin . Value ) : null ;
2011
2011
2012
2012
( reference , reason ) = GetOriginalType ( reference , reason ) ;
2013
2013
@@ -2053,7 +2053,7 @@ internal void MarkStaticConstructorVisibleToReflection (TypeDefinition type, in
2053
2053
if ( type . Scope is ModuleDefinition module )
2054
2054
MarkModule ( module , new DependencyInfo ( DependencyKind . ScopeOfType , type ) ) ;
2055
2055
2056
- using var typeScope = ScopeStack . PushScope ( new MessageOrigin ( type ) ) ;
2056
+ using var typeScope = ScopeStack . PushLocalScope ( new MessageOrigin ( type ) ) ;
2057
2057
2058
2058
foreach ( Action < TypeDefinition > handleMarkType in MarkContext . MarkTypeActions )
2059
2059
handleMarkType ( type ) ;
@@ -2141,7 +2141,7 @@ internal void MarkStaticConstructorVisibleToReflection (TypeDefinition type, in
2141
2141
}
2142
2142
}
2143
2143
if ( ShouldMarkTypeStaticConstructor ( type ) && reason . Kind != DependencyKind . TriggersCctorForCalledMethod ) {
2144
- using ( ScopeStack . PopToParent ( ) )
2144
+ using ( ScopeStack . PopToParentScope ( ) )
2145
2145
MarkStaticConstructor ( type , new DependencyInfo ( DependencyKind . CctorForType , type ) , ScopeStack . CurrentScope . Origin ) ;
2146
2146
}
2147
2147
}
@@ -2440,7 +2440,7 @@ void MarkNamedProperty (TypeDefinition type, string property_name, in Dependency
2440
2440
if ( property . Name != property_name )
2441
2441
continue ;
2442
2442
2443
- using ( ScopeStack . PushScope ( new MessageOrigin ( property ) ) ) {
2443
+ using ( ScopeStack . PushLocalScope ( new MessageOrigin ( property ) ) ) {
2444
2444
// This marks methods directly without reporting the property.
2445
2445
MarkMethod ( property . GetMethod , reason , ScopeStack . CurrentScope . Origin ) ;
2446
2446
MarkMethod ( property . SetMethod , reason , ScopeStack . CurrentScope . Origin ) ;
@@ -2804,7 +2804,7 @@ void MarkGenericArguments (IGenericInstance instance)
2804
2804
// The only two implementations of IGenericInstance both derive from MemberReference
2805
2805
Debug . Assert ( instance is MemberReference ) ;
2806
2806
2807
- using var _ = ScopeStack . CurrentScope . Origin . Provider == null ? ScopeStack . PushScope ( new MessageOrigin ( ( ( MemberReference ) instance ) . Resolve ( ) ) ) : null ;
2807
+ using MarkScopeStack . LocalScope ? _ = ScopeStack . CurrentScope . Origin . Provider == null ? ScopeStack . PushLocalScope ( new MessageOrigin ( ( ( MemberReference ) instance ) . Resolve ( ) ) ) : null ;
2808
2808
var scanner = new GenericArgumentDataFlow ( Context , this , ScopeStack . CurrentScope . Origin ) ;
2809
2809
scanner . ProcessGenericArgumentDataFlow ( parameter , argument ) ;
2810
2810
}
@@ -2832,7 +2832,7 @@ void MarkGenericArguments (IGenericInstance instance)
2832
2832
2833
2833
void ApplyPreserveInfo ( TypeDefinition type )
2834
2834
{
2835
- using var typeScope = ScopeStack . PushScope ( new MessageOrigin ( type ) ) ;
2835
+ using var typeScope = ScopeStack . PushLocalScope ( new MessageOrigin ( type ) ) ;
2836
2836
2837
2837
if ( Annotations . TryGetPreserve ( type , out TypePreserve preserve ) ) {
2838
2838
if ( ! Annotations . SetAppliedPreserve ( type , preserve ) )
@@ -3203,8 +3203,8 @@ protected virtual void ProcessMethod (MethodDefinition method, in DependencyInfo
3203
3203
throw new InternalErrorException ( $ "Unsupported method dependency { reason . Kind } ") ;
3204
3204
#endif
3205
3205
ScopeStack . AssertIsEmpty ( ) ;
3206
- using var parentScope = ScopeStack . PushScope ( new MarkScopeStack . Scope ( origin ) ) ;
3207
- using var methodScope = ScopeStack . PushScope ( new MessageOrigin ( method ) ) ;
3206
+ using var parentScope = ScopeStack . PushLocalScope ( new MarkScopeStack . Scope ( origin ) ) ;
3207
+ using var methodScope = ScopeStack . PushLocalScope ( new MessageOrigin ( method ) ) ;
3208
3208
3209
3209
bool markedForCall =
3210
3210
reason . Kind == DependencyKind . DirectCall ||
@@ -3360,7 +3360,7 @@ protected virtual void MarkRequirementsForInstantiatedTypes (TypeDefinition type
3360
3360
3361
3361
Annotations . MarkInstantiated ( type ) ;
3362
3362
3363
- using var typeScope = ScopeStack . PushScope ( new MessageOrigin ( type ) ) ;
3363
+ using var typeScope = ScopeStack . PushLocalScope ( new MessageOrigin ( type ) ) ;
3364
3364
3365
3365
MarkInterfaceImplementations ( type ) ;
3366
3366
@@ -3450,7 +3450,7 @@ bool MarkDisablePrivateReflectionAttribute ()
3450
3450
if ( disablePrivateReflection == null )
3451
3451
throw new LinkerFatalErrorException ( MessageContainer . CreateErrorMessage ( null , DiagnosticId . CouldNotFindType , "System.Runtime.CompilerServices.DisablePrivateReflectionAttribute" ) ) ;
3452
3452
3453
- using ( ScopeStack . PushScope ( new MessageOrigin ( null as ICustomAttributeProvider ) ) ) {
3453
+ using ( ScopeStack . PushLocalScope ( new MessageOrigin ( null as ICustomAttributeProvider ) ) ) {
3454
3454
MarkType ( disablePrivateReflection , DependencyInfo . DisablePrivateReflectionRequirement ) ;
3455
3455
3456
3456
var ctor = MarkMethodIf ( disablePrivateReflection . Methods , MethodDefinitionExtensions . IsDefaultConstructor , new DependencyInfo ( DependencyKind . DisablePrivateReflectionRequirement , disablePrivateReflection ) , ScopeStack . CurrentScope . Origin ) ;
@@ -3570,7 +3570,7 @@ protected internal void MarkProperty (PropertyDefinition prop, in DependencyInfo
3570
3570
if ( ! Annotations . MarkProcessed ( prop , reason ) )
3571
3571
return ;
3572
3572
3573
- using var propertyScope = ScopeStack . PushScope ( new MessageOrigin ( prop ) ) ;
3573
+ using var propertyScope = ScopeStack . PushLocalScope ( new MessageOrigin ( prop ) ) ;
3574
3574
3575
3575
// Consider making this more similar to MarkEvent method?
3576
3576
MarkCustomAttributes ( prop , new DependencyInfo ( DependencyKind . CustomAttribute , prop ) ) ;
@@ -3582,7 +3582,7 @@ protected internal virtual void MarkEvent (EventDefinition evt, in DependencyInf
3582
3582
if ( ! Annotations . MarkProcessed ( evt , reason ) )
3583
3583
return ;
3584
3584
3585
- using var eventScope = ScopeStack . PushScope ( new MessageOrigin ( evt ) ) ;
3585
+ using var eventScope = ScopeStack . PushLocalScope ( new MessageOrigin ( evt ) ) ;
3586
3586
3587
3587
MarkCustomAttributes ( evt , new DependencyInfo ( DependencyKind . CustomAttribute , evt ) ) ;
3588
3588
@@ -3681,7 +3681,7 @@ bool MarkAndCheckRequiresReflectionMethodBodyScanner (MethodIL methodIL)
3681
3681
3682
3682
requiresReflectionMethodBodyScanner =
3683
3683
ReflectionMethodBodyScanner . RequiresReflectionMethodBodyScannerForMethodBody ( Context , methodIL . Method ) ;
3684
- using var _ = ScopeStack . PushScope ( new MessageOrigin ( methodIL . Method ) ) ;
3684
+ using var _ = ScopeStack . PushLocalScope ( new MessageOrigin ( methodIL . Method ) ) ;
3685
3685
foreach ( Instruction instruction in methodIL . Instructions )
3686
3686
MarkInstruction ( instruction , methodIL . Method , ref requiresReflectionMethodBodyScanner ) ;
3687
3687
@@ -3832,7 +3832,7 @@ protected internal virtual void MarkInterfaceImplementation (InterfaceImplementa
3832
3832
return ;
3833
3833
Annotations . MarkProcessed ( iface , reason ?? new DependencyInfo ( DependencyKind . InterfaceImplementationOnType , ScopeStack . CurrentScope . Origin . Provider ) ) ;
3834
3834
3835
- using var localScope = origin . HasValue ? ScopeStack . PushScope ( origin . Value ) : null ;
3835
+ using MarkScopeStack . LocalScope ? localScope = origin . HasValue ? ScopeStack . PushLocalScope ( origin . Value ) : null ;
3836
3836
3837
3837
// Blame the type that has the interfaceimpl, expecting the type itself to get marked for other reasons.
3838
3838
MarkCustomAttributes ( iface , new DependencyInfo ( DependencyKind . CustomAttribute , iface ) ) ;
0 commit comments