Linker.Steps\MarkStep.cs (133)
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)
1755if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1768isReflectionAccessCoveredByRUC = Annotations.DoesMethodRequireUnreferencedCode(method, out requiresUnreferencedCode);
1778isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1787isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1798isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1805bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(method);
1848bool isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(member, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute);
1859bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(member);
1876Debug.Assert(Annotations.IsMarked(field));
1880Annotations.Mark(field, reason, origin);
1918if (field.IsStatic && !Annotations.HasPreservedStaticCtor(parent))
1952if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1955if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(field, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute))
1966if (Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(field))
1979return assembly != null && Annotations.GetAction(assembly) != AssemblyAction.Link;
1986Debug.Assert(Annotations.IsMarked(module));
1990Annotations.Mark(module, reason, origin);
2023Annotations.MarkReflectionUsed(definition);
2031Annotations.MarkRelevantToVariantCasting(type);
2039Annotations.MarkReflectionUsed(methodDefinition);
2040Annotations.MarkIndirectlyCalledMethod(methodDefinition);
2044if (!Annotations.IsReflectionUsed(methodDefinition.DeclaringType))
2066if (IsFullyPreservedAction(Annotations.GetAction(type.Module.Assembly)))
2067Annotations.SetAction(method, MethodAction.ForceParse);
2078Annotations.MarkReflectionUsed(fieldDefinition);
2082if (!Annotations.IsReflectionUsed(fieldDefinition.DeclaringType))
2109if (propertyDefinition != null && !Annotations.IsMarked(propertyDefinition))
2177Debug.Assert(Annotations.IsMarked(type));
2180Annotations.Mark(type, reason, origin);
2188if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(type))
2377if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(resolvedAttributeType) && Annotations.GetAction(type.Module.Assembly) == AssemblyAction.Link)
2623var ifaces = Annotations.GetRecursiveInterfaces(type);
2638if (ifaces.All(Annotations.IsMarked))
2647if (Annotations.IsMarked(resolvedInterfaceType))
2691if (Annotations.IsMarked(method))
2697var base_list = Annotations.GetBaseMethods(method);
2734if (Annotations.IsMarked(method))
2740if (!((iface is not null && Annotations.IsMarked(iface))
2746if (!Annotations.IsMarked(@base) && !IgnoreScope(@base.DeclaringType.Scope))
2757return Annotations.IsRelevantToVariantCasting(overrideInformation.InterfaceImplementor.Implementor)
2762return Annotations.IsInstantiated(overrideInformation.InterfaceImplementor.Implementor);
3006if (Annotations.TryGetPreserve(type, out TypePreserve preserve))
3008if (!Annotations.SetAppliedPreserve(type, preserve))
3031if (Annotations.TryGetPreservedMembers(type, out TypePreserveMembers members))
3104var list = Annotations.GetPreservedMethods(type);
3108Annotations.ClearPreservedMethods(type);
3114var list = Annotations.GetPreservedMethods(method);
3118Annotations.ClearPreservedMethods(method);
3211if (Annotations.GetAction(method) == MethodAction.Nothing)
3212Annotations.SetAction(method, MethodAction.Parse);
3222Debug.Assert(Annotations.IsMarked(method));
3225Annotations.Mark(method, reason, origin);
3405else if (method.IsStaticConstructor() && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3407else if (method == method.Module.EntryPoint && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3412if (!Annotations.ProcessSatelliteAssemblies && KnownMembers.IsSatelliteAssemblyMarker(method))
3413Annotations.ProcessSatelliteAssemblies = true;
3434bool markAllOverrides = assembly != null && Annotations.GetAction(assembly) is AssemblyAction.Copy or AssemblyAction.CopyUsed or AssemblyAction.Save;
3462if (Annotations.GetOverrides(method) is IEnumerable<OverrideInformation> overrides)
3464foreach (var @override in overrides.Where(ov => Annotations.IsMarked(ov.Base) || IgnoreScope(ov.Base.DeclaringType.Scope)))
3553if (Annotations.IsInstantiated(type))
3556Annotations.MarkInstantiated(type);
3585var ifaces = Annotations.GetRecursiveInterfaces(method.DeclaringType);
3600switch (Annotations.GetAction(method))
3667var base_methods = Annotations.GetBaseMethods(method);
3693Annotations.MarkProcessed(pii.Module, new DependencyInfo(DependencyKind.InteropMethodDependency, method));
3759switch (Annotations.GetAction(method))
3767switch (Annotations.GetAction(assembly))
3785if (!Annotations.MarkProcessed(prop, reason))
3804if (!Annotations.MarkProcessed(evt, reason))
3901if (!Annotations.IsProcessed(methodIL.Method))
3908Debug.Assert(Annotations.IsProcessed(owningMethod));
3944&& !Annotations.IsInstantiated(methodIL.Method.DeclaringType)
4089if (!Annotations.IsInstantiated(type))
4114if (Annotations.IsMarked(iface))
4116Annotations.MarkProcessed(iface, reason ?? new DependencyInfo(DependencyKind.InterfaceImplementationOnType, origin.Provider));
4122Annotations.TryGetLinkerAttribute<RequiresUnreferencedCodeAttribute>(implementingType, out _);