Skip to content
Merged
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 @@ -245,7 +245,15 @@ protected override void GetMetadataDependenciesDueToReflectability(ref Dependenc
bool fullyRoot;
string reason;

if (_rootEntireAssembliesModules.Contains(assemblyName))
// Compat with https://github.com/dotnet/linker/issues/1541 IL Linker bug:
// Asking to root an assembly with entrypoint will not actually root things in the assembly.
// We need to emulate this because the SDK injects a root for the entrypoint assembly right now
// because of IL Linker's implementation details (IL Linker won't root Main() by itself).
// TODO: We should technically reflection-root Main() here but hopefully the above issue
// will be fixed before it comes to that being necessary.
bool isEntrypointAssembly = module is EcmaModule ecmaModule && ecmaModule.PEReader.PEHeaders.IsExe;

if (!isEntrypointAssembly && _rootEntireAssembliesModules.Contains(assemblyName))
{
// If the assembly was specified as a root on the command line, root it
fullyRoot = true;
Expand Down