public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            DependencyList result = new DependencyList();

            var lookupContext = new GenericLookupResultContext(_dictionaryOwner, typeInstantiation, methodInstantiation);

            switch (_id)
            {
            case ReadyToRunHelperId.GetGCStaticBase:
            case ReadyToRunHelperId.GetThreadStaticBase:
            {
                // If the type has a lazy static constructor, we also need the non-GC static base
                // because that's where the class constructor context is.
                TypeDesc type = (TypeDesc)_target;

                if (factory.TypeSystemContext.HasLazyStaticConstructor(type))
                {
                    result.Add(
                        new DependencyListEntry(
                            factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, lookupContext),
                            "Dictionary dependency"));
                }
            }
            break;

            case ReadyToRunHelperId.DelegateCtor:
            {
                DelegateCreationInfo createInfo = (DelegateCreationInfo)_target;
                if (createInfo.NeedsVirtualMethodUseTracking)
                {
                    MethodDesc instantiatedTargetMethod = createInfo.TargetMethod.GetNonRuntimeDeterminedMethodFromRuntimeDeterminedMethodViaSubstitution(typeInstantiation, methodInstantiation);
                    if (!factory.VTable(instantiatedTargetMethod.OwningType).HasFixedSlots)
                    {
                        result.Add(
                            new DependencyListEntry(
                                factory.VirtualMethodUse(instantiatedTargetMethod),
                                "Dictionary dependency"));
                    }

                    factory.MetadataManager.GetDependenciesDueToVirtualMethodReflectability(ref result, factory, instantiatedTargetMethod);
                }
            }
            break;
            }

            // All generic lookups depend on the thing they point to
            result.Add(new DependencyListEntry(
                           _lookupSignature.GetTarget(factory, lookupContext),
                           "Dictionary dependency"));

            return(result.ToArray());
        }
        public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            DependencyList result = new DependencyList();

            var lookupContext = new GenericLookupResultContext(_dictionaryOwner, typeInstantiation, methodInstantiation);

            switch (_id)
            {
            case ReadyToRunHelperId.GetGCStaticBase:
            case ReadyToRunHelperId.GetThreadStaticBase:
            {
                // If the type has a lazy static constructor, we also need the non-GC static base
                // because that's where the class constructor context is.
                TypeDesc type = (TypeDesc)_target;

                if (factory.PreinitializationManager.HasLazyStaticConstructor(type))
                {
                    result.Add(
                        new DependencyListEntry(
                            factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, lookupContext),
                            "Dictionary dependency"));
                }
            }
            break;

            case ReadyToRunHelperId.DelegateCtor:
            {
                DelegateCreationInfo createInfo = (DelegateCreationInfo)_target;
                if (createInfo.NeedsVirtualMethodUseTracking)
                {
                    MethodDesc instantiatedTargetMethod = createInfo.TargetMethod.GetNonRuntimeDeterminedMethodFromRuntimeDeterminedMethodViaSubstitution(typeInstantiation, methodInstantiation);
                    if (!factory.VTable(instantiatedTargetMethod.OwningType).HasFixedSlots)
                    {
                        result.Add(
                            new DependencyListEntry(
                                factory.VirtualMethodUse(instantiatedTargetMethod),
                                "Dictionary dependency"));
                    }

                    factory.MetadataManager.GetDependenciesDueToVirtualMethodReflectability(ref result, factory, instantiatedTargetMethod);
                }
            }
            break;
            }

            try
            {
                // All generic lookups depend on the thing they point to
                result.Add(new DependencyListEntry(
                               _lookupSignature.GetTarget(factory, lookupContext),
                               "Dictionary dependency"));
            }
            catch (TypeSystemException)
            {
                // If there was an exception, we're going to generate a null slot in the associated
                // dictionary. The helper needs to be able to handle a null slot and tailcall
                // and exception throwing helper instead of returning a result.
                _hasInvalidEntries = true;
                result.Add(GetBadSlotHelper(factory), "Failure to build dictionary slot");
            }

            return(result.ToArray());
        }