Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable processing of dynamically referenced assemblies #1611

Closed
wants to merge 9 commits into from

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Nov 6, 2020

This introduces the ability to add assemblies to LinkContext lazily and have them
processed in MarkStep. For now, the only additional processing is to
load references and run the TypeMap logic. Later, embedded XML processing and
constant propagation will also happen for lazy assemblies.

This is Phase 1 outlined in #1164 (comment).

Fixes #943
Fixes #1079

This still needs a bit of work to handle a case where a dynamic assembly is resolved but not marked (for example when using GetType for an assembly-qualified type where the assembly exists, but the type doesn't). In this case, SweepStep can make some false assumptions.

This introduces the ability to add assemblies to LinkContext lazily and have them
processed in MarkStep. For now, the only additional processing is to
load references and run the TypeMap logic. Later, embedded XML processing and
constant propagation will also happen for lazy assemblies.

This is Phase 1 outlined in dotnet#1164 (comment).

Fixes dotnet#943
Fixes dotnet#1079
- Use Resolve for debugger attributes and CreateInstance
- Don't process references for types that come from already-processed assemblies
- Don't throw when resolving dynamic references to assemblies
- Don't allow specifying assembly with assembly-qualified type name
And update some tests
src/linker/Linker.Steps/LoadReferencesStep.cs Show resolved Hide resolved
src/linker/Linker.Steps/LoadReferencesStep.cs Outdated Show resolved Hide resolved
src/linker/Linker.Steps/IAssemblyStep.cs Show resolved Hide resolved
src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs Outdated Show resolved Hide resolved
@@ -7,6 +7,9 @@ namespace Mono.Linker.Tests.Cases.Attributes
{
[Reference ("System.dll")]
[SetupLinkerCoreAction ("link")]
// IComponent has TypeConverterAttribute referencing System.dll, which has
// unresolved references to Win32 assemblies.
[SetupLinkerArgument ("--skip-unresolved", "true")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this. Is ths PR is making the situation worse instead of better?

src/linker/Linker/Pipeline.cs Outdated Show resolved Hide resolved
src/linker/Linker.Steps/IAssemblyStep.cs Show resolved Hide resolved
And fix up some existing tests
This could lead to some extra processing, but it guarantees that
references resolved in SweepStep will be registered with the context.

Also make TryParseTypeName return a bool.
@sbomer
Copy link
Member Author

sbomer commented Jan 5, 2021

Closing in favor of #1666

@sbomer sbomer closed this Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants