Repository navigation
Option to keep assemblies that have only type forwarders referenced. - #12
Conversation
|
Hi @erozenfeld, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! The agreement was validated by .NET Foundation and real humans are currently evaluating your PR. TTYL, DNFBOT; |
akoeplinger
left a comment
There was a problem hiding this comment.
LGTM but I'm no authority on this codebase so I'll let the other guys chime in :)
| break; | ||
| case 't': | ||
| context.KeepTypeForwarderOnlyAssemblies = true; | ||
| break; |
|
As I noted in #2 (comment) we can move this option to be specific to the code that XI ships. However I don't mind making it an option in the linker code itself. |
| // type forwarders from Delete assemblies | ||
| // thus try to resolve all the type references and see | ||
| // if some changed the scope. if yes change the action to Save | ||
| if (ResolveAllTypeReferences (assembly)) |
There was a problem hiding this comment.
Should be just && instead of extra if
|
|
||
| MarkType (context, type); | ||
|
|
||
| if (assembly.MainModule.HasExportedTypes) { |
There was a problem hiding this comment.
Can we not copy this block of code?
There was a problem hiding this comment.
Note that only the first part of the block is the same as in MarkStep. I'm happy to factor them into a method but I'm not sure where to put that method. MarkStep and ResolveFromAssemblyStep don't share a common base. Any suggestions?
| continue; | ||
| var resolvedExportedType = exported.Resolve (); | ||
| var resolvedTypeAssembly = context.Resolve (resolvedExportedType.Scope); | ||
| context.Annotations.Push (resolvedTypeAssembly); |
There was a problem hiding this comment.
What do you need it for ?
There was a problem hiding this comment.
If a library assembly is specified as a root via -a, that means that anything in the library can be accessed. I think exported types should be included for consistency. For example, I may specify -a for an assembly because I believe anything in it can potentially be a target of a reflection. That should include exported types.
There was a problem hiding this comment.
My question was why do you need to do context.Annotations.Push (resolvedTypeAssembly);
|
@akoeplinger It looks like it doesn't have permissions to update the mono/linker status again. |
|
@dotnet-bot test this please |
|
@mmitche hmm weird, I see dotnet-bot has write access: |
|
It's not dotnet-bot doing to the update. It's the CI application. Someone revoked access. |
8211c2a to
f55bec5
Compare
| Annotations.SetAction (assembly, AssemblyAction.Save); | ||
| if (!Context.KeepTypeForwarderOnlyAssemblies) { | ||
| ResolveAllTypeReferences (assembly); | ||
| } |
There was a problem hiding this comment.
I added the above lines in this round of review. There is no reason to resolve all type references if type forwarder-only assemblies are kept.
| ResolveAllTypeReferences (assembly); | ||
| if (!Context.KeepTypeForwarderOnlyAssemblies) { | ||
| ResolveAllTypeReferences (assembly); | ||
| } |
There was a problem hiding this comment.
I added the above lines in this round of review. There is no reason to resolve all type references if type forwarder-only assemblies are kept.
|
@marek-safar @akoeplinger @spouliot I addressed code review feedback and made a couple of additional changes. PTAL |
| LinkContext context = new LinkContext (pipeline); | ||
| context.CoreAction = AssemblyAction.Skip; | ||
| context.OutputDirectory = "output"; | ||
| context.KeepTypeForwarderOnlyAssemblies = false; |
There was a problem hiding this comment.
No need to re-set default false value
There was a problem hiding this comment.
Removed this line.
| continue; | ||
| var resolvedExportedType = exported.Resolve (); | ||
| var resolvedTypeAssembly = context.Resolve (resolvedExportedType.Scope); | ||
| context.Annotations.Push (resolvedTypeAssembly); |
There was a problem hiding this comment.
My question was why do you need to do context.Annotations.Push (resolvedTypeAssembly);
The linker had an optimization that removed assemblies that had only type forwarders referenced. dotnet#2 broke that optimization by adding a line that marked assembly.MainModule whenever a type forwarder was marked. This change introduces a new switch -t that controls this optimization. The optimization is on by default; if -t is specified, the optimization is disabled and assemblies with referenced type forwarders are kept. Additionally, this includes a change that marks all type forwarders in assemblies specified with -a.
f55bec5 to
0c0bd37
Compare
|
I removed the calls to |
|
@marek-safar I addressed your feedback, PTAL. |
|
@mmitche @akoeplinger How can we sort out the CI application access issue? |
|
Can you give me admin access to this repo temporarily so I can see the settings? |
|
@dotnet-bot test this please |
…aaecdb38a68e44 parent 3b9ffe6 author Jackson Schuster <[email protected]> 1642552996 -0800 committer Jackson Schuster <[email protected]> 1642552996 -0800 parent ea177be author Jackson Schuster <[email protected]> 1642552698 -0800 committer Jackson Schuster <[email protected]> 1642552698 -0800 Add Function to parse xml and return a list of injected attributes Finalize schema so all test xml is valid Add restrictions on some attributes and change uses of "nothing" to "none" Remove schema reference in generated file expectation Initial Schema work Add restrictions on some attributes and change uses of "nothing" to "none" Adds a more restrictive schema for LinkAttributes and updates paths for linux Update docs to use 'none' instead of 'nothing' remove schema from xml expectation file remove namespace from xml schema location # This is the commit message dotnet#12: intial xml parsing

The linker had an optimization that removed assemblies that had only type forwarders referenced.
#2 broke that optimization by adding a line that
marked assembly.MainModule whenever a type forwarder was marked.
This change introduces a new switch -t that controls this optimization. The optimization is on
by default; if -t is specified, the optimization is disabled and assemblies with referenced type
forwarders are kept.
Additionally, this includes a change that marks all type forwarders in assemblies specified with -a.