@@ -62,7 +62,6 @@ protected LinkContext Context {
62
62
protected Queue < ( MethodDefinition , DependencyInfo , MessageOrigin ) > _methods ;
63
63
protected Dictionary < MethodDefinition , MarkScopeStack . Scope > _virtual_methods ;
64
64
protected Queue < AttributeProviderPair > _assemblyLevelAttributes ;
65
- readonly List < AttributeProviderPair > _ivt_attributes ;
66
65
protected Queue < ( AttributeProviderPair , DependencyInfo , MarkScopeStack . Scope ) > _lateMarkedAttributes ;
67
66
protected List < ( TypeDefinition , MarkScopeStack . Scope ) > _typesWithInterfaces ;
68
67
protected HashSet < AssemblyDefinition > _dynamicInterfaceCastableImplementationTypesDiscovered ;
@@ -222,7 +221,6 @@ public MarkStep ()
222
221
_methods = new Queue < ( MethodDefinition , DependencyInfo , MessageOrigin ) > ( ) ;
223
222
_virtual_methods = new Dictionary < MethodDefinition , MarkScopeStack . Scope > ( ) ;
224
223
_assemblyLevelAttributes = new Queue < AttributeProviderPair > ( ) ;
225
- _ivt_attributes = new List < AttributeProviderPair > ( ) ;
226
224
_lateMarkedAttributes = new Queue < ( AttributeProviderPair , DependencyInfo , MarkScopeStack . Scope ) > ( ) ;
227
225
_typesWithInterfaces = new List < ( TypeDefinition , MarkScopeStack . Scope ) > ( ) ;
228
226
_dynamicInterfaceCastableImplementationTypesDiscovered = new HashSet < AssemblyDefinition > ( ) ;
@@ -288,42 +286,6 @@ protected virtual void Complete ()
288
286
}
289
287
}
290
288
291
- bool ProcessInternalsVisibleAttributes ( )
292
- {
293
- bool marked_any = false ;
294
- foreach ( var attr in _ivt_attributes ) {
295
-
296
- var provider = attr . Provider ;
297
- Debug . Assert ( attr . Provider is ModuleDefinition or AssemblyDefinition ) ;
298
- var assembly = ( provider is ModuleDefinition module ) ? module . Assembly : provider as AssemblyDefinition ;
299
-
300
- using var assemblyScope = ScopeStack . PushLocalScope ( new MessageOrigin ( assembly ) ) ;
301
-
302
- if ( ! Annotations . IsMarked ( attr . Attribute ) && IsInternalsVisibleAttributeAssemblyMarked ( attr . Attribute ) ) {
303
- MarkCustomAttribute ( attr . Attribute , new DependencyInfo ( DependencyKind . AssemblyOrModuleAttribute , attr . Provider ) ) ;
304
- marked_any = true ;
305
- }
306
- }
307
-
308
- return marked_any ;
309
-
310
- bool IsInternalsVisibleAttributeAssemblyMarked ( CustomAttribute ca )
311
- {
312
- System . Reflection . AssemblyName an ;
313
- try {
314
- an = new System . Reflection . AssemblyName ( ( string ) ca . ConstructorArguments [ 0 ] . Value ) ;
315
- } catch {
316
- return false ;
317
- }
318
-
319
- var assembly = Context . GetLoadedAssembly ( an . Name ! ) ;
320
- if ( assembly == null )
321
- return false ;
322
-
323
- return Annotations . IsMarked ( assembly . MainModule ) ;
324
- }
325
- }
326
-
327
289
static bool TypeIsDynamicInterfaceCastableImplementation ( TypeDefinition type )
328
290
{
329
291
if ( ! type . IsInterface || ! type . HasInterfaces || ! type . HasCustomAttributes )
@@ -416,8 +378,7 @@ void Process ()
416
378
ProcessMarkedPending ( ) ||
417
379
ProcessLazyAttributes ( ) ||
418
380
ProcessLateMarkedAttributes ( ) ||
419
- MarkFullyPreservedAssemblies ( ) ||
420
- ProcessInternalsVisibleAttributes ( ) ) ;
381
+ MarkFullyPreservedAssemblies ( ) ) ;
421
382
422
383
ProcessPendingTypeChecks ( ) ;
423
384
}
@@ -1169,6 +1130,9 @@ protected virtual bool ShouldMarkCustomAttribute (CustomAttribute ca, ICustomAtt
1169
1130
case "System.Runtime.InteropServices.InterfaceTypeAttribute" :
1170
1131
case "System.Runtime.InteropServices.GuidAttribute" :
1171
1132
return true ;
1133
+ // May be implicitly used by the runtime
1134
+ case "System.Runtime.CompilerServices.InternalsVisibleToAttribute" :
1135
+ return true ;
1172
1136
}
1173
1137
1174
1138
TypeDefinition ? type = Context . Resolve ( attr_type ) ;
@@ -1546,10 +1510,7 @@ bool ProcessLazyAttributes ()
1546
1510
if ( IsAttributeRemoved ( customAttribute , resolved . DeclaringType ) && Annotations . GetAction ( CustomAttributeSource . GetAssemblyFromCustomAttributeProvider ( assemblyLevelAttribute . Provider ) ) == AssemblyAction . Link )
1547
1511
continue ;
1548
1512
1549
- if ( customAttribute . AttributeType . IsTypeOf ( "System.Runtime.CompilerServices" , "InternalsVisibleToAttribute" ) && ! Annotations . IsMarked ( customAttribute ) ) {
1550
- _ivt_attributes . Add ( assemblyLevelAttribute ) ;
1551
- continue ;
1552
- } else if ( ! ShouldMarkTopLevelCustomAttribute ( assemblyLevelAttribute , resolved ) ) {
1513
+ if ( ! ShouldMarkTopLevelCustomAttribute ( assemblyLevelAttribute , resolved ) ) {
1553
1514
skippedItems . Add ( assemblyLevelAttribute ) ;
1554
1515
continue ;
1555
1516
}
0 commit comments