Linker.Steps\MarkStep.cs (132)
268startingAssembly ??= Annotations.GetEntryPointAssembly();
301Annotations.SetAction(body.Method, MethodAction.ConvertToThrow);
320if (Annotations.TryGetPreserve(type, out TypePreserve preserve) && preserve == TypePreserve.All)
323switch (Annotations.GetAction(type.Module.Assembly))
423Debug.Assert(Annotations.GetAction(assembly) == action);
438var action = Annotations.GetAction(assembly);
441if (!Annotations.IsProcessed(assembly))
469foreach (var pending in Annotations.GetMarkedPending())
474if (Annotations.IsProcessed(pending.Key))
493Annotations.SetProcessed(exportedType);
501foreach (var type in Annotations.GetPendingPreserve())
507foreach (var (method, origin) in Annotations.DrainPendingReflectionVisibleMethods())
513foreach (var (field, origin) in Annotations.DrainPendingReflectionVisibleFields())
519foreach (var (type, origin) in Annotations.DrainPendingReflectionVisibleTypes())
534if (Annotations.IsInstantiated(type))
592if (Annotations.IsInstantiated(type) || Annotations.IsRelevantToVariantCasting(type) ||
600var baseMethods = Annotations.GetBaseMethods(method);
619switch (Annotations.GetAction(assembly))
638if (!Annotations.IsMarked(type) && TypeIsDynamicInterfaceCastableImplementation(type))
663if (Annotations.IsMarked(type))
671if (Annotations.IsMarked(iface.InterfaceType))
689if (Annotations.IsInstantiated(body.Method.DeclaringType))
700Annotations.EnqueueVirtualMethod(method);
710var defaultImplementations = Annotations.GetDefaultInterfaceImplementations(method);
721List<OverrideInformation>? overridingMethods = (List<OverrideInformation>?)Annotations.GetOverrides(method);
741Debug.Assert(Annotations.IsMarked(overrideInformation.Base) || IgnoreScope(overrideInformation.Base.DeclaringType.Scope));
742if (!Annotations.IsMarked(overrideInformation.Override.DeclaringType))
753if (Annotations.IsInstantiated(overrideInformation.Override.DeclaringType))
771if (Context.IsOptimizationEnabled(CodeOptimizations.OverrideRemoval, overrideInformation.Override) && Annotations.IsInstantiated(overrideInformation.Override.DeclaringType))
785Debug.Assert(Annotations.IsMarked(method.DeclaringType));
787var bases = Annotations.GetBaseMethods(method);
791var markedBaseMethods = bases.Where(ov => Annotations.IsMarked(ov.Base) || IgnoreScope(ov.Base.DeclaringType.Scope));
835if ((!ov.Override.IsStatic && !Annotations.IsInstantiated(ov.InterfaceImplementor.Implementor))
836|| ov.Override.IsStatic && !Annotations.IsRelevantToVariantCasting(ov.InterfaceImplementor.Implementor))
863bool providerInLinkedAssembly = Annotations.GetAction(CustomAttributeSource.GetAssemblyFromCustomAttributeProvider(provider)) == AssemblyAction.Link;
895foreach (var dynamicDependency in Annotations.GetLinkerAttributes<DynamicDependency>(providerMember))
901foreach (var attr in Annotations.GetLinkerAttributes<RemoveAttributeInstancesAttribute>(attributeType))
1203Annotations.Mark(ca, reason);
1245if (type is null || !Annotations.IsMarked(type))
1254if (Annotations.HasPreservedStaticCtor(type))
1266Annotations.SetPreservedStaticCtor(type);
1278if (!Annotations.IsMarked(resolvedConstructor.Module) &&
1279!Annotations.IsMarked(ca.AttributeType) &&
1280Annotations.GetAction(resolvedConstructor.Module.Assembly) == AssemblyAction.Link)
1289if (displayTargetType == null || !Annotations.IsMarked(displayTargetType))
1350if (property != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(property.SetMethod))
1389if (field != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(field))
1435if (resolvedConstructor != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(resolvedConstructor))
1482return !Annotations.SetProcessed(provider);
1487Annotations.Mark(assembly, reason, origin);
1504var action = Annotations.GetAction(assembly);
1517else if (Annotations.IsRootAssembly(assembly))
1534Debug.Assert(Annotations.IsProcessed(assembly));
1617if (Annotations.HasMarkedAnyIndirectlyCalledMethods() && MarkDisablePrivateReflectionAttribute())
1644if (IsAttributeRemoved(customAttribute, resolved.DeclaringType) && Annotations.GetAction(CustomAttributeSource.GetAssemblyFromCustomAttributeProvider(assemblyLevelAttribute.Provider)) == AssemblyAction.Link)
1746if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1759isReflectionAccessCoveredByRUC = Annotations.DoesMethodRequireUnreferencedCode(method, out requiresUnreferencedCode);
1769isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1778isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1789isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1796bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(method);
1839bool isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(member, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute);
1850bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(member);
1867Debug.Assert(Annotations.IsMarked(field));
1871Annotations.Mark(field, reason, origin);
1909if (field.IsStatic && !Annotations.HasPreservedStaticCtor(parent))
1940if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1943if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(field, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute))
1954if (Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(field))
1967return assembly != null && Annotations.GetAction(assembly) != AssemblyAction.Link;
1974Debug.Assert(Annotations.IsMarked(module));
1978Annotations.Mark(module, reason, origin);
2011Annotations.MarkReflectionUsed(definition);
2019Annotations.MarkRelevantToVariantCasting(type);
2027Annotations.MarkReflectionUsed(methodDefinition);
2028Annotations.MarkIndirectlyCalledMethod(methodDefinition);
2032if (!Annotations.IsReflectionUsed(methodDefinition.DeclaringType))
2054if (IsFullyPreservedAction(Annotations.GetAction(type.Module.Assembly)))
2055Annotations.SetAction(method, MethodAction.ForceParse);
2066Annotations.MarkReflectionUsed(fieldDefinition);
2070if (!Annotations.IsReflectionUsed(fieldDefinition.DeclaringType))
2097if (propertyDefinition != null && !Annotations.IsMarked(propertyDefinition))
2165Debug.Assert(Annotations.IsMarked(type));
2168Annotations.Mark(type, reason, origin);
2176if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(type))
2365if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(resolvedAttributeType) && Annotations.GetAction(type.Module.Assembly) == AssemblyAction.Link)
2611var ifaces = Annotations.GetRecursiveInterfaces(type);
2626if (ifaces.All(Annotations.IsMarked))
2635if (Annotations.IsMarked(resolvedInterfaceType))
2679if (Annotations.IsMarked(method))
2685var base_list = Annotations.GetBaseMethods(method);
2722if (Annotations.IsMarked(method))
2728if (!((iface is not null && Annotations.IsMarked(iface))
2734if (!Annotations.IsMarked(@base) && !IgnoreScope(@base.DeclaringType.Scope))
2745return Annotations.IsRelevantToVariantCasting(overrideInformation.InterfaceImplementor.Implementor)
2750return Annotations.IsInstantiated(overrideInformation.InterfaceImplementor.Implementor);
2994if (Annotations.TryGetPreserve(type, out TypePreserve preserve))
2996if (!Annotations.SetAppliedPreserve(type, preserve))
3019if (Annotations.TryGetPreservedMembers(type, out TypePreserveMembers members))
3092var list = Annotations.GetPreservedMethods(type);
3096Annotations.ClearPreservedMethods(type);
3102var list = Annotations.GetPreservedMethods(method);
3106Annotations.ClearPreservedMethods(method);
3199if (Annotations.GetAction(method) == MethodAction.Nothing)
3200Annotations.SetAction(method, MethodAction.Parse);
3210Debug.Assert(Annotations.IsMarked(method));
3213Annotations.Mark(method, reason, origin);
3393else if (method.IsStaticConstructor() && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3395else if (method == method.Module.EntryPoint && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3400if (!Annotations.ProcessSatelliteAssemblies && KnownMembers.IsSatelliteAssemblyMarker(method))
3401Annotations.ProcessSatelliteAssemblies = true;
3422bool markAllOverrides = assembly != null && Annotations.GetAction(assembly) is AssemblyAction.Copy or AssemblyAction.CopyUsed or AssemblyAction.Save;
3450if (Annotations.GetOverrides(method) is IEnumerable<OverrideInformation> overrides)
3452foreach (var @override in overrides.Where(ov => Annotations.IsMarked(ov.Base) || IgnoreScope(ov.Base.DeclaringType.Scope)))
3541if (Annotations.IsInstantiated(type))
3544Annotations.MarkInstantiated(type);
3573var ifaces = Annotations.GetRecursiveInterfaces(method.DeclaringType);
3588switch (Annotations.GetAction(method))
3655var base_methods = Annotations.GetBaseMethods(method);
3681Annotations.MarkProcessed(pii.Module, new DependencyInfo(DependencyKind.InteropMethodDependency, method));
3747switch (Annotations.GetAction(method))
3755switch (Annotations.GetAction(assembly))
3773if (!Annotations.MarkProcessed(prop, reason))
3792if (!Annotations.MarkProcessed(evt, reason))
3889if (!Annotations.IsProcessed(methodIL.Method))
3896Debug.Assert(Annotations.IsProcessed(owningMethod));
3932&& !Annotations.IsInstantiated(methodIL.Method.DeclaringType)
4077if (!Annotations.IsInstantiated(type))
4102if (Annotations.IsMarked(iface))
4104Annotations.MarkProcessed(iface, reason ?? new DependencyInfo(DependencyKind.InterfaceImplementationOnType, origin.Provider));