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);
1248if (type is null || !Annotations.IsMarked(type))
1257if (Annotations.HasPreservedStaticCtor(type))
1269Annotations.SetPreservedStaticCtor(type);
1281if (!Annotations.IsMarked(resolvedConstructor.Module) &&
1282!Annotations.IsMarked(ca.AttributeType) &&
1283Annotations.GetAction(resolvedConstructor.Module.Assembly) == AssemblyAction.Link)
1292if (displayTargetType == null || !Annotations.IsMarked(displayTargetType))
1353if (property != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(property.SetMethod))
1392if (field != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(field))
1438if (resolvedConstructor != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(resolvedConstructor))
1485return !Annotations.SetProcessed(provider);
1490Annotations.Mark(assembly, reason, origin);
1510var action = Annotations.GetAction(assembly);
1523else if (Annotations.IsRootAssembly(assembly))
1540Debug.Assert(Annotations.IsProcessed(assembly));
1623if (Annotations.HasMarkedAnyIndirectlyCalledMethods() && MarkDisablePrivateReflectionAttribute())
1650if (IsAttributeRemoved(customAttribute, resolved.DeclaringType) && Annotations.GetAction(CustomAttributeSource.GetAssemblyFromCustomAttributeProvider(assemblyLevelAttribute.Provider)) == AssemblyAction.Link)
1752if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1765isReflectionAccessCoveredByRUC = Annotations.DoesMethodRequireUnreferencedCode(method, out requiresUnreferencedCode);
1775isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1784isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1795isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1802bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(method);
1845bool isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(member, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute);
1856bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(member);
1873Debug.Assert(Annotations.IsMarked(field));
1877Annotations.Mark(field, reason, origin);
1915if (field.IsStatic && !Annotations.HasPreservedStaticCtor(parent))
1946if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1949if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(field, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute))
1960if (Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(field))
1973return assembly != null && Annotations.GetAction(assembly) != AssemblyAction.Link;
1980Debug.Assert(Annotations.IsMarked(module));
1984Annotations.Mark(module, reason, origin);
2017Annotations.MarkReflectionUsed(definition);
2025Annotations.MarkRelevantToVariantCasting(type);
2033Annotations.MarkReflectionUsed(methodDefinition);
2034Annotations.MarkIndirectlyCalledMethod(methodDefinition);
2038if (!Annotations.IsReflectionUsed(methodDefinition.DeclaringType))
2060if (IsFullyPreservedAction(Annotations.GetAction(type.Module.Assembly)))
2061Annotations.SetAction(method, MethodAction.ForceParse);
2072Annotations.MarkReflectionUsed(fieldDefinition);
2076if (!Annotations.IsReflectionUsed(fieldDefinition.DeclaringType))
2103if (propertyDefinition != null && !Annotations.IsMarked(propertyDefinition))
2171Debug.Assert(Annotations.IsMarked(type));
2174Annotations.Mark(type, reason, origin);
2182if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(type))
2371if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(resolvedAttributeType) && Annotations.GetAction(type.Module.Assembly) == AssemblyAction.Link)
2617var ifaces = Annotations.GetRecursiveInterfaces(type);
2632if (ifaces.All(Annotations.IsMarked))
2641if (Annotations.IsMarked(resolvedInterfaceType))
2685if (Annotations.IsMarked(method))
2691var base_list = Annotations.GetBaseMethods(method);
2728if (Annotations.IsMarked(method))
2734if (!((iface is not null && Annotations.IsMarked(iface))
2740if (!Annotations.IsMarked(@base) && !IgnoreScope(@base.DeclaringType.Scope))
2751return Annotations.IsRelevantToVariantCasting(overrideInformation.InterfaceImplementor.Implementor)
2756return Annotations.IsInstantiated(overrideInformation.InterfaceImplementor.Implementor);
3000if (Annotations.TryGetPreserve(type, out TypePreserve preserve))
3002if (!Annotations.SetAppliedPreserve(type, preserve))
3025if (Annotations.TryGetPreservedMembers(type, out TypePreserveMembers members))
3098var list = Annotations.GetPreservedMethods(type);
3102Annotations.ClearPreservedMethods(type);
3108var list = Annotations.GetPreservedMethods(method);
3112Annotations.ClearPreservedMethods(method);
3205if (Annotations.GetAction(method) == MethodAction.Nothing)
3206Annotations.SetAction(method, MethodAction.Parse);
3216Debug.Assert(Annotations.IsMarked(method));
3219Annotations.Mark(method, reason, origin);
3399else if (method.IsStaticConstructor() && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3401else if (method == method.Module.EntryPoint && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3406if (!Annotations.ProcessSatelliteAssemblies && KnownMembers.IsSatelliteAssemblyMarker(method))
3407Annotations.ProcessSatelliteAssemblies = true;
3428bool markAllOverrides = assembly != null && Annotations.GetAction(assembly) is AssemblyAction.Copy or AssemblyAction.CopyUsed or AssemblyAction.Save;
3456if (Annotations.GetOverrides(method) is IEnumerable<OverrideInformation> overrides)
3458foreach (var @override in overrides.Where(ov => Annotations.IsMarked(ov.Base) || IgnoreScope(ov.Base.DeclaringType.Scope)))
3547if (Annotations.IsInstantiated(type))
3550Annotations.MarkInstantiated(type);
3579var ifaces = Annotations.GetRecursiveInterfaces(method.DeclaringType);
3594switch (Annotations.GetAction(method))
3661var base_methods = Annotations.GetBaseMethods(method);
3687Annotations.MarkProcessed(pii.Module, new DependencyInfo(DependencyKind.InteropMethodDependency, method));
3753switch (Annotations.GetAction(method))
3761switch (Annotations.GetAction(assembly))
3779if (!Annotations.MarkProcessed(prop, reason))
3798if (!Annotations.MarkProcessed(evt, reason))
3895if (!Annotations.IsProcessed(methodIL.Method))
3902Debug.Assert(Annotations.IsProcessed(owningMethod));
3938&& !Annotations.IsInstantiated(methodIL.Method.DeclaringType)
4083if (!Annotations.IsInstantiated(type))
4108if (Annotations.IsMarked(iface))
4110Annotations.MarkProcessed(iface, reason ?? new DependencyInfo(DependencyKind.InterfaceImplementationOnType, origin.Provider));