Linker.Steps\MarkStep.cs (131)
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);
2040Annotations.MarkReflectionUsed(methodDefinition);
2041Annotations.MarkIndirectlyCalledMethod(methodDefinition);
2045if (!Annotations.IsReflectionUsed(methodDefinition.DeclaringType))
2084if (IsFullyPreservedAction(Annotations.GetAction(type.Module.Assembly)))
2085Annotations.SetAction(method, MethodAction.ForceParse);
2096Annotations.MarkReflectionUsed(fieldDefinition);
2100if (!Annotations.IsReflectionUsed(fieldDefinition.DeclaringType))
2144if (propertyDefinition != null && !Annotations.IsMarked(propertyDefinition))
2212Debug.Assert(Annotations.IsMarked(type));
2215Annotations.Mark(type, reason, origin);
2223if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(type))
2412if (Annotations.HasLinkerAttribute<RemoveAttributeInstancesAttribute>(resolvedAttributeType) && Annotations.GetAction(type.Module.Assembly) == AssemblyAction.Link)
2658var ifaces = Annotations.GetRecursiveInterfaces(type);
2673if (ifaces.All(Annotations.IsMarked))
2682if (Annotations.IsMarked(resolvedInterfaceType))
2726if (Annotations.IsMarked(method))
2732var base_list = Annotations.GetBaseMethods(method);
2769if (Annotations.IsMarked(method))
2775if (!((iface is not null && Annotations.IsMarked(iface))
2781if (!Annotations.IsMarked(@base) && !IgnoreScope(@base.DeclaringType.Scope))
2792return Annotations.IsRelevantToVariantCasting(overrideInformation.InterfaceImplementor.Implementor)
2797return Annotations.IsInstantiated(overrideInformation.InterfaceImplementor.Implementor);
3041if (Annotations.TryGetPreserve(type, out TypePreserve preserve))
3043if (!Annotations.SetAppliedPreserve(type, preserve))
3066if (Annotations.TryGetPreservedMembers(type, out TypePreserveMembers members))
3139var list = Annotations.GetPreservedMethods(type);
3143Annotations.ClearPreservedMethods(type);
3149var list = Annotations.GetPreservedMethods(method);
3153Annotations.ClearPreservedMethods(method);
3246if (Annotations.GetAction(method) == MethodAction.Nothing)
3247Annotations.SetAction(method, MethodAction.Parse);
3257Debug.Assert(Annotations.IsMarked(method));
3260Annotations.Mark(method, reason, origin);
3440else if (method.IsStaticConstructor() && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3442else if (method == method.Module.EntryPoint && Annotations.HasLinkerAttribute<RequiresUnreferencedCodeAttribute>(method))
3447if (!Annotations.ProcessSatelliteAssemblies && KnownMembers.IsSatelliteAssemblyMarker(method))
3448Annotations.ProcessSatelliteAssemblies = true;
3469bool markAllOverrides = assembly != null && Annotations.GetAction(assembly) is AssemblyAction.Copy or AssemblyAction.CopyUsed or AssemblyAction.Save;
3497if (Annotations.GetOverrides(method) is IEnumerable<OverrideInformation> overrides)
3499foreach (var @override in overrides.Where(ov => Annotations.IsMarked(ov.Base) || IgnoreScope(ov.Base.DeclaringType.Scope)))
3588if (Annotations.IsInstantiated(type))
3591Annotations.MarkInstantiated(type);
3620var ifaces = Annotations.GetRecursiveInterfaces(method.DeclaringType);
3635switch (Annotations.GetAction(method))
3702var base_methods = Annotations.GetBaseMethods(method);
3728Annotations.MarkProcessed(pii.Module, new DependencyInfo(DependencyKind.InteropMethodDependency, method));
3794switch (Annotations.GetAction(method))
3802switch (Annotations.GetAction(assembly))
3820if (!Annotations.MarkProcessed(prop, reason))
3839if (!Annotations.MarkProcessed(evt, reason))
3979&& !Annotations.IsInstantiated(methodIL.Method.DeclaringType)
4124if (!Annotations.IsInstantiated(type))
4149if (Annotations.IsMarked(iface))
4151Annotations.MarkProcessed(iface, reason ?? new DependencyInfo(DependencyKind.InterfaceImplementationOnType, origin.Provider));
4157Annotations.TryGetLinkerAttribute<RequiresUnreferencedCodeAttribute>(implementingType, out _);