Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFact
}

// Keep track of the default constructor map dependency for this type if it has a default constructor
// We only do this for reflection blocked types because dataflow analysis is responsible for
// generating default constructors for Activator.CreateInstance in other cases.
MethodDesc defaultCtor = closestDefType.GetDefaultConstructor();
if (defaultCtor != null)
if (defaultCtor != null && factory.MetadataManager.IsReflectionBlocked(defaultCtor))
{
dependencyList.Add(new DependencyListEntry(
factory.CanonicalEntrypoint(defaultCtor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFact
factory.InteropStubManager.AddInterestingInteropConstructedTypeDependencies(ref dependencyList, factory, _type);

// Keep track of the default constructor map dependency for this type if it has a default constructor
// We only do this for reflection blocked types because dataflow analysis is responsible for
// generating default constructors for Activator.CreateInstance in other cases.
MethodDesc defaultCtor = closestDefType.GetDefaultConstructor();
if (defaultCtor != null)
if (defaultCtor != null && factory.MetadataManager.IsReflectionBlocked(defaultCtor))
{
dependencyList.Add(new DependencyListEntry(
factory.CanonicalEntrypoint(defaultCtor),
factory.CanonicalEntrypoint(defaultCtor),
"DefaultConstructorNode"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
if (defaultCtor == null)
continue;

// We only place default constructors of reflection-blocked types in this table.
// At runtime, the type loader will search both this table and the invoke map
// for default constructor info. If the ctor is reflectable, we would have
// expected dataflow analysis to ensure there's a reflectable method for it.
// If we don't find a reflectable method for the ctor of a non-blocked type
// there would have to be a dataflow analysis warning.
if (!factory.MetadataManager.IsReflectionBlocked(defaultCtor))
continue;

defaultCtor = defaultCtor.GetCanonMethodTarget(CanonicalFormKind.Specific);

ISymbolNode typeNode = factory.NecessaryTypeSymbol(type);
Expand Down