Linker.Steps\MarkStep.cs (132)
269startingAssembly ??= Annotations.GetEntryPointAssembly();
302Annotations.SetAction(body.Method, MethodAction.ConvertToThrow);
321if (Annotations.TryGetPreserve(type, out TypePreserve preserve) && preserve == TypePreserve.All)
324switch (Annotations.GetAction(type.Module.Assembly))
424Debug.Assert(Annotations.GetAction(assembly) == action);
439var action = Annotations.GetAction(assembly);
442if (!Annotations.IsProcessed(assembly))
470foreach (var pending in Annotations.GetMarkedPending())
475if (Annotations.IsProcessed(pending.Key))
494Annotations.SetProcessed(exportedType);
502foreach (var type in Annotations.GetPendingPreserve())
508foreach (var (method, origin) in Annotations.DrainPendingReflectionVisibleMethods())
514foreach (var (field, origin) in Annotations.DrainPendingReflectionVisibleFields())
520foreach (var (type, origin) in Annotations.DrainPendingReflectionVisibleTypes())
535if (Annotations.IsInstantiated(type))
593if (Annotations.IsInstantiated(type) || Annotations.IsRelevantToVariantCasting(type) ||
601var baseMethods = Annotations.GetBaseMethods(method);
620switch (Annotations.GetAction(assembly))
639if (!Annotations.IsMarked(type) && TypeIsDynamicInterfaceCastableImplementation(type))
664if (Annotations.IsMarked(type))
672if (Annotations.IsMarked(iface.InterfaceType))
690if (Annotations.IsInstantiated(body.Method.DeclaringType))
701Annotations.EnqueueVirtualMethod(method);
711var defaultImplementations = Annotations.GetDefaultInterfaceImplementations(method);
722List<OverrideInformation>? overridingMethods = (List<OverrideInformation>?)Annotations.GetOverrides(method);
742Debug.Assert(Annotations.IsMarked(overrideInformation.Base) || IgnoreScope(overrideInformation.Base.DeclaringType.Scope));
743if (!Annotations.IsMarked(overrideInformation.Override.DeclaringType))
754if (Annotations.IsInstantiated(overrideInformation.Override.DeclaringType))
772if (Context.IsOptimizationEnabled(CodeOptimizations.OverrideRemoval, overrideInformation.Override) && Annotations.IsInstantiated(overrideInformation.Override.DeclaringType))
786Debug.Assert(Annotations.IsMarked(method.DeclaringType));
788var bases = Annotations.GetBaseMethods(method);
792var markedBaseMethods = bases.Where(ov => Annotations.IsMarked(ov.Base) || IgnoreScope(ov.Base.DeclaringType.Scope));
836if ((!ov.Override.IsStatic && !Annotations.IsInstantiated(ov.InterfaceImplementor.Implementor))
837|| ov.Override.IsStatic && !Annotations.IsRelevantToVariantCasting(ov.InterfaceImplementor.Implementor))
864bool providerInLinkedAssembly = Annotations.GetAction(CustomAttributeSource.GetAssemblyFromCustomAttributeProvider(provider)) == AssemblyAction.Link;
896foreach (var dynamicDependency in Annotations.GetLinkerAttributes<DynamicDependency>(providerMember))
902foreach (var attr in Annotations.GetLinkerAttributes<RemoveAttributeInstancesAttribute>(attributeType))
1204Annotations.Mark(ca, reason);
1249if (type is null || !Annotations.IsMarked(type))
1258if (Annotations.HasPreservedStaticCtor(type))
1270Annotations.SetPreservedStaticCtor(type);
1282if (!Annotations.IsMarked(resolvedConstructor.Module) &&
1283!Annotations.IsMarked(ca.AttributeType) &&
1284Annotations.GetAction(resolvedConstructor.Module.Assembly) == AssemblyAction.Link)
1293if (displayTargetType == null || !Annotations.IsMarked(displayTargetType))
1354if (property != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(property.SetMethod))
1393if (field != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(field))
1439if (resolvedConstructor != null && Annotations.FlowAnnotations.RequiresDataFlowAnalysis(resolvedConstructor))
1486return !Annotations.SetProcessed(provider);
1491Annotations.Mark(assembly, reason, origin);
1511var action = Annotations.GetAction(assembly);
1524else if (Annotations.IsRootAssembly(assembly))
1541Debug.Assert(Annotations.IsProcessed(assembly));
1624if (Annotations.HasMarkedAnyIndirectlyCalledMethods() && MarkDisablePrivateReflectionAttribute())
1651if (IsAttributeRemoved(customAttribute, resolved.DeclaringType) && Annotations.GetAction(CustomAttributeSource.GetAssemblyFromCustomAttributeProvider(assemblyLevelAttribute.Provider)) == AssemblyAction.Link)
1756if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1769isReflectionAccessCoveredByRUC = Annotations.DoesMethodRequireUnreferencedCode(method, out requiresUnreferencedCode);
1779isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1788isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1799isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(method, out requiresUnreferencedCode);
1806bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(method);
1849bool isReflectionAccessCoveredByRUC = Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(member, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute);
1860bool isReflectionAccessCoveredByDAM = Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(member);
1877Debug.Assert(Annotations.IsMarked(field));
1881Annotations.Mark(field, reason, origin);
1919if (field.IsStatic && !Annotations.HasPreservedStaticCtor(parent))
1953if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(origin.Provider, out _))
1956if (Annotations.ShouldSuppressAnalysisWarningsForRequiresUnreferencedCode(field, out RequiresUnreferencedCodeAttribute? requiresUnreferencedCodeAttribute))
1967if (Annotations.FlowAnnotations.ShouldWarnWhenAccessedForReflection(field))
1980return assembly != null && Annotations.GetAction(assembly) != AssemblyAction.Link;
1987Debug.Assert(Annotations.IsMarked(module));
1991Annotations.Mark(module, reason, origin);
2024Annotations.MarkReflectionUsed(definition);
2032Annotations.MarkRelevantToVariantCasting(type);
2034if (Context.TryResolve(type.BaseType) is TypeDefinition baseType && !Annotations.IsRelevantToVariantCasting(baseType))
2043Annotations.MarkReflectionUsed(methodDefinition);
2044Annotations.MarkIndirectlyCalledMethod(methodDefinition);
2048if (!Annotations.IsReflectionUsed(methodDefinition.DeclaringType))
2087if (IsFullyPreservedAction(Annotations.GetAction(type.Module.Assembly)))
2088Annotations.SetAction(method, MethodAction.ForceParse);
2099Annotations.MarkReflectionUsed(fieldDefinition);
2103if (!Annotations.IsReflectionUsed(fieldDefinition.DeclaringType))
2147if (propertyDefinition != null && !Annotations.IsMarked(propertyDefinition))
2215Debug.Assert(Annotations.IsMarked(type));
2218Annotations.Mark(type, reason, origin);
2226if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(type))
2415if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(resolvedAttributeType) && Annotations.GetAction(type.Module.Assembly) == AssemblyAction.Link)
2661var ifaces = Annotations.GetRecursiveInterfaces(type);
2676if (ifaces.All(Annotations.IsMarked))
2685if (Annotations.IsMarked(resolvedInterfaceType))
2729if (Annotations.IsMarked(method))
2735var base_list = Annotations.GetBaseMethods(method);
2772if (Annotations.IsMarked(method))
2778if (!((iface is not null && Annotations.IsMarked(iface))
2784if (!Annotations.IsMarked(@base) && !IgnoreScope(@base.DeclaringType.Scope))
2795return Annotations.IsRelevantToVariantCasting(overrideInformation.InterfaceImplementor.Implementor)
2800return Annotations.IsInstantiated(overrideInformation.InterfaceImplementor.Implementor);
3044if (Annotations.TryGetPreserve(type, out TypePreserve preserve))
3046if (!Annotations.SetAppliedPreserve(type, preserve))
3069if (Annotations.TryGetPreservedMembers(type, out TypePreserveMembers members))
3142var list = Annotations.GetPreservedMethods(type);
3146Annotations.ClearPreservedMethods(type);
3152var list = Annotations.GetPreservedMethods(method);
3156Annotations.ClearPreservedMethods(method);
3249if (Annotations.GetAction(method) == MethodAction.Nothing)
3250Annotations.SetAction(method, MethodAction.Parse);
3260Debug.Assert(Annotations.IsMarked(method));
3263Annotations.Mark(method, reason, origin);
3443else if (method.IsStaticConstructor() && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3445else if (method == method.Module.EntryPoint && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3450if (!Annotations.ProcessSatelliteAssemblies && KnownMembers.IsSatelliteAssemblyMarker(method))
3451Annotations.ProcessSatelliteAssemblies = true;
3472bool markAllOverrides = assembly != null && Annotations.GetAction(assembly) is AssemblyAction.Copy or AssemblyAction.CopyUsed or AssemblyAction.Save;
3500if (Annotations.GetOverrides(method) is IEnumerable<OverrideInformation> overrides)
3502foreach (var @override in overrides.Where(ov => Annotations.IsMarked(ov.Base) || IgnoreScope(ov.Base.DeclaringType.Scope)))
3591if (Annotations.IsInstantiated(type))
3594Annotations.MarkInstantiated(type);
3623var ifaces = Annotations.GetRecursiveInterfaces(method.DeclaringType);
3638switch (Annotations.GetAction(method))
3705var base_methods = Annotations.GetBaseMethods(method);
3731Annotations.MarkProcessed(pii.Module, new DependencyInfo(DependencyKind.InteropMethodDependency, method));
3797switch (Annotations.GetAction(method))
3805switch (Annotations.GetAction(assembly))
3823if (!Annotations.MarkProcessed(prop, reason))
3842if (!Annotations.MarkProcessed(evt, reason))
3982&& !Annotations.IsInstantiated(methodIL.Method.DeclaringType)
4127if (!Annotations.IsInstantiated(type))
4152if (Annotations.IsMarked(iface))
4154Annotations.MarkProcessed(iface, reason ?? new DependencyInfo(DependencyKind.InterfaceImplementationOnType, origin.Provider));
4160Annotations.TryGetLinkerAttribute<RequiresUnreferencedCodeAttribute>(implementingType, out _);