Linker.Steps\MarkStep.cs (133)
276 Annotations.SetAction (body.Method, MethodAction.ConvertToThrow);
294 if (Annotations.TryGetPreserve (type, out TypePreserve preserve) && preserve == TypePreserve.All)
297 switch (Annotations.GetAction (type.Module.Assembly)) {
387 Debug.Assert (Annotations.GetAction (assembly) == action);
401 var action = Annotations.GetAction (assembly);
404 if (!Annotations.IsProcessed (assembly))
431 foreach (var pending in Annotations.GetMarkedPending ()) {
435 if (Annotations.IsProcessed (pending.Key))
453 Annotations.SetProcessed (exportedType);
461 foreach (var type in Annotations.GetPendingPreserve ()) {
474 if (Annotations.IsInstantiated (type))
529 if (Annotations.IsInstantiated (type) || Annotations.IsRelevantToVariantCasting (type) ||
535 var baseMethods = Annotations.GetBaseMethods (method);
551 switch (Annotations.GetAction (assembly)) {
569 if (!Annotations.IsMarked (type) && TypeIsDynamicInterfaceCastableImplementation (type))
592 if (Annotations.IsMarked (type)) {
598 if (Annotations.IsMarked (iface.InterfaceType)) {
614 if (Annotations.IsInstantiated (body.Method.DeclaringType)) {
624 Annotations.EnqueueVirtualMethod (method);
633 var defaultImplementations = Annotations.GetDefaultInterfaceImplementations (method);
642 List<OverrideInformation>? overridingMethods = (List<OverrideInformation>?) Annotations.GetOverrides (method);
660 Debug.Assert (Annotations.IsMarked (overrideInformation.Base) || IgnoreScope (overrideInformation.Base.DeclaringType.Scope));
661 if (!Annotations.IsMarked (overrideInformation.Override.DeclaringType))
672 if (Annotations.IsInstantiated (overrideInformation.Override.DeclaringType))
690 if (Context.IsOptimizationEnabled (CodeOptimizations.OverrideRemoval, overrideInformation.Override) && Annotations.IsInstantiated (overrideInformation.Override.DeclaringType)) {
701 Debug.Assert (Annotations.IsMarked (method.DeclaringType));
703 var bases = Annotations.GetBaseMethods (method);
707 var markedBaseMethods = bases.Where (ov => Annotations.IsMarked (ov.Base) || IgnoreScope (ov.Base.DeclaringType.Scope));
748 if ((!ov.Override.IsStatic && !Annotations.IsInstantiated (ov.InterfaceImplementor.Implementor))
749 || ov.Override.IsStatic && !Annotations.IsRelevantToVariantCasting (ov.InterfaceImplementor.Implementor))
773 bool providerInLinkedAssembly = Annotations.GetAction (CustomAttributeSource.GetAssemblyFromCustomAttributeProvider (provider)) == AssemblyAction.Link;
802 foreach (var dynamicDependency in Annotations.GetLinkerAttributes<DynamicDependency> (providerMember))
808 foreach (var attr in Annotations.GetLinkerAttributes<RemoveAttributeInstancesAttribute> (attributeType)) {
1064 Annotations.Mark (ca, reason);
1103 if (type is null || !Annotations.IsMarked (type))
1112 if (Annotations.HasPreservedStaticCtor (type))
1124 Annotations.SetPreservedStaticCtor (type);
1136 if (!Annotations.IsMarked (resolvedConstructor.Module) &&
1137 !Annotations.IsMarked (ca.AttributeType) &&
1138 Annotations.GetAction (resolvedConstructor.Module.Assembly) == AssemblyAction.Link)
1145 if (displayTargetType == null || !Annotations.IsMarked (displayTargetType))
1205 if (property != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis (property.SetMethod)) {
1242 if (field != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis (field)) {
1285 if (resolvedConstructor != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis (resolvedConstructor)) {
1328 return !Annotations.SetProcessed (provider);
1333 Annotations.Mark (assembly, reason, origin);
1350 var action = Annotations.GetAction (assembly);
1358 } else if (Annotations.IsRootAssembly (assembly)) {
1374 Debug.Assert (Annotations.IsProcessed (assembly));
1449 if (Annotations.HasMarkedAnyIndirectlyCalledMethods () && MarkDisablePrivateReflectionAttribute ())
1474 if (IsAttributeRemoved (customAttribute, resolved.DeclaringType) && Annotations.GetAction (CustomAttributeSource.GetAssemblyFromCustomAttributeProvider (assemblyLevelAttribute.Provider)) == AssemblyAction.Link)
1567 if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode (origin.Provider, out _))
1579 isReflectionAccessCoveredByRUC = Annotations.DoesMethodRequireUnreferencedCode (method, out requiresUnreferencedCode);
1589 isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode (method, out requiresUnreferencedCode);
1597 isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode (method, out requiresUnreferencedCode);
1604 bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection (method);
1644 bool isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode (member, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute);
1654 bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection (member);
1669 Debug.Assert (Annotations.IsMarked (field));
1671 Annotations.Mark (field, reason, origin);
1707 if (field.IsStatic && !Annotations.HasPreservedStaticCtor (parent)) {
1716 if (Annotations.HasSubstitutedInit (field)) {
1717 Annotations.SetPreservedStaticCtor (parent);
1718 Annotations.SetSubstitutedInit (parent);
1740 if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode (origin.Provider, out _))
1743 if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode (field, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute))
1753 if (Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection (field))
1766 return assembly != null && Annotations.GetAction (assembly) != AssemblyAction.Link;
1772 Debug.Assert (Annotations.IsMarked (module));
1774 Annotations.Mark (module, reason, origin);
1804 Annotations.MarkRelevantToVariantCasting (definition);
1805 Annotations.MarkReflectionUsed (definition);
1814 Annotations.MarkReflectionUsed (methodDefinition);
1815 Annotations.MarkIndirectlyCalledMethod (methodDefinition);
1825 if (IsFullyPreservedAction (Annotations.GetAction (type.Module.Assembly)))
1826 Annotations.SetAction (method, MethodAction.ForceParse);
1852 if (propertyDefinition != null && !Annotations.IsMarked (propertyDefinition))
1919 Debug.Assert (Annotations.IsMarked (type));
1922 Annotations.Mark (type, reason, origin);
1930 if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute> (type)) {
1965 !Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute> (type) &&
1966 Annotations.TryGetLinkerAttribute (baseType, out RequiresUnreferencedCodeAttribute? effectiveRequiresUnreferencedCode)) {
2107 if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute> (resolvedAttributeType) && Annotations.GetAction (type.Module.Assembly) == AssemblyAction.Link)
2328 var ifaces = Annotations.GetRecursiveInterfaces (type);
2342 if (ifaces.All (Annotations.IsMarked))
2351 if (Annotations.IsMarked (resolvedInterfaceType))
2394 if (Annotations.IsMarked (method))
2400 var base_list = Annotations.GetBaseMethods (method);
2436 if (Annotations.IsMarked (method))
2442 if (!((iface is not null && Annotations.IsMarked (iface))
2448 if (!Annotations.IsMarked (@base) && !IgnoreScope (@base.DeclaringType.Scope))
2459 return Annotations.IsRelevantToVariantCasting (overrideInformation.InterfaceImplementor.Implementor)
2464 return Annotations.IsInstantiated (overrideInformation.InterfaceImplementor.Implementor);
2674 if (parameter is not null && Annotations.FlowAnnotations.RequiresGenericArgumentDataFlowAnalysis (parameter)) {
2686 Annotations.MarkRelevantToVariantCasting (argumentTypeDef);
2708 if (Annotations.TryGetPreserve (type, out TypePreserve preserve)) {
2709 if (!Annotations.SetAppliedPreserve (type, preserve))
2731 if (Annotations.TryGetPreservedMembers (type, out TypePreserveMembers members)) {
2793 var list = Annotations.GetPreservedMethods (type);
2797 Annotations.ClearPreservedMethods (type);
2803 var list = Annotations.GetPreservedMethods (method);
2807 Annotations.ClearPreservedMethods (method);
2876 Annotations.MarkRelevantToVariantCasting (typeDefinition);
2893 var methodAction = Annotations.GetAction (method);
2899 Annotations.TryGetMethodStubValue (method, out _);
2903 Annotations.SetAction (method, MethodAction.Parse);
2913 Debug.Assert (Annotations.IsMarked (method));
2916 Annotations.Mark (method, reason, origin);
3089 } else if (method.IsStaticConstructor () && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute> (method))
3093 if (!Annotations.ProcessSatelliteAssemblies && KnownMembers.IsSatelliteAssemblyMarker (method))
3094 Annotations.ProcessSatelliteAssemblies = true;
3111 bool markAllOverrides = assembly != null && Annotations.GetAction (assembly) is AssemblyAction.Copy or AssemblyAction.CopyUsed or AssemblyAction.Save;
3138 if (Annotations.GetOverrides (method) is IEnumerable<OverrideInformation> overrides) {
3139 foreach (var @override in overrides.Where (ov => Annotations.IsMarked (ov.Base) || IgnoreScope (ov.Base.DeclaringType.Scope))) {
3222 if (Annotations.IsInstantiated (type))
3225 Annotations.MarkInstantiated (type);
3249 var ifaces = Annotations.GetRecursiveInterfaces (method.DeclaringType);
3262 switch (Annotations.GetAction (method)) {
3328 var base_methods = Annotations.GetBaseMethods (method);
3351 Annotations.MarkProcessed (pii.Module, new DependencyInfo (DependencyKind.InteropMethodDependency, method));
3408 switch (Annotations.GetAction (method)) {
3415 switch (Annotations.GetAction (assembly)) {
3432 if (!Annotations.MarkProcessed (prop, reason))
3451 if (!Annotations.MarkProcessed (evt, reason))
3522 if (!Annotations.IsProcessed (methodIL.Method)) {
3528 Debug.Assert (Annotations.IsProcessed (owningMethod));
3564 && !Annotations.IsInstantiated (methodIL.Method.DeclaringType)
3656 Annotations.MarkRelevantToVariantCasting (typeDefinition);
3673 if (!Annotations.IsInstantiated (type)) {
3696 if (Annotations.IsMarked (iface))
3698 Annotations.MarkProcessed (iface, reason ?? new DependencyInfo (DependencyKind.InterfaceImplementationOnType, origin.Provider));